From c72589b52c123acb294cde834a26cc78e019f6d5 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Thu, 9 Mar 2023 09:55:02 +0100 Subject: [PATCH] fix(emqx_cm): avoid using 'pid' as log keyword 'pid' is a logging metadata for the log issuer process, if 'pid' is used as a structured log field, it will be overwritten by the logging handler module --- src/emqx_cm.erl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/emqx_cm.erl b/src/emqx_cm.erl index 981fe49f8..dc9aa6c3e 100644 --- a/src/emqx_cm.erl +++ b/src/emqx_cm.erl @@ -337,20 +337,20 @@ request_stepdown(Action, ConnMod, Pid) -> Reply -> {ok, Reply} catch _ : noproc -> % emqx_ws_connection: call - ok = ?tp(debug, "session_already_gone", #{pid => Pid, action => Action}), + ok = ?tp(debug, "session_already_gone", #{stale_pid => Pid, action => Action}), {error, noproc}; _ : {noproc, _} -> % emqx_connection: gen_server:call - ok = ?tp(debug, "session_already_gone", #{pid => Pid, action => Action}), + ok = ?tp(debug, "session_already_gone", #{stale_pid => Pid, action => Action}), {error, noproc}; _ : Reason = {shutdown, _} -> - ok = ?tp(debug, "session_already_shutdown", #{pid => Pid, action => Action}), + ok = ?tp(debug, "session_already_shutdown", #{stale_pid => Pid, action => Action}), {error, Reason}; _ : Reason = {{shutdown, _}, _} -> - ok = ?tp(debug, "session_already_shutdown", #{pid => Pid, action => Action}), + ok = ?tp(debug, "session_already_shutdown", #{stale_pid => Pid, action => Action}), {error, Reason}; _ : {timeout, {gen_server, call, _}} -> ?tp(warning, "session_stepdown_request_timeout", - #{pid => Pid, + #{stale_pid => Pid, action => Action, stale_channel => stale_channel_info(Pid) }), @@ -358,7 +358,7 @@ request_stepdown(Action, ConnMod, Pid) -> {error, timeout}; _ : Error : St -> ?tp(error, "session_stepdown_request_exception", - #{pid => Pid, + #{stale_pid => Pid, action => Action, reason => Error, stacktrace => St, @@ -537,7 +537,7 @@ handle_cast(Msg, State) -> {noreply, State}. handle_info({'DOWN', _MRef, process, Pid, _Reason}, State = #{chan_pmon := PMon}) -> - ?tp(emqx_cm_process_down, #{pid => Pid, reason => _Reason}), + ?tp(emqx_cm_process_down, #{down_pid => Pid, reason => _Reason}), ChanPids = [Pid | emqx_misc:drain_down(?BATCH_SIZE)], {Items, PMon1} = emqx_pmon:erase_all(ChanPids, PMon), lists:foreach(fun mark_channel_disconnected/1, ChanPids),