4

When running a set of tests by using mix test I get

 ** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.414.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.

I have already replaced Ecto.Adapters.SQL.Sandbox.mode(Secure.Repo, :manual) by Ecto.Adapters.SQL.Sandbox.mode(Secure.Repo, {:shared, self()}) in test/test_helper.exs.

Tests failing belong to the same test file, where I am not using ExUnit.Case, async: true.

If I run them isolatedly they run ok. Still not completely sure if it has something to do with tests being run in parallel way using a MySQL server.

David
  • 595
  • 1
  • 8
  • 19
  • 1
    Did you recently upgrade to ecto 2.0? In any way, check out https://github.com/elixir-ecto/ecto/blob/v2.0.0/CHANGELOG.md#concurrent-transactional-tests and possibly generate a new empty project with a test to diff the boilerplate. – Matthias Winkelmann Sep 09 '16 at 10:51
  • I am using Ecto through Phoenix 1.2.0. So, phoenix_ecto 3.0 and Ecto 2.0. – David Sep 12 '16 at 11:09
  • 2
    I've been having the same problem (also using MySQL with Mariaex), but it's inconsistent. I often get it the first time I run tests after "some time". Then the second run, I don't have the problem and it doesn't come back again as I rerun the tests until after the next "some time" passes without running tests. – objectuser Oct 25 '16 at 14:31

0 Answers0