Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid logging unnecessary errors in async cleanup functions #11065

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 13 additions & 9 deletions apps/emqx/src/emqx_broker_helper.erl
Expand Up @@ -153,13 +153,17 @@ code_change(_OldVsn, State, _Extra) ->
%%--------------------------------------------------------------------

clean_down(SubPid) ->
case ets:lookup(?SUBMON, SubPid) of
[{_, SubId}] ->
true = ets:delete(?SUBMON, SubPid),
true =
(SubId =:= undefined) orelse
ets:delete_object(?SUBID, {SubId, SubPid}),
emqx_broker:subscriber_down(SubPid);
[] ->
ok
try
case ets:lookup(?SUBMON, SubPid) of
[{_, SubId}] ->
true = ets:delete(?SUBMON, SubPid),
true =
(SubId =:= undefined) orelse
ets:delete_object(?SUBID, {SubId, SubPid}),
emqx_broker:subscriber_down(SubPid);
[] ->
ok
end
catch
error:badarg -> ok
end.
6 changes: 5 additions & 1 deletion apps/emqx/src/emqx_cm.erl
Expand Up @@ -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() ->
Expand Down
6 changes: 5 additions & 1 deletion apps/emqx_gateway/src/emqx_gateway_cm.erl
Expand Up @@ -823,7 +823,11 @@ code_change(_OldVsn, State, _Extra) ->
do_unregister_channel_task(Items, GwName, CmTabs) ->
lists:foreach(
fun({ChanPid, ClientId}) ->
do_unregister_channel(GwName, {ClientId, ChanPid}, CmTabs)
try
do_unregister_channel(GwName, {ClientId, ChanPid}, CmTabs)
catch
error:badarg -> ok
end
end,
Items
).
Expand Down
1 change: 1 addition & 0 deletions changes/ce/fix-11065.en.md
@@ -0,0 +1 @@
Avoid logging irrelevant error messages during EMQX shutdown.