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
This commit is contained in:
Zaiming (Stone) Shi 2023-03-09 09:55:02 +01:00
parent a965649421
commit c72589b52c
1 changed files with 7 additions and 7 deletions

View File

@ -337,20 +337,20 @@ request_stepdown(Action, ConnMod, Pid) ->
Reply -> {ok, Reply} Reply -> {ok, Reply}
catch catch
_ : noproc -> % emqx_ws_connection: call _ : 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}; {error, noproc};
_ : {noproc, _} -> % emqx_connection: gen_server:call _ : {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}; {error, noproc};
_ : Reason = {shutdown, _} -> _ : 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}; {error, Reason};
_ : Reason = {{shutdown, _}, _} -> _ : 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}; {error, Reason};
_ : {timeout, {gen_server, call, _}} -> _ : {timeout, {gen_server, call, _}} ->
?tp(warning, "session_stepdown_request_timeout", ?tp(warning, "session_stepdown_request_timeout",
#{pid => Pid, #{stale_pid => Pid,
action => Action, action => Action,
stale_channel => stale_channel_info(Pid) stale_channel => stale_channel_info(Pid)
}), }),
@ -358,7 +358,7 @@ request_stepdown(Action, ConnMod, Pid) ->
{error, timeout}; {error, timeout};
_ : Error : St -> _ : Error : St ->
?tp(error, "session_stepdown_request_exception", ?tp(error, "session_stepdown_request_exception",
#{pid => Pid, #{stale_pid => Pid,
action => Action, action => Action,
reason => Error, reason => Error,
stacktrace => St, stacktrace => St,
@ -537,7 +537,7 @@ handle_cast(Msg, State) ->
{noreply, State}. {noreply, State}.
handle_info({'DOWN', _MRef, process, Pid, _Reason}, State = #{chan_pmon := PMon}) -> 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)], ChanPids = [Pid | emqx_misc:drain_down(?BATCH_SIZE)],
{Items, PMon1} = emqx_pmon:erase_all(ChanPids, PMon), {Items, PMon1} = emqx_pmon:erase_all(ChanPids, PMon),
lists:foreach(fun mark_channel_disconnected/1, ChanPids), lists:foreach(fun mark_channel_disconnected/1, ChanPids),