Application is encountering an error in prod environment during startup, leading to a crash. The error message suggests a problem with the initialization of the Oban
application. Oban is working fine in dev environment
Application myapp exited: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: Oban
** (EXIT) an exception was raised:
** (ArgumentError) expected :repo to implement Ecto.Repo, got: MyApp.Repo
(oban 2.17.1) lib/oban/config.ex:91: Oban.Config.new/1
(oban 2.17.1) lib/oban.ex:387: Oban.start_link/1
(stdlib 5.1.1) supervisor.erl:420: :supervisor.do_start_child_i/3
(stdlib 5.1.1) supervisor.erl:406: :supervisor.do_start_child/2
(stdlib 5.1.1) supervisor.erl:390: anonymous fn/3 in :supervisor.start_children/2
(stdlib 5.1.1) supervisor.erl:1258: :supervisor.children_map/4
(stdlib 5.1.1) supervisor.erl:350: :supervisor.init_children/2
(stdlib 5.1.1) gen_server.erl:962: :gen_server.init_it/2
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :myapp,
adapter: Ecto.Adapters.Postgres
end
On futher investigating we found out that Oban uses __info__(:attributes)
to check if repo implements Ecto.Repo behaviour and on prod when we ran MyApp.Repo.__info__(:attributes)
it return empty list causing above error.
Not sure why __info__(:attributes)
is returning empty list of attributes on prod environment. Any help here will be appreciated