aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2018-06-07 23:52:01 +0200
committerSiri Hansen <[email protected]>2018-06-11 15:01:41 +0200
commitd8a16e264fcdbe5b13643b81987e7afe0a633dd8 (patch)
tree9bb301903bf0b337b1ee5f00488e9857e6bfc299 /lib/kernel/src
parentc026109009942d7a877242f161860cc824223cf1 (diff)
downloadotp-d8a16e264fcdbe5b13643b81987e7afe0a633dd8.tar.gz
otp-d8a16e264fcdbe5b13643b81987e7afe0a633dd8.tar.bz2
otp-d8a16e264fcdbe5b13643b81987e7afe0a633dd8.zip
[logger] Change names of overload config parameters in build-in handlers
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/logger_disk_log_h.erl44
-rw-r--r--lib/kernel/src/logger_h_common.erl66
-rw-r--r--lib/kernel/src/logger_h_common.hrl30
-rw-r--r--lib/kernel/src/logger_std_h.erl44
4 files changed, 94 insertions, 90 deletions
diff --git a/lib/kernel/src/logger_disk_log_h.erl b/lib/kernel/src/logger_disk_log_h.erl
index c3d2204630..e4b583c269 100644
--- a/lib/kernel/src/logger_disk_log_h.erl
+++ b/lib/kernel/src/logger_disk_log_h.erl
@@ -131,10 +131,10 @@ adding_handler(#{id:=Name}=Config) ->
Error
end;
false ->
- #{toggle_sync_qlen := TSQL,
- drop_new_reqs_qlen := DNRQL,
- flush_reqs_qlen := FRQL} = HState,
- {error,{invalid_levels,{TSQL,DNRQL,FRQL}}}
+ #{sync_mode_qlen := SMQL,
+ drop_mode_qlen := DMQL,
+ flush_qlen := FQL} = HState,
+ {error,{invalid_levels,{SMQL,DMQL,FQL}}}
end;
Error ->
Error
@@ -347,9 +347,9 @@ handle_call(disk_log_sync, _From, State = #{id := Name}) ->
handle_call({change_config,_OldConfig,NewConfig}, _From,
State = #{filesync_repeat_interval := FSyncInt0}) ->
HConfig = maps:get(config, NewConfig, #{}),
- State1 = #{toggle_sync_qlen := TSQL,
- drop_new_reqs_qlen := DNRQL,
- flush_reqs_qlen := FRQL} = maps:merge(State, HConfig),
+ State1 = #{sync_mode_qlen := SMQL,
+ drop_mode_qlen := DMQL,
+ flush_qlen := FQL} = maps:merge(State, HConfig),
case logger_h_common:overload_levels_ok(State1) of
true ->
_ =
@@ -370,7 +370,7 @@ handle_call({change_config,_OldConfig,NewConfig}, _From,
end,
{reply, ok, State1};
false ->
- {reply, {error,{invalid_levels,{TSQL,DNRQL,FRQL}}}, State}
+ {reply, {error,{invalid_levels,{SMQL,DMQL,FQL}}}, State}
end;
handle_call(info, _From, State) ->
@@ -464,19 +464,19 @@ code_change(_OldVsn, State, _Extra) ->
%%%-----------------------------------------------------------------
%%%
get_init_state() ->
- #{toggle_sync_qlen => ?TOGGLE_SYNC_QLEN,
- drop_new_reqs_qlen => ?DROP_NEW_REQS_QLEN,
- flush_reqs_qlen => ?FLUSH_REQS_QLEN,
- enable_burst_limit => ?ENABLE_BURST_LIMIT,
- burst_limit_size => ?BURST_LIMIT_SIZE,
- burst_window_time => ?BURST_WINDOW_TIME,
- enable_kill_overloaded => ?ENABLE_KILL_OVERLOADED,
- handler_overloaded_qlen => ?HANDLER_OVERLOADED_QLEN,
- handler_overloaded_mem => ?HANDLER_OVERLOADED_MEM,
- handler_restart_after => ?HANDLER_RESTART_AFTER,
- dl_sync_int => ?CONTROLLER_SYNC_INTERVAL,
- filesync_ok_qlen => ?FILESYNC_OK_QLEN,
- filesync_repeat_interval => ?FILESYNC_REPEAT_INTERVAL}.
+ #{sync_mode_qlen => ?SYNC_MODE_QLEN,
+ drop_mode_qlen => ?DROP_MODE_QLEN,
+ flush_qlen => ?FLUSH_QLEN,
+ burst_limit_enable => ?BURST_LIMIT_ENABLE,
+ burst_limit_max_count => ?BURST_LIMIT_MAX_COUNT,
+ burst_limit_window_time => ?BURST_LIMIT_WINDOW_TIME,
+ overload_kill_enable => ?OVERLOAD_KILL_ENABLE,
+ overload_kill_qlen => ?OVERLOAD_KILL_QLEN,
+ overload_kill_mem_size => ?OVERLOAD_KILL_MEM_SIZE,
+ overload_kill_restart_after => ?OVERLOAD_KILL_RESTART_AFTER,
+ dl_sync_int => ?CONTROLLER_SYNC_INTERVAL,
+ filesync_ok_qlen => ?FILESYNC_OK_QLEN,
+ filesync_repeat_interval => ?FILESYNC_REPEAT_INTERVAL}.
%%%-----------------------------------------------------------------
%%% Add a disk_log handler to the logger.
@@ -499,7 +499,7 @@ get_init_state() ->
%%% Handler specific config should be provided with a sub map associated
%%% with a key named 'config', e.g:
%%%
-%%% Config = #{config => #{toggle_sync_qlen => 50}
+%%% Config = #{config => #{sync_mode_qlen => 50}
%%%
%%% The disk_log handler process is linked to logger_sup, which is
%%% part of the kernel application's supervision tree.
diff --git a/lib/kernel/src/logger_h_common.erl b/lib/kernel/src/logger_h_common.erl
index d2fcc7e115..b145043522 100644
--- a/lib/kernel/src/logger_h_common.erl
+++ b/lib/kernel/src/logger_h_common.erl
@@ -91,29 +91,33 @@ check_common_config({mode_tab,_Tid}) ->
valid;
check_common_config({handler_pid,Pid}) when is_pid(Pid) ->
valid;
-check_common_config({toggle_sync_qlen,N}) when is_integer(N) ->
+
+check_common_config({sync_mode_qlen,N}) when is_integer(N) ->
valid;
-check_common_config({drop_new_reqs_qlen,N}) when is_integer(N) ->
+check_common_config({drop_mode_qlen,N}) when is_integer(N) ->
valid;
-check_common_config({flush_reqs_qlen,N}) when is_integer(N) ->
+check_common_config({flush_qlen,N}) when is_integer(N) ->
valid;
-check_common_config({enable_burst_limit,Bool}) when Bool == true;
+
+check_common_config({burst_limit_enable,Bool}) when Bool == true;
Bool == false ->
valid;
-check_common_config({burst_limit_size,N}) when is_integer(N) ->
+check_common_config({burst_limit_max_count,N}) when is_integer(N) ->
valid;
-check_common_config({burst_window_time,N}) when is_integer(N) ->
+check_common_config({burst_limit_window_time,N}) when is_integer(N) ->
valid;
-check_common_config({enable_kill_overloaded,Bool}) when Bool == true;
- Bool == false ->
+
+check_common_config({overload_kill_enable,Bool}) when Bool == true;
+ Bool == false ->
valid;
-check_common_config({handler_overloaded_qlen,N}) when is_integer(N) ->
+check_common_config({overload_kill_qlen,N}) when is_integer(N) ->
valid;
-check_common_config({handler_overloaded_mem,N}) when is_integer(N) ->
+check_common_config({overload_kill_mem_size,N}) when is_integer(N) ->
valid;
-check_common_config({handler_restart_after,NorA}) when is_integer(NorA);
- NorA == never ->
+check_common_config({overload_kill_restart_after,NorA}) when is_integer(NorA);
+ NorA == never ->
valid;
+
check_common_config({filesync_repeat_interval,NorA}) when is_integer(NorA);
NorA == no_repeat ->
valid;
@@ -173,9 +177,9 @@ unset_restart_flag(Name, Module) ->
end.
check_load(State = #{id:=_Name, mode_tab := ModeTab, mode := Mode,
- toggle_sync_qlen := ToggleSyncQLen,
- drop_new_reqs_qlen := DropNewQLen,
- flush_reqs_qlen := FlushQLen}) ->
+ sync_mode_qlen := SyncModeQLen,
+ drop_mode_qlen := DropModeQLen,
+ flush_qlen := FlushQLen}) ->
{_,Mem} = process_info(self(), memory),
?observe(_Name,{max_mem,Mem}),
{_,QLen} = process_info(self(), message_queue_len),
@@ -191,13 +195,13 @@ check_load(State = #{id:=_Name, mode_tab := ModeTab, mode := Mode,
if
QLen >= FlushQLen ->
{flush, 0,1};
- QLen >= DropNewQLen ->
+ QLen >= DropModeQLen ->
%% Note that drop mode will force log events to
%% be dropped on the client side (never sent get to
%% the handler).
IncDrops = if Mode == drop -> 0; true -> 1 end,
{?change_mode(ModeTab, Mode, drop), IncDrops,0};
- QLen >= ToggleSyncQLen ->
+ QLen >= SyncModeQLen ->
{?change_mode(ModeTab, Mode, sync), 0,0};
true ->
{?change_mode(ModeTab, Mode, async), 0,0}
@@ -207,17 +211,17 @@ check_load(State = #{id:=_Name, mode_tab := ModeTab, mode := Mode,
?update_other(flushes,FLUSHES,_NewFlushes,
State1#{last_qlen => QLen})}.
-limit_burst(#{enable_burst_limit := false}) ->
+limit_burst(#{burst_limit_enable := false}) ->
{true,0,0};
limit_burst(#{burst_win_ts := BurstWinT0,
burst_msg_count := BurstMsgCount,
- burst_window_time := BurstWinTime,
- burst_limit_size := BurstLimitSz}) ->
- if (BurstMsgCount >= BurstLimitSz) ->
+ burst_limit_window_time := BurstLimitWinTime,
+ burst_limit_max_count := BurstLimitMaxCnt}) ->
+ if (BurstMsgCount >= BurstLimitMaxCnt) ->
%% the limit for allowed messages has been reached
BurstWinT1 = ?timestamp(),
case ?diff_time(BurstWinT1,BurstWinT0) of
- BurstCheckTime when BurstCheckTime < (BurstWinTime*1000) ->
+ BurstCheckTime when BurstCheckTime < (BurstLimitWinTime*1000) ->
%% we're still within the burst time frame
{false,BurstWinT0,BurstMsgCount};
_BurstCheckTime ->
@@ -230,11 +234,11 @@ limit_burst(#{burst_win_ts := BurstWinT0,
end.
kill_if_choked(Name, QLen, Mem, HandlerMod,
- State = #{enable_kill_overloaded := KillIfOL,
- handler_overloaded_qlen := HOLQLen,
- handler_overloaded_mem := HOLMem}) ->
+ State = #{overload_kill_enable := KillIfOL,
+ overload_kill_qlen := OLKillQLen,
+ overload_kill_mem_size := OLKillMem}) ->
if KillIfOL andalso
- ((QLen > HOLQLen) orelse (Mem > HOLMem)) ->
+ ((QLen > OLKillQLen) orelse (Mem > OLKillMem)) ->
HandlerMod:log_handler_info(Name,
"Handler ~p overloaded and stopping",
[Name], State),
@@ -274,7 +278,7 @@ cancel_timer(TRef) -> timer:cancel(TRef).
stop_or_restart(Name, {shutdown,Reason={overloaded,_Name,_QLen,_Mem}},
- #{handler_restart_after := RestartAfter}) ->
+ #{overload_kill_restart_after := RestartAfter}) ->
%% If we're terminating because of an overload situation (see
%% logger_h_common:kill_if_choked/4), we need to remove the handler
%% and set a restart timer. A separate process must perform this
@@ -322,10 +326,10 @@ stop_or_restart(_Name, _Reason, _State) ->
ok.
overload_levels_ok(HandlerConfig) ->
- TSQL = maps:get(toggle_sync_qlen, HandlerConfig, ?TOGGLE_SYNC_QLEN),
- DNRQL = maps:get(drop_new_reqs_qlen, HandlerConfig, ?DROP_NEW_REQS_QLEN),
- FRQL = maps:get(flush_reqs_qlen, HandlerConfig, ?FLUSH_REQS_QLEN),
- (DNRQL > 1) andalso (TSQL =< DNRQL) andalso (DNRQL =< FRQL).
+ SMQL = maps:get(sync_mode_qlen, HandlerConfig, ?SYNC_MODE_QLEN),
+ DMQL = maps:get(drop_mode_qlen, HandlerConfig, ?DROP_MODE_QLEN),
+ FQL = maps:get(flush_qlen, HandlerConfig, ?FLUSH_QLEN),
+ (DMQL > 1) andalso (SMQL =< DMQL) andalso (DMQL =< FQL).
error_notify(Term) ->
?internal_log(error, Term).
diff --git a/lib/kernel/src/logger_h_common.hrl b/lib/kernel/src/logger_h_common.hrl
index e4d3431468..ad80b51109 100644
--- a/lib/kernel/src/logger_h_common.hrl
+++ b/lib/kernel/src/logger_h_common.hrl
@@ -4,47 +4,47 @@
%%! *** NOTE ***
%%! It's important that:
-%%! TOGGLE_SYNC_QLEN < DROP_NEW_REQS_QLEN < FLUSH_REQS_QLEN
-%%! and that DROP_NEW_REQS_QLEN >= 2.
+%%! SYNC_MODE_QLEN =< DROP_MODE_QLEN =< FLUSH_QLEN
+%%! and that DROP_MODE_QLEN >= 2.
%%! Otherwise the handler could end up in drop mode with no new
%%! log requests to process. This would cause all future requests
%%! to be dropped (no switch to async mode would ever take place).
%% This specifies the message_queue_len value where the log
%% requests switch from asynchronous casts to synchronous calls.
--define(TOGGLE_SYNC_QLEN, 10).
+-define(SYNC_MODE_QLEN, 10).
%% Above this message_queue_len, log requests will be dropped,
%% i.e. no log requests get sent to the handler process.
--define(DROP_NEW_REQS_QLEN, 200).
+-define(DROP_MODE_QLEN, 200).
%% Above this message_queue_len, the handler process will flush
%% its mailbox and only leave this number of messages in it.
--define(FLUSH_REQS_QLEN, 1000).
+-define(FLUSH_QLEN, 1000).
%% Never flush more than this number of messages in one go,
%% or the handler will be unresponsive for seconds (keep this
%% number as large as possible or the mailbox could grow large).
-define(FLUSH_MAX_N, 5000).
-%% BURST_LIMIT is the max number of log requests allowed to be
-%% written within a BURST_WINDOW_TIME time frame.
--define(ENABLE_BURST_LIMIT, true).
--define(BURST_LIMIT_SIZE, 500).
--define(BURST_WINDOW_TIME, 1000).
+%% BURST_LIMIT_MAX_COUNT is the max number of log requests allowed
+%% to be written within a BURST_LIMIT_WINDOW_TIME time frame.
+-define(BURST_LIMIT_ENABLE, true).
+-define(BURST_LIMIT_MAX_COUNT, 500).
+-define(BURST_LIMIT_WINDOW_TIME, 1000).
%% This enables/disables the feature to automatically get the
%% handler terminated if it gets too loaded (and can't keep up).
--define(ENABLE_KILL_OVERLOADED, false).
+-define(OVERLOAD_KILL_ENABLE, false).
%% If the message_queue_len goes above this size even after
%% flushing has been performed, the handler is terminated.
--define(HANDLER_OVERLOADED_QLEN, 20000).
+-define(OVERLOAD_KILL_QLEN, 20000).
%% If the memory usage exceeds this level
--define(HANDLER_OVERLOADED_MEM, 3000000).
+-define(OVERLOAD_KILL_MEM_SIZE, 3000000).
%% This is the default time that the handler will wait before
%% restarting and accepting new requests. The value 'never'
%% disables restarts.
--define(HANDLER_RESTART_AFTER, 5000).
-%%-define(HANDLER_RESTART_AFTER, never).
+-define(OVERLOAD_KILL_RESTART_AFTER, 5000).
+%%-define(OVERLOAD_KILL_RESTART_AFTER, never).
%% The handler sends asynchronous write requests to the process
%% controlling the i/o device, but every once in this interval
diff --git a/lib/kernel/src/logger_std_h.erl b/lib/kernel/src/logger_std_h.erl
index 77b054a9b7..e087178211 100644
--- a/lib/kernel/src/logger_std_h.erl
+++ b/lib/kernel/src/logger_std_h.erl
@@ -132,10 +132,10 @@ adding_handler(#{id:=Name}=Config) ->
Error
end;
false ->
- #{toggle_sync_qlen := TSQL,
- drop_new_reqs_qlen := DNRQL,
- flush_reqs_qlen := FRQL} = HState,
- {error,{invalid_levels,{TSQL,DNRQL,FRQL}}}
+ #{sync_mode_qlen := SMQL,
+ drop_mode_qlen := DMQL,
+ flush_qlen := FQL} = HState,
+ {error,{invalid_levels,{SMQL,DMQL,FQL}}}
end;
Error ->
Error
@@ -360,10 +360,10 @@ handle_call({change_config,_OldConfig,NewConfig}, _From,
end,
{reply, ok, State1};
false ->
- #{toggle_sync_qlen := TSQL,
- drop_new_reqs_qlen := DNRQL,
- flush_reqs_qlen := FRQL} = State1,
- {reply, {error,{invalid_levels,{TSQL,DNRQL,FRQL}}}, State}
+ #{sync_mode_qlen := SMQL,
+ drop_mode_qlen := DMQL,
+ flush_qlen := FQL} = State1,
+ {reply, {error,{invalid_levels,{SMQL,DMQL,FQL}}}, State}
end;
handle_call(info, _From, State) ->
@@ -459,19 +459,19 @@ code_change(_OldVsn, State, _Extra) ->
%%%-----------------------------------------------------------------
%%%
get_init_state() ->
- #{toggle_sync_qlen => ?TOGGLE_SYNC_QLEN,
- drop_new_reqs_qlen => ?DROP_NEW_REQS_QLEN,
- flush_reqs_qlen => ?FLUSH_REQS_QLEN,
- enable_burst_limit => ?ENABLE_BURST_LIMIT,
- burst_limit_size => ?BURST_LIMIT_SIZE,
- burst_window_time => ?BURST_WINDOW_TIME,
- enable_kill_overloaded => ?ENABLE_KILL_OVERLOADED,
- handler_overloaded_qlen => ?HANDLER_OVERLOADED_QLEN,
- handler_overloaded_mem => ?HANDLER_OVERLOADED_MEM,
- handler_restart_after => ?HANDLER_RESTART_AFTER,
- file_ctrl_sync_int => ?CONTROLLER_SYNC_INTERVAL,
- filesync_ok_qlen => ?FILESYNC_OK_QLEN,
- filesync_repeat_interval => ?FILESYNC_REPEAT_INTERVAL}.
+ #{sync_mode_qlen => ?SYNC_MODE_QLEN,
+ drop_mode_qlen => ?DROP_MODE_QLEN,
+ flush_qlen => ?FLUSH_QLEN,
+ burst_limit_enable => ?BURST_LIMIT_ENABLE,
+ burst_limit_max_count => ?BURST_LIMIT_MAX_COUNT,
+ burst_limit_window_time => ?BURST_LIMIT_WINDOW_TIME,
+ overload_kill_enable => ?OVERLOAD_KILL_ENABLE,
+ overload_kill_qlen => ?OVERLOAD_KILL_QLEN,
+ overload_kill_mem_size => ?OVERLOAD_KILL_MEM_SIZE,
+ overload_kill_restart_after => ?OVERLOAD_KILL_RESTART_AFTER,
+ file_ctrl_sync_int => ?CONTROLLER_SYNC_INTERVAL,
+ filesync_ok_qlen => ?FILESYNC_OK_QLEN,
+ filesync_repeat_interval => ?FILESYNC_REPEAT_INTERVAL}.
%%%-----------------------------------------------------------------
%%% Add a standard handler to the logger.
@@ -482,7 +482,7 @@ get_init_state() ->
%%% Handler specific config should be provided with a sub map associated
%%% with a key named 'config', e.g:
%%%
-%%% Config = #{config => #{toggle_sync_qlen => 50}
+%%% Config = #{config => #{sync_mode_qlen => 50}
%%%
%%% The standard handler process is linked to logger_sup, which is
%%% part of the kernel application's supervision tree.