oban-bg/oban

Oban bringing app down on Prod with error (expected :repo to implement Ecto.Repo, got: MyApp.Repo)

Closed this issue · 2 comments

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

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

Environment

  • Oban Version: 2.17.1
  • PostgreSQL Version: 15.5
  • Elixir & Erlang/OTP Versions (elixir --version): Elixir 1.15.7 & Erlang/OTP 26

As noted in the linked discussion, this was due to how nix built production releases and not from anything in Oban itself.