DBConnection.OwnershipError in CI/CD pipeline but not locally

Hello all,

I have a project that uses two repos and I have them both initialized in the children processes of my application.ex module.

When I run my tests locally, they work perfectly, but now in the CI/CD pipeline for some reason they are giving me an DBConnection.OwnershipError. I have done some research and tried a bunch of differente configurations and debugging but I can’t seem to find the cause of this. Other projects that have the exactly same configuration don’t have any problem in the pipeline, so I’m imaging that using two repos might be the problem.

This is my setup for testing:

setup tags do

  def setup_sandbox(tags) do
    pid_funds_manager = Sandbox.start_owner!(FundsManagerRepo, shared: not tags[:async])
    pid_cards = Sandbox.start_owner!(CardsRepo, shared: not tags[:async])

    on_exit(fn -> Sandbox.stop_owner(pid_funds_manager) end)
    on_exit(fn -> Sandbox.stop_owner(pid_cards) end)

And this is the error I’m getting:

(db_connection 2.4.2) lib/db_connection.ex:904: DBConnection.transaction/3 (oban 2.13.6) lib/oban/plugins/stager.ex:106: anonymous fn/2 in Oban.Plugins.Stager.handle_info/2 (telemetry 1.1.0) /builds/swappers/engineering/cards/funds-manager/deps/telemetry/src/telemetry.erl:320: :telemetry.span/3 (oban 2.13.6) lib/oban/plugins/stager.ex:105: Oban.Plugins.Stager.handle_info/2 (stdlib gen_server.erl:695: :gen_server.try_dispatch/4 (stdlib gen_server.erl:771: :gen_server.handle_msg/6 (stdlib proc_lib.erl:226: :proc_lib.init_p_do_apply/3 Last message: :stage .........17:09:42.378 line=949 mfa=:gen_server.error_info/7 [error] GenServer {Oban.Registry, {Oban, {:plugin, Oban.Plugins.Stager}}} terminating ** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.12604.0>.

** (RuntimeError) could not lookup Ecto repo FundsManager.CardsRepo because it was not started or it does not exist ``

Does anyone have any idea what I’m missing?

Thanks! :smiley:

In the config/test.exs
Configure Oban with

config :funds_manager, Oban, testing: :manual
1 Like