From 66693d68462a389a692d1f14a8f31ba071ffbe3c Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 29 Mar 2021 10:57:37 +0200 Subject: [PATCH] fix(emqx_connection): connection OOM kill immediately Prior to this change, connection process' OOM kill is a loopback message, which results in a delayed kill when message queue length is large. In this change, the loopback message is changed to an exit signal. --- src/emqx_connection.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index 88a1ba4d7..28ea67bf8 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -684,9 +684,11 @@ check_oom(State = #state{channel = Channel}) -> Zone = emqx_channel:info(zone, Channel), OomPolicy = emqx_zone:oom_policy(Zone), case ?ENABLED(OomPolicy) andalso emqx_misc:check_oom(OomPolicy) of - Shutdown = {shutdown, _Reason} -> - erlang:send(self(), Shutdown); - _Other -> ok + {shutdown, Reason} -> + %% triggers terminate/2 callback immediately + erlang:exit({shutdown, Reason}); + _Other -> + ok end, State.