diff --git a/apps/emqx_connector/i18n/emqx_connector_mongo.conf b/apps/emqx_connector/i18n/emqx_connector_mongo.conf index 1f00083a4..6a2511ec8 100644 --- a/apps/emqx_connector/i18n/emqx_connector_mongo.conf +++ b/apps/emqx_connector/i18n/emqx_connector_mongo.conf @@ -177,8 +177,8 @@ The MongoDB default port 27017 is used if `[:Port]` is not specified.""" heartbeat_period { desc { - en: "Controls when the driver checks the state of the MongoDB deployment. Specify the interval between checks, counted from the end of the previous check until the beginning of the next one." - zh: "控制驱动程序何时检查MongoDB部署的状态。指定检查的间隔时间,从上一次检查结束到下一次检查开始计算。" + en: "Controls when the driver checks the state of the MongoDB deployment. Specify the interval between checks, counted from the end of the previous check until the beginning of the next one. If the number of connections is increased (which will happen, for example, if you increase the pool size), you may need to increase this period as well to avoid creating too many log entries in the MongoDB log file." + zh: "控制驱动程序何时检查MongoDB部署的状态。指定检查的间隔时间,从上一次检查结束到下一次检查开始计算。如果连接数增加(例如,如果你增加池子的大小,就会发生这种情况),你可能也需要增加这个周期,以避免在MongoDB日志文件中创建太多的日志条目。" } label { en: "Heartbeat period" diff --git a/apps/emqx_connector/src/emqx_connector_mongo.erl b/apps/emqx_connector/src/emqx_connector_mongo.erl index 1b0bcf94d..8804ebaf2 100644 --- a/apps/emqx_connector/src/emqx_connector_mongo.erl +++ b/apps/emqx_connector/src/emqx_connector_mongo.erl @@ -106,7 +106,7 @@ fields(topology) -> {socket_timeout_ms, duration("socket_timeout")}, {server_selection_timeout_ms, duration("server_selection_timeout")}, {wait_queue_timeout_ms, duration("wait_queue_timeout")}, - {heartbeat_frequency_ms, duration("heartbeat_period")}, + {heartbeat_frequency_ms, fun heartbeat_frequency_ms/1}, {min_heartbeat_frequency_ms, duration("min_heartbeat_period")} ]. @@ -407,6 +407,12 @@ duration(Desc) -> desc => ?DESC(Desc) }. +heartbeat_frequency_ms(type) -> emqx_schema:duration_ms(); +heartbeat_frequency_ms(desc) -> ?DESC("heartbeat_period"); +heartbeat_frequency_ms(default) -> 200000; +heartbeat_frequency_ms(validator) -> [?MIN(1)]; +heartbeat_frequency_ms(_) -> undefined. + max_overflow(type) -> non_neg_integer(); max_overflow(desc) -> ?DESC("max_overflow"); max_overflow(default) -> 0; diff --git a/changes/ce/fix-10124.en.md b/changes/ce/fix-10124.en.md new file mode 100644 index 000000000..1a4aca3d9 --- /dev/null +++ b/changes/ce/fix-10124.en.md @@ -0,0 +1 @@ +The default heartbeat period for MongoDB has been increased to reduce the risk of too excessive logging to the MongoDB log file. diff --git a/changes/ce/fix-10124.zh.md b/changes/ce/fix-10124.zh.md new file mode 100644 index 000000000..7605f2da3 --- /dev/null +++ b/changes/ce/fix-10124.zh.md @@ -0,0 +1 @@ +增加了MongoDB的默认心跳周期,以减少对MongoDB日志文件的过多记录的风险。