Skip to content

Commit f502453

Browse files
Merge pull request #1472 from rabbitmq/rabbitmq-server-1471
Temporarily raise log high water mark when node boots
2 parents dca0ff1 + b337013 commit f502453

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/rabbit.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ broker_start() ->
320320
ToBeLoaded = Plugins ++ ?APPS,
321321
start_apps(ToBeLoaded),
322322
maybe_sd_notify(),
323+
ok = rabbit_lager:broker_is_started(),
323324
ok = log_broker_started(rabbit_plugins:strictly_plugins(rabbit_plugins:active())).
324325

325326
%% Try to send systemd ready notification if it makes sense in the

src/rabbit_lager.erl

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
-include("rabbit_log.hrl").
2020

2121
%% API
22-
-export([start_logger/0, log_locations/0, fold_sinks/2]).
22+
-export([start_logger/0, log_locations/0, fold_sinks/2,
23+
broker_is_started/0]).
2324

2425
%% For test purposes
2526
-export([configure_lager/0]).
@@ -39,6 +40,21 @@ start_logger() ->
3940
end, ok),
4041
ensure_log_working().
4142

43+
broker_is_started() ->
44+
{ok, HwmCurrent} = application:get_env(lager, error_logger_hwm),
45+
{ok, HwmOrig} = application:get_env(lager, error_logger_hwm_original),
46+
case HwmOrig =:= HwmCurrent of
47+
false ->
48+
ok = application:set_env(lager, error_logger_hwm, HwmOrig),
49+
Handlers = gen_event:which_handlers(lager_event),
50+
lists:foreach(fun(Handler) ->
51+
lager:set_loghwm(Handler, HwmOrig)
52+
end, Handlers),
53+
ok;
54+
_ ->
55+
ok
56+
end.
57+
4258
log_locations() ->
4359
ensure_lager_configured(),
4460
DefaultHandlers = application:get_env(lager, handlers, []),
@@ -233,10 +249,14 @@ configure_lager() ->
233249

234250
case application:get_env(lager, error_logger_hwm) of
235251
undefined ->
236-
application:set_env(lager, error_logger_hwm, 100);
237-
{ok, Val} when is_integer(Val) andalso Val =< 100 ->
238-
application:set_env(lager, error_logger_hwm, 100);
239-
{ok, _Val} ->
252+
application:set_env(lager, error_logger_hwm, 1000),
253+
% NB: 50 is the default value in lager.app.src
254+
application:set_env(lager, error_logger_hwm_original, 50);
255+
{ok, Val} when is_integer(Val) andalso Val < 1000 ->
256+
application:set_env(lager, error_logger_hwm, 1000),
257+
application:set_env(lager, error_logger_hwm_original, Val);
258+
{ok, Val} ->
259+
application:set_env(lager, error_logger_hwm_original, Val),
240260
ok
241261
end,
242262
ok.

0 commit comments

Comments
 (0)