Hi,
I’ve been learning Elixir for about a month, and a week ago I’ve deployed my first app to a staging environment. Everything worked smoothly for a couple of days. But then the service started giving 500 responses, but to my surprise there were no new logs. I’ve restarted the app and it worked for a couple of days but then I’ve observed the same behavior.
This my Elixir and OTP versions:
Erlang/OTP 24 [erts-12.0.1] [source] [64-bit] [smp:64:64] [ds:64:64:10] [async-threads:1] [jit]
Elixir (1.12.0)
So upon investigation I found out that one of my GenServers has hanged. This is the current stacktrace of this hanged genserver:
iex(ingestor@almighty)3> Process.info(pid_commiter, :current_stacktrace)
{:current_stacktrace,
[
{:gen, :do_call, 4, [file: 'gen.erl', line: 214]},
{:gen_event, :rpc, 2, [file: 'gen_event.erl', line: 290]},
{Logger.Handler, :log, 2, [file: 'lib/logger/handler.ex', line: 101]},
{:logger_backend, :call_handlers, 3, [file: 'logger_backend.erl', line: 51]},
{Admiral.BucketCommiter, :commit, 1,
[file: 'lib/admiral/bucket_commiter.ex', line: 220]},
{Admiral.BucketCommiter, :handle_info, 2,
[file: 'lib/admiral/bucket_commiter.ex', line: 57]},
{:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 695]},
{:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 771]}
]}
'lib/admiral/bucket_commiter.ex', line: 220 is just a simple Logger.debug call,
And Logger process is always stucking on this line:
iex(ingestor@almighty)5> Process.info(Process.whereis(Logger), :current_stacktrace)
{:current_stacktrace,
[
{Logger.Backends.Console, :await_io, 1,
[file: 'lib/logger/backends/console.ex', line: 270]},
{Logger.Backends.Console, :handle_event, 2,
[file: 'lib/logger/backends/console.ex', line: 153]},
{:gen_event, :server_update, 4, [file: 'gen_event.erl', line: 627]},
{:gen_event, :server_notify, 4, [file: 'gen_event.erl', line: 609]},
{:gen_event, :server_notify, 4, [file: 'gen_event.erl', line: 611]},
{:gen_event, :handle_msg, 6, [file: 'gen_event.erl', line: 351]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}
]}
I’m new to Elixir and I can’t fully understand what’s going on, but it appears like there is some kind of problem with Logger.Backend.Console as it eventually stucks on await_io call.
This is my config for logger’s console backed
config :logger, :console,
format: {Admiral.LoggerFormatter, :format},
metadata: [:file, :function, :line],
sync_threshold: 1000,
discard_threshold: 1000
I’ve tried to play with sync_threshold and discard_threshold but the problems still occurs no matter what is set in thresholds.
I’m not able to reliably reproduce the issue, sometimes it takes couple of hours before my GenServer hangs, sometime it’s couple of days.
I’ll appreciate any help, and I can provide any further details.























