From 97e27faf05a2c24a6115e0c06f5f592b9d1a8f28 Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Tue, 18 May 2021 10:34:23 +0800 Subject: [PATCH] fix(emqx): check if the congestion alarm was sent before clearing (#4824) --- src/emqx.appup.src | 4 ++++ src/emqx_congestion.erl | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/emqx.appup.src b/src/emqx.appup.src index 937f31eff..7e21ef4ed 100644 --- a/src/emqx.appup.src +++ b/src/emqx.appup.src @@ -2,10 +2,12 @@ {VSN, [ {"4.3.1", [ + {load_module, emqx_congestion, brutal_purge, soft_purge, []}, {load_module, emqx_node_dump, brutal_purge, soft_purge, []} ]}, {"4.3.0", [ {load_module, emqx_logger_jsonfmt, brutal_purge, soft_purge, []}, + {load_module, emqx_congestion, brutal_purge, soft_purge, []}, {load_module, emqx_connection, brutal_purge, soft_purge, []}, {load_module, emqx_frame, brutal_purge, soft_purge, []}, {load_module, emqx_trie, brutal_purge, soft_purge, []}, @@ -16,11 +18,13 @@ ], [ {"4.3.1", [ + {load_module, emqx_congestion, brutal_purge, soft_purge, []}, {load_module, emqx_node_dump, brutal_purge, soft_purge, []} ]}, {"4.3.0", [ {load_module, emqx_logger_jsonfmt, brutal_purge, soft_purge, []}, {load_module, emqx_connection, brutal_purge, soft_purge, []}, + {load_module, emqx_congestion, brutal_purge, soft_purge, []}, {load_module, emqx_frame, brutal_purge, soft_purge, []}, {load_module, emqx_trie, brutal_purge, soft_purge, []}, %% Just load the module. We don't need to change the 'messages.retained' diff --git a/src/emqx_congestion.erl b/src/emqx_congestion.erl index ea99a63b1..4ec20034d 100644 --- a/src/emqx_congestion.erl +++ b/src/emqx_congestion.erl @@ -48,7 +48,10 @@ maybe_alarm_conn_congestion(Socket, Transport, Channel) -> cancel_alarms(Socket, Transport, Channel) -> lists:foreach(fun(Reason) -> - do_cancel_alarm_congestion(Socket, Transport, Channel, Reason) + case has_alarm_sent(Reason) of + true -> do_cancel_alarm_congestion(Socket, Transport, Channel, Reason); + false -> ok + end end, ?ALL_ALARM_REASONS). is_alarm_enabled(Channel) ->