Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Elixir 使用MySQL服务器运行测试时出现DB OwnershipError_Elixir_Phoenix Framework_Elixir Mix - Fatal编程技术网

Elixir 使用MySQL服务器运行测试时出现DB OwnershipError

Elixir 使用MySQL服务器运行测试时出现DB OwnershipError,elixir,phoenix-framework,elixir-mix,Elixir,Phoenix Framework,Elixir Mix,当使用混合测试运行一组测试时,我得到 ** (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

当使用混合测试运行一组测试时,我得到

 ** (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.
**(DBConnection.OwnershipError)找不到#PID的所有权进程。
使用所有权时,必须在一个数据库中管理连接
在三种方式中:
*通过显式签出连接
*通过显式允许派生的进程
*通过在共享模式下运行池
前两个选项要求每个新流程都显式
签出连接或通过调用checkout或
分别允许。
第三个选项需要设置{:shared,pid}模式。
如果在测试中使用共享模式,请确保您的测试不是
异步的。
如果您正在阅读此错误,则表示您尚未执行此操作
或所有者进程已崩溃。
我已经将test/test\u helper.exs中的
exto.Adapters.SQL.Sandbox.mode(Secure.Repo,:manual)
替换为
exto.Adapters.SQL.Sandbox.mode(Secure.Repo,{:shared,self()})

失败的测试属于同一个测试文件,其中我没有使用
ExUnit.Case,async:true


如果我单独运行它们,它们运行正常。仍然不能完全确定这是否与使用MySQL服务器并行运行的测试有关。

您最近是否升级到了ecto 2.0?无论如何,请检查并可能生成一个新的空项目,通过测试来区分样板文件。所以,phoenix_ecto 3.0和ecto 2.0。我也遇到了同样的问题(也在Mariaex中使用MySQL),但不一致。我经常在“一段时间”之后第一次运行测试时得到它。然后第二次运行时,我没有问题,当我重新运行测试时,它不会再次出现,直到下一次“某个时间”通过而没有运行测试。