axelclark

axelclark

I’m running a Phoenix app on Fly. I have a GenServer I’m starting as a child in my Application.start/2 function under my MyApp.Supervisor.

I had it crash within the GenServer.init/1 function when the app was starting for a deploy. In the logs there was:

{exit,terminating,[{application_controller,call,2,[{file,"application_controller.erl"},{line,511}]},{application,enqueue_or_start,6,[{file,"application.erl"},{line,380}]},{application,ensure_all_started,3,[{file,"application.erl"},{line,359}]},{elixir,start_cli,0,[{file,"src/elixir.erl"},{line,195}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}
Runtime terminating during boot (terminating)

However, the cause of the crash was not in the logs. When I tested it more, if I try to log in GenServer.init/1 during a successful start with Logger.error("Test log") it also doesn’t end up in the production logs.

The crash and logs show up when I try all these scenarios in dev using either mix or a release.

I found How do I get Phoenix or Elixir to print more detailed logs on a crash? and added:

config :logger, 
   handle_otp_reports: true, 
   handle_sasl_reports: true,
   ...

That gave me more information about the supervisor starting its children, but I still didn’t get any logs from the GenServer init function in production.

My config/prod.exs is:

config :logger,
  level: :info,
  backends: [:console, {Appsignal.Logger.Backend, [group: "phoenix"]}],
  handle_otp_reports: true,
  handle_sasl_reports: true

my config/config.exs is:

config :logger, :console,
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id]

Any idea why I’m not getting these logs in production (either AppSignal or the console)?

Showing Posts 1 to 7

martosaur

martosaur

Don’t bother with handle_sasl_reports option, it will enable an additional error-level message, but the one you’re interested in is notice-level. This is what I see if I run your case in an empty application in a release locally:

{exit,terminating,[{application_controller,call,2,[{file,"application_controller.erl"},{line,511}]},{application,enqueue_or_start,6,[{file,"application.erl"},{line,380}]},{application,ensure_all_started,3,[{file,"application.erl"},{line,359}]},{elixir,start_cli,0,[{file,"src/elixir.erl"},{line,195}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}

18:14:35.635 [notice] Application log_app exited: LogApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: :foo
    ** (EXIT) an exception was raised:
        ** (RuntimeError) Oops
            (log_app 0.1.0) lib/log_app/application.ex:7: MyServer.init/1
            (stdlib 6.2.1) gen_server.erl:2229: :gen_server.init_it/2
            (stdlib 6.2.1) gen_server.erl:2184: :gen_server.init_it/6
            (stdlib 6.2.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Kernel pid terminated (application_controller) ("{application_start_failure,log_app,{{shutdown,{failed_to_start_child,foo,{#{message => <<\"Oops\">>,'__struct__' => 'Elixir.RuntimeError','__exception__' => true},[{'Elixir.MyServer',init,1,[{file,\"lib/log_app/application.ex\"},{line,7},{error_info,#{module => 'Elixir.Exception'}}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,2229}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,2184}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,329}]}]}}},{'Elixir.LogApp.Application',start,[normal,[]]}}}")

Which version of Elixir & OTP are you on?

I would try to run the app release locally and/or without appsignal backend as the next step.

kif

kif

There is also this No stack trace in production log - #20 by markmark206 that might be relevant.

axelclark

axelclark OP

Thanks for reproducing this! Here are my versions:

elixir          1.17.3-otp-27 
erlang          27.1.2 

I also thought that maybe the log level was the issue, but I can add Logger.error("Test log") in the GenServer.init/1 and I don’t see that in prod either. I tried it locally with both mix and as a release and the logs are all there in the terminal.

hauleth

hauleth

Are you sure that your Logger line is even called?

axelclark

axelclark OP

It gets called when I run a release locally, but I guess I’m not 100% sure if it gets called in production.

martosaur

martosaur

Alright, I think you’ve encountered this bug that was fixed in Erlang 27.2.1 Missing error logs when application crashes on OTP-26 · Issue #9163 · erlang/otp · GitHub

axelclark

axelclark OP

Amazing! Thank you!

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews