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.
This commit is contained in:
Zaiming Shi 2021-03-29 10:57:37 +02:00 committed by Zaiming (Stone) Shi
parent 2e30d7803f
commit 66693d6846
1 changed files with 5 additions and 3 deletions

View File

@ -684,9 +684,11 @@ check_oom(State = #state{channel = Channel}) ->
Zone = emqx_channel:info(zone, Channel), Zone = emqx_channel:info(zone, Channel),
OomPolicy = emqx_zone:oom_policy(Zone), OomPolicy = emqx_zone:oom_policy(Zone),
case ?ENABLED(OomPolicy) andalso emqx_misc:check_oom(OomPolicy) of case ?ENABLED(OomPolicy) andalso emqx_misc:check_oom(OomPolicy) of
Shutdown = {shutdown, _Reason} -> {shutdown, Reason} ->
erlang:send(self(), Shutdown); %% triggers terminate/2 callback immediately
_Other -> ok erlang:exit({shutdown, Reason});
_Other ->
ok
end, end,
State. State.