Papillon6814

Papillon6814

Hello.

I cannot run mix test due to this error.

18:22:11.758 [error] GenServer {Oban.Registry, {Oban, {:plugin, Oban.Plugins.Stager}}} terminating
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.1432.0>.

When using ownership, you must manage connections in one
of the four ways:

* By explicitly checking out a connection
* By explicitly allowing a spawned process
* By running the pool in shared mode
* By using :caller option with allowed process

The first two options require every new process to explicitly
check a connection out or be allowed by calling checkout or
allow respectively.

The third option requires a {:shared, pid} mode to be set.
If using shared mode in tests, make sure your tests are not
async.

The fourth option requires [caller: pid] to be used when
checking out a connection from the pool. The caller process
should already be allowed on a connection.

If you are reading this error, it means you have not done one
of the steps above or that the owner process has crashed.

    (db_connection 2.4.0) lib/db_connection.ex:883: DBConnection.transaction/3
    (oban 2.7.2) lib/oban/plugins/stager.ex:83: anonymous fn/2 in Oban.Plugins.Stager.handle_info/2
    (telemetry 0.4.3) /Users/useeer/Documents/github/xxx/deps/telemetry/src/telemetry.erl:272: :telemetry.span/3
    (oban 2.7.2) lib/oban/plugins/stager.ex:82: Oban.Plugins.Stager.handle_info/2
    (stdlib 3.15.1) gen_server.erl:695: :gen_server.try_dispatch/4
    (stdlib 3.15.1) gen_server.erl:771: :gen_server.handle_msg/6
    (stdlib 3.15.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: :stage

I added oban in the project, and the error occurs with oban.

config.exs

config :proj, Oban,
  repo: Proj.Repo,
  plugins: [
    Oban.Plugins.Pruner,
    {Oban.Plugins.Cron,
      crontab: [
        # {"work", ProjWeb._Worker}
      ]}
  ],
  queues: [default: 10, event: 50]

application.ex

    children = [
      ...
      {Oban, oban_config()}
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: Proj.Supervisor]
    Supervisor.start_link(children, opts)

I don’t know where to check to solve the error.

Showing Posts 1 to 10

Papillon6814

Papillon6814 OP

And I have added this script in test.exs

config :proj, Oban, queues: false, plugins: false
sorentwo

sorentwo

Oban Core Team

The error you’re getting is definitely because plugins are running during tests.

It looks like you found the queues: false, plugins: false config, which is the proper fix. Maybe double check that everything is saved and that there aren’t any typos?

amnu3387

amnu3387

Also check (if and how) you’re using the standard DataCase, if you’re not using any other use that might try to setup the ecto sandbox, async tags that can conflict, and if you’re using any setup_all that might require explicit checkouts - from the top of my head.

Papillon6814

Papillon6814 OP

Thank you for answering me!

Papillon6814

Papillon6814 OP

Thank you, I have changed mode of the sandbox. then my tests work!

21:41:34.246 [error] GenServer {Oban.Registry, {Oban, {:plugin, Oban.Plugins.Pruner}}} terminating
** (DBConnection.ConnectionError) could not checkout the connection owned by #PID<0.1174.0>. When using the sandbox, connections are shared, so this may imply another process is using a connection. Reason: connection not available and request was dropped from queue after 104ms. You can configure how long requests wait in the queue using :queue_target and :queue_interval. See DBConnection.start_link/2 for more information
    (db_connection 2.4.0) lib/db_connection.ex:883: DBConnection.transaction/3
    (oban 2.7.2) lib/oban/plugins/pruner.ex:90: anonymous fn/2 in Oban.Plugins.Pruner.handle_info/2
    (telemetry 0.4.3) /Users/papillon/Documents/GitHub/Milk_DBServer/milk/deps/telemetry/src/telemetry.erl:272: :telemetry.span/3
    (oban 2.7.2) lib/oban/plugins/pruner.ex:89: Oban.Plugins.Pruner.handle_info/2
    (stdlib 3.15.1) gen_server.erl:695: :gen_server.try_dispatch/4
    (stdlib 3.15.1) gen_server.erl:771: :gen_server.handle_msg/6
    (stdlib 3.15.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: :prune

Although the tests work, this error still appears in the terminal. do you have any ideas of fixing it?

sorentwo

sorentwo

Oban Core Team

There shouldn’t be any errors. Try putting this in one of your tests (any test):

IO.inspect(Oban.config())

You should see plugins: [] and queues: [] in there. If not, then your test config isn’t loading.

Papillon6814

Papillon6814 OP

OK, I’ll check it out!

pzingg

pzingg

I am having the same problem, just realized after two or three hours of head scratching. I think there are two approaches, but I don’t have the Elixir skills to do the first one:

  1. In the test environment, how do you checkout an Ecto connection NOT in Sandbox mode?

or

  1. Is there someway to just manually call Oban.Notifier after an insert to stimulate the producer to start executing available jobs?

I can’t find concrete examples of either one.

pzingg

pzingg

I was able to get things to work by adding the Oban.Plugins.Repeater plugin in the test Oban config. That was the only plugin I added to the config.

sorentwo

sorentwo

Oban Core Team

The way I recommend running Oban for tests is to have queues and plugins disabled entirely. When you need to check that something is enqueued you use the Testing helpers, and when you need to execute jobs you use drain_queue.

The goal is to keep async work predictable, and to avoid cross-process connection checkouts/sandbox issues.

In this case that means you would remove the repeater plugin and drain from within your test process.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
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
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
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
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
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews