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,13 +153,17 @@ code_change(_OldVsn, State, _Extra) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
clean_down(SubPid) -> clean_down(SubPid) ->
case ets:lookup(?SUBMON, SubPid) of try
[{_, SubId}] -> case ets:lookup(?SUBMON, SubPid) of
true = ets:delete(?SUBMON, SubPid), [{_, SubId}] ->
true = true = ets:delete(?SUBMON, SubPid),
(SubId =:= undefined) orelse true =
ets:delete_object(?SUBID, {SubId, SubPid}), (SubId =:= undefined) orelse
emqx_broker:subscriber_down(SubPid); ets:delete_object(?SUBID, {SubId, 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}) ->
do_unregister_channel(GwName, {ClientId, ChanPid}, CmTabs) try
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.