Przeglądaj źródła

fix(mongodb): hide `topology.pool_size` and fix it at 1

Fixes https://emqx.atlassian.net/browse/EMQX-10408

From an old conversation with @kjellwinblad:

> There are 3 pool_sizes
> - The buffer workers pool size, just exposed here: https://github.com/emqx/emqx/pull/9742
> - The topology.pool_size, which controls the pool size for the poolboy_pool in Kjell's
  diagram (on mongodb's side).
> - The pool_size from emqx_connector_mongo:mongo_fields that controls the ecpool pool
  size (on EMQX's side).
> So we actually want to set topology.pool_size = 1 and hide it from users.
Thales Macedo Garitezi 2 lat temu
rodzic
commit
3c8f591cc4

+ 25 - 2
apps/emqx_mongodb/src/emqx_mongodb.erl

@@ -97,7 +97,14 @@ fields(sharded) ->
     ] ++ mongo_fields();
 fields(topology) ->
     [
-        {pool_size, fun emqx_connector_schema_lib:pool_size/1},
+        {pool_size,
+            hoconsc:mk(
+                pos_integer(),
+                #{
+                    deprecated => {since, "5.1.1"},
+                    importance => ?IMPORTANCE_HIDDEN
+                }
+            )},
         {max_overflow, fun max_overflow/1},
         {overflow_ttl, duration("overflow_ttl")},
         {overflow_check_period, duration("overflow_check_period")},
@@ -174,7 +181,23 @@ on_start(
             false ->
                 [{ssl, false}]
         end,
-    Topology = maps:get(topology, NConfig, #{}),
+    Topology0 = maps:get(topology, NConfig, #{}),
+    %% we fix this at 1 because we already have ecpool
+    case maps:get(pool_size, Topology0, 1) =:= 1 of
+        true ->
+            ok;
+        false ->
+            ?SLOG(
+                info,
+                #{
+                    msg => "mongodb_overriding_topology_pool_size",
+                    connector => InstId,
+                    reason => "this option is deprecated; please set `pool_size' for the connector",
+                    value => 1
+                }
+            )
+    end,
+    Topology = Topology0#{pool_size => 1},
     Opts = [
         {mongo_type, init_type(NConfig)},
         {hosts, Hosts},

+ 1 - 0
changes/ee/fix-11163.en.md

@@ -0,0 +1 @@
+Fixed `topology.pool_size = 1` and hid such option from users for MondoDB bridges to avoid confusion.