Logger under load

Steve Strong steve@REDACTED
Fri Aug 7 10:27:59 CEST 2020


I think a child process to perform the synchronous logging would work fine - something like:

child(Server) ->
  receive
    {do_log, Ref, From, Msg} ->
      try
        Res = gen_server:call(Server, Msg),
        From ! {Ref, {completed, Res}}
      catch
        _:{timeout,_} -> 
          From ! {Ref, timeout}
      end;

    {Ref, ok} ->
      ok;

    {Ref, dropped} ->
      ok
  end,
  child(Server).

(I doubt that even compiles, but should give the idea!) - when logger_olp is in sync mode, instead of it doing the gen_server:call, it sends a do_log message to the child and then waits for the response, which it is guaranteed to get.  Any timeouts are caught in the child, and any resulting stray replies will also be getting sent to the child where they can be dropped

> On 7 Aug 2020, at 09:14, Łukasz Niemier <lukasz@REDACTED> wrote:
> 
>> In the event of a timeout, it is handling the exception dropping the log request.  And it’s when this occurs that there’s a problem - the gen_server call to the handler is obviously still in operation, even though the caller (logger, in this case) has timed out and moved on.  At some point it completes, and a message of {Ref, ok} or {Ref, dropped} gets returned to the caller.
> 
> I am working on the "public" version of logger_olp so I can check out that, but I do not think that much could be done there except of just handling and dropping the stray messages in the handling process itself as in one way or another there will be need to fetch the state of the process. So in the end, there always be some call that can timeout and will result in stray messages.
> 
> --
> 
> Łukasz Niemier
> lukasz@REDACTED
> 



More information about the erlang-questions mailing list