Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBConnection error when running test with :manual mode for sandbox #58

Open
zacksiri opened this issue Nov 16, 2019 · 2 comments
Open

Comments

@zacksiri
Copy link

I have an application using EctoJob and it seems I'm getting errors when I'm using the manual sandbox mode.

This is very strange

because I have the same setup in another app and this is not happening.

I can't seem to find what's wrong

See Ecto.Adapters.SQL.Sandbox docs for more information.
    (ecto_sql) lib/ecto/adapters/sql.ex:626: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql) lib/ecto/adapters/sql.ex:562: Ecto.Adapters.SQL.execute/5
    (ecto) lib/ecto/repo/queryable.ex:177: Ecto.Repo.Queryable.execute/4
    (ecto_job) lib/ecto_job/producer.ex:184: EctoJob.Producer.dispatch_jobs/2
    (gen_stage) lib/gen_stage.ex:2103: GenStage.noreply_callback/3
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_producer", {#PID<0.427.0>, #Reference<0.3185423543.3099852806.167003>}, {:ask, 100}}
12:02:12.163 [error] GenServer #PID<0.427.0> terminating
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.426.0>.

test_helper.exs

ExUnit.start()

Ecto.Adapters.SQL.Sandbox.mode(Dispatch.Repo, :manual)

If I comment out the last line everything works.

@strzibny
Copy link

strzibny commented Dec 19, 2019

Same here, I can have one job queue in application.ex to start, but once I have two, or another process accessing the DB I got this error. For me this happens when running MIX_ENV=test mix ecto.reset, tests actually work.

@mbuhot
Copy link
Owner

mbuhot commented Sep 16, 2020

I'm guessing this is caused by EctoJob accessing the Repo before your test_helper.exs file gets a chance to put the DB in sandbox mode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants