Ecto: Amend ownership error with pointer to Ecto.Adapters.SQL.Sandbox

Created on 2 Jun 2016  路  3Comments  路  Source: elixir-ecto/ecto

** (EXIT from #PID<0.421.0>) an exception was raised:
         ** (RuntimeError) cannot find ownership process for #PID<0.534.0>.

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

       * By explicitly checking out a connection
       * By explicitly allowing a spawned process
       * By running the pool in shared mode

     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.

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

DbConnection raises a great error that explains the issue and possible solutions to it. But there's no pointer to the code I should use to fix it. We should capture the error in the SQL adapter and a pointer to Ecto.Adapters.SQL.Sandbox.

Enhancement

Most helpful comment

In a Phoenix app, this error happens if you try to run ecto queries in a test module with use ExUnit.Case instead of the appropriate use <YourApp>.ModelCase

All 3 comments

In a Phoenix app, this error happens if you try to run ecto queries in a test module with use ExUnit.Case instead of the appropriate use <YourApp>.ModelCase

@kenabe It's now <YourApp>.DataCase.
I didn't know what's causing the problem, but when i came across your comment, I realized I forgot to change ExUnit.Case to <MyApp>.DataCase. :100:

Was this page helpful?
0 / 5 - 0 ratings