lager icon indicating copy to clipboard operation
lager copied to clipboard

Unbounded actors created for log when console is stuck

Open neeraj9 opened this issue 5 years ago • 3 comments

While using lager 06f676aad8ed823b7838a70288cd4d13b5a25ede one of the production cluster node started consuming a lot of memory. Upon detailed inspection, which is covered as part of my bug report https://bugs.erlang.org/browse/ERL-710 it was found that lager (https://github.com/erlang-lager/lager/blob/bf60290101306b3cc26544d0d181a5cff8931e82/include/lager.hrl#L137L156) spawns unbounded actors. This is an issue when gen_event:which_handlers(lager_event) is stuck, which happened in this particular case.

-define(INT_LOG(Level, Format, Args),
    Self = self(),
    %% do this in a spawn so we don't cause a deadlock calling gen_event:which_handlers
    %% from a gen_event handler
    spawn(fun() ->
            case catch(gen_event:which_handlers(lager_event)) of

Although the real issue is still under investigation (as part of https://bugs.erlang.org/browse/ERL-710), but it is better to protect against such issues by keeping spawn under control and bounded. There should be a mechanism to break the circuit when io write is stuck instead of allowing unbounded actors to be spawned for each log.

neeraj9 avatar Aug 21 '18 02:08 neeraj9

Yeah, that's fair. Usually I'd recommend disabling console logging in production because the console is generally a problematic device to work with because of exactly this issue.

Vagabond avatar Aug 21 '18 15:08 Vagabond

It's a fair point that lager ought to use a proxy process rather than a blind spawn in this situation.

jadeallenx avatar Dec 21 '18 22:12 jadeallenx

any improvment ? we aslo get this issue :(

dingdongnigetou avatar Jul 22 '22 14:07 dingdongnigetou