diff options
author | Siri Hansen <[email protected]> | 2018-09-14 14:12:13 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2018-09-14 14:12:13 +0200 |
commit | 6073d37a5a0691704d0fa1a5ff9289ba9e35c8ed (patch) | |
tree | 4c6b91691981f5713904638974635dfe181eb7a1 /lib/kernel/src/logger_h_common.erl | |
parent | 48a1c458a46dcd1f031fd3b9689af80b32b4a6a2 (diff) | |
download | otp-6073d37a5a0691704d0fa1a5ff9289ba9e35c8ed.tar.gz otp-6073d37a5a0691704d0fa1a5ff9289ba9e35c8ed.tar.bz2 otp-6073d37a5a0691704d0fa1a5ff9289ba9e35c8ed.zip |
[logger] Read config before terminating handler process
When a handler process is terminated due to overload, it reads its
configuration from the configuration database, so it can be restarted
with the same configuration after a small delay. This was earlier done
in a different process, which was spawned off from the terminate
function. This caused a race condition, where in some cases, the
configuration was already removed before it could be read.
The reason for spawning off a process, is to avoid a deadlock due to
the call to logger:remove_handler/1.
This commit moves the call to logger:get_handler_config/1 back to the
handler process - to ensure that the data is still there, but keeps
the call to logger:remove_handler/1 in the spawned off process - to
avoid deadlock.
Diffstat (limited to 'lib/kernel/src/logger_h_common.erl')
-rw-r--r-- | lib/kernel/src/logger_h_common.erl | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/kernel/src/logger_h_common.erl b/lib/kernel/src/logger_h_common.erl index 2818a460f1..38ac7d8ffc 100644 --- a/lib/kernel/src/logger_h_common.erl +++ b/lib/kernel/src/logger_h_common.erl @@ -294,6 +294,7 @@ stop_or_restart(Name, {shutdown,Reason={overloaded,_Name,_QLen,_Mem}}, %% and set a restart timer. A separate process must perform this %% in order to avoid deadlock. HandlerPid = self(), + ConfigResult = logger:get_handler_config(Name), RemoveAndRestart = fun() -> MRef = erlang:monitor(process, HandlerPid), @@ -304,7 +305,7 @@ stop_or_restart(Name, {shutdown,Reason={overloaded,_Name,_QLen,_Mem}}, error_notify(Reason), exit(HandlerPid, kill) end, - case logger:get_handler_config(Name) of + case ConfigResult of {ok,#{module:=HMod}=HConfig} when is_integer(RestartAfter) -> _ = logger:remove_handler(Name), _ = timer:apply_after(RestartAfter, logger, add_handler, |