fix: avoid logging unnecessary errors in async cleanup functions
Cleanup functions that access ETS tables may fail with `badarg` error during EMQX shutdown. They are called asynchronously by `emqx_pool` workers and accessed ETS tables may be already destroyed as their owners are shut down. This fix catches ETS `badarg` errors before they can be caught and logged by `emqx_pool`. Fixes: EMQX-9992
This commit is contained in:
parent
0dff428efb
commit
950d5edc41
|
@ -153,6 +153,7 @@ code_change(_OldVsn, State, _Extra) ->
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
clean_down(SubPid) ->
|
||||
try
|
||||
case ets:lookup(?SUBMON, SubPid) of
|
||||
[{_, SubId}] ->
|
||||
true = ets:delete(?SUBMON, SubPid),
|
||||
|
@ -162,4 +163,7 @@ clean_down(SubPid) ->
|
|||
emqx_broker:subscriber_down(SubPid);
|
||||
[] ->
|
||||
ok
|
||||
end
|
||||
catch
|
||||
error:badarg -> ok
|
||||
end.
|
||||
|
|
|
@ -734,7 +734,11 @@ code_change(_OldVsn, State, _Extra) ->
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
clean_down({ChanPid, ClientId}) ->
|
||||
do_unregister_channel({ClientId, ChanPid}),
|
||||
try
|
||||
do_unregister_channel({ClientId, ChanPid})
|
||||
catch
|
||||
error:badarg -> ok
|
||||
end,
|
||||
ok = ?tp(debug, emqx_cm_clean_down, #{client_id => ClientId}).
|
||||
|
||||
stats_fun() ->
|
||||
|
|
|
@ -823,7 +823,11 @@ code_change(_OldVsn, State, _Extra) ->
|
|||
do_unregister_channel_task(Items, GwName, CmTabs) ->
|
||||
lists:foreach(
|
||||
fun({ChanPid, ClientId}) ->
|
||||
try
|
||||
do_unregister_channel(GwName, {ClientId, ChanPid}, CmTabs)
|
||||
catch
|
||||
error:badarg -> ok
|
||||
end
|
||||
end,
|
||||
Items
|
||||
).
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Avoid logging irrelevant error messages during EMQX shutdown.
|
Loading…
Reference in New Issue