From 3c8f591cc448011fd10bbb132910c91c27f5ad6c Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Thu, 29 Jun 2023 15:29:42 -0300 Subject: [PATCH] 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. --- apps/emqx_mongodb/src/emqx_mongodb.erl | 27 ++++++++++++++++++++++++-- changes/ee/fix-11163.en.md | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 changes/ee/fix-11163.en.md diff --git a/apps/emqx_mongodb/src/emqx_mongodb.erl b/apps/emqx_mongodb/src/emqx_mongodb.erl index 9daffd43f..4236517e2 100644 --- a/apps/emqx_mongodb/src/emqx_mongodb.erl +++ b/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}, diff --git a/changes/ee/fix-11163.en.md b/changes/ee/fix-11163.en.md new file mode 100644 index 000000000..40201ba06 --- /dev/null +++ b/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.