Merge pull request #11065 from SergeTupchiy/EMQX-9992-fix-async-cleanup-error-logs

fix: avoid logging unnecessary errors in async cleanup functions
This commit is contained in:
SergeTupchiy 2023-07-20 12:20:57 +03:00 committed by GitHub
commit 8480a26b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 11 deletions

View File

@ -153,6 +153,7 @@ code_change(_OldVsn, State, _Extra) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
clean_down(SubPid) -> clean_down(SubPid) ->
try
case ets:lookup(?SUBMON, SubPid) of case ets:lookup(?SUBMON, SubPid) of
[{_, SubId}] -> [{_, SubId}] ->
true = ets:delete(?SUBMON, SubPid), true = ets:delete(?SUBMON, SubPid),
@ -162,4 +163,7 @@ clean_down(SubPid) ->
emqx_broker:subscriber_down(SubPid); emqx_broker:subscriber_down(SubPid);
[] -> [] ->
ok ok
end
catch
error:badarg -> ok
end. end.

View File

@ -706,7 +706,11 @@ code_change(_OldVsn, State, _Extra) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
clean_down({ChanPid, ClientId}) -> 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}). ok = ?tp(debug, emqx_cm_clean_down, #{client_id => ClientId}).
stats_fun() -> stats_fun() ->

View File

@ -823,7 +823,11 @@ code_change(_OldVsn, State, _Extra) ->
do_unregister_channel_task(Items, GwName, CmTabs) -> do_unregister_channel_task(Items, GwName, CmTabs) ->
lists:foreach( lists:foreach(
fun({ChanPid, ClientId}) -> fun({ChanPid, ClientId}) ->
try
do_unregister_channel(GwName, {ClientId, ChanPid}, CmTabs) do_unregister_channel(GwName, {ClientId, ChanPid}, CmTabs)
catch
error:badarg -> ok
end
end, end,
Items Items
). ).

View File

@ -0,0 +1 @@
Avoid logging irrelevant error messages during EMQX shutdown.