I encounter this error every once in a while when running tests. I use Postgres 15 on a Windows 11 machine.
I’d appreciate any advice on how I should find the root cause, on which steps I should take.
** (MatchError) no match of right hand side value: {:error, {%DBConnection.ConnectionError{message: "connection not available and request was dropped from queue after 102ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:\n\n
1. Ensuring your database is available and that you can connect to it\n
2. Tracking down slow queries and making sure they are running fast enough\n
3. Increasing the pool_size (although this increases resource consumption)\n
4. Allowing requests to wait longer by increasing :queue_target and :queue_interval\n\n
See DBConnection.start_link/2 for more information\n", severity: :error, reason: :queue_timeout}, [{DBConnection.Ownership, :ownership_checkout, 2, [file: 'lib/db_connection/ownership.ex', line: 100, error_info: %{module: Exception}]}, {Ecto.Adapters.SQL.Sandbox, :checkout, 2, [file: 'lib/ecto/adapters/sql/sandbox.ex', line: 500]}, {Ecto.Adapters.SQL.Sandbox, :"-start_owner!/2-fun-0-", 3, [file: 'lib/ecto/adapters/sql/sandbox.ex', line: 407]}, {Agent.Server, :init, 1, [file: 'lib/agent/server.ex', line: 8]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 848]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 811]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}
stacktrace:
(ecto_sql 3.10.1) lib/ecto/adapters/sql/sandbox.ex:404: Ecto.Adapters.SQL.Sandbox.start_owner!/2
(my_app 0.1.0) test/support/data_case.ex:39: MyAppApp.DataCase.setup_sandbox/1
(my_app 0.1.0) test/support/conn_case.ex:38: MyAppWeb.ConnCase.__ex_unit_setup_0/1
(my_app 0.1.0) test/support/conn_case.ex:1: MyAppWeb.ConnCase.__ex_unit__/2
test/my_app_web/graphql/mutation/create_articles_test.exs:1: MyAppWeb.GraphQL.CreateArticlesTest.__ex_unit__/2
Any suggestion welcome, thank you!
test_helper.exs
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(MyApp.Repo, :manual)
When testing the _web
folder:
use MyAppWeb.ConnCase, async: true
When testing the contexts and schemas:
use MyApp.DataCase, async: true
Note also that I run mix test
from the root of the umbrella apps.