From 66662102113ab748385c08528f36f2e8d34e5caf Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Thu, 11 Mar 2021 14:50:18 +0800 Subject: [PATCH] fix(congestion): alarm and clear congestion too frequetly --- src/emqx_congestion.erl | 2 +- src/emqx_connection.erl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/emqx_congestion.erl b/src/emqx_congestion.erl index 36dc7ac9f..9ad5b8ee5 100644 --- a/src/emqx_congestion.erl +++ b/src/emqx_congestion.erl @@ -38,7 +38,7 @@ -define(ALARM_SENT(REASON), {alarm_sent, REASON}). -define(ALL_ALARM_REASONS, [port_busy, too_many_publish]). -define(CONFIRM_CLEAR(REASON), {alarm_confirm_clear, REASON}). --define(CONFIRM_CLEAR_INTERVAL, 10000). +-define(CONFIRM_CLEAR_INTERVAL, 60000). maybe_alarm_port_busy(Socket, Transport, Channel) -> maybe_alarm_port_busy(Socket, Transport, Channel, false). diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index 91088f027..2b28f327a 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -551,9 +551,9 @@ handle_timeout(_TRef, limit_timeout, State) -> handle_timeout(_TRef, emit_stats, State = #state{active_n = MaxBatchSize, channel = Channel, transport = Transport, socket = Socket}) -> {_, MsgQLen} = erlang:process_info(self(), message_queue_len), - emqx_congestion:maybe_alarm_port_busy(Socket, Transport, Channel, true), + emqx_congestion:maybe_alarm_port_busy(Socket, Transport, Channel), emqx_congestion:maybe_alarm_too_many_publish(Socket, Transport, Channel, - MsgQLen, MaxBatchSize, true), + MsgQLen, MaxBatchSize), ClientId = emqx_channel:info(clientid, Channel), emqx_cm:set_chan_stats(ClientId, stats(State)), {ok, State#state{stats_timer = undefined}};