dogweather

dogweather

I was getting this from mix test. Even though lower level data access still worked — we could actually connect to the test database.

** (RuntimeError) could not lookup Ecto repo Xxx.Yyy because it was not started or it does not exist

Finally, we tried env MIX_ENV=test mix ecto.reset, and that fixed it. (!)

Apparently, there was unexpected data/schema in the test database, but we got no indication of this root problem. So this seems like an error messaging & propagation issue. (?) Is there somewhere else we could have looked for the actual errors?

Showing Posts 1 to 4

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Can you show the complete logs from system boot to that point?

dogweather

dogweather OP

Yes, thanks! You’ll see we also get these other errors/warnings with that dataset only:

robb@arbor ~/s/M/phoenix (master) [1]> mix test
13:15:43.764 [error] Postgrex.Protocol (#PID<0.547.0>) disconnected: ** (DBConnection.ConnectionError) #PID<0.90.0> checked in the connection owned by #PID<0.621.0>

#PID<0.90.0> triggered the checkin at location:

    (kernel) code_server.erl:140: :code_server.call/1
    (elixir) src/elixir_compiler.erl:80: :elixir_compiler.dispatch/4
    (elixir) src/elixir_compiler.erl:63: :elixir_compiler.compile/3
    (elixir) src/elixir_lexical.erl:17: :elixir_lexical.run/2
    (elixir) src/elixir_compiler.erl:23: :elixir_compiler.quoted/2
    (elixir) lib/code.ex:767: Code.require_file/2
    (elixir) lib/enum.ex:769: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:769: Enum.each/2


Client #PID<0.621.0> is still using a connection from owner at location:

    :prim_inet.ctl_cmd/3
    :prim_inet.async_recv/3
    :prim_inet.recv0/3
    (postgrex) lib/postgrex/protocol.ex:2879: Postgrex.Protocol.rows_recv/5
    (postgrex) lib/postgrex/protocol.ex:1898: Postgrex.Protocol.recv_execute/5
    (postgrex) lib/postgrex/protocol.ex:1772: Postgrex.Protocol.bind_execute/4
    (db_connection) lib/db_connection/holder.ex:293: DBConnection.Holder.holder_apply/4
    (db_connection) lib/db_connection.ex:1255: DBConnection.run_execute/5

The connection itself was checked out by #PID<0.621.0> at location:

    (ecto_sql) lib/ecto/adapters/sql.ex:570: Ecto.Adapters.SQL.execute!/4


13:15:43.810 [error] GenServer #PID<0.621.0> terminating
** (DBConnection.ConnectionError) tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)
    (ecto_sql) lib/ecto/adapters/sql.ex:629: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql) lib/ecto/adapters/sql.ex:562: Ecto.Adapters.SQL.execute/5
    (ecto) lib/ecto/repo/queryable.ex:177: Ecto.Repo.Queryable.execute/4
    (ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (macrostax) lib/macrostax/accounts/signup_worker.ex:31: Macrostax.Accounts.SignupWorker.check_abandoned/0
    (macrostax) lib/macrostax/accounts/signup_worker.ex:23: Macrostax.Accounts.SignupWorker.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
Last message: :check_abandoned
13:15:43.893 [error] GenServer #PID<0.669.0> terminating
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.669.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.

See Ecto.Adapters.SQL.Sandbox docs for more information.
    (ecto_sql) lib/ecto/adapters/sql.ex:626: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql) lib/ecto/adapters/sql.ex:562: Ecto.Adapters.SQL.execute/5
    (ecto) lib/ecto/repo/queryable.ex:177: Ecto.Repo.Queryable.execute/4
    (ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (macrostax) lib/macrostax/accounts/signup_worker.ex:31: Macrostax.Accounts.SignupWorker.check_abandoned/0
    (macrostax) lib/macrostax/accounts/signup_worker.ex:23: Macrostax.Accounts.SignupWorker.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
Last message: :check_abandoned
13:15:43.894 [error] GenServer #PID<0.671.0> terminating
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.671.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.

See Ecto.Adapters.SQL.Sandbox docs for more information.
    (ecto_sql) lib/ecto/adapters/sql.ex:626: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql) lib/ecto/adapters/sql.ex:562: Ecto.Adapters.SQL.execute/5
    (ecto) lib/ecto/repo/queryable.ex:177: Ecto.Repo.Queryable.execute/4
    (ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (macrostax) lib/macrostax/accounts/signup_worker.ex:31: Macrostax.Accounts.SignupWorker.check_abandoned/0
    (macrostax) lib/macrostax/accounts/signup_worker.ex:23: Macrostax.Accounts.SignupWorker.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
Last message: :check_abandoned
13:15:43.894 [error] GenServer #PID<0.672.0> terminating
** (DBConnection.OwnershipError) cannot find ownership process for #PID<0.672.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.

See Ecto.Adapters.SQL.Sandbox docs for more information.
    (ecto_sql) lib/ecto/adapters/sql.ex:626: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql) lib/ecto/adapters/sql.ex:562: Ecto.Adapters.SQL.execute/5
    (ecto) lib/ecto/repo/queryable.ex:177: Ecto.Repo.Queryable.execute/4
    (ecto) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
    (macrostax) lib/macrostax/accounts/signup_worker.ex:31: Macrostax.Accounts.SignupWorker.check_abandoned/0
    (macrostax) lib/macrostax/accounts/signup_worker.ex:23: Macrostax.Accounts.SignupWorker.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
Last message: :check_abandoned
Excluding tags: [:skip, :hits_external_api]

.......

  1) test migrate_food/1 given a simple meal: creates Recipes, Foods, Conversions, and Tags with expected hierarchy (Macrostax.Utils.KitchenSchemaMigratorTest)
     test/macrostax/utils/kitchen_schema_migrator_test.exs:17
     ** (RuntimeError) could not lookup Ecto repo Macrostax.Repo because it was not started or it does not exist
     stacktrace:
       (ecto) lib/ecto/repo/registry.ex:19: Ecto.Repo.Registry.lookup/1
       (ecto) lib/ecto/adapter.ex:127: Ecto.Adapter.lookup_meta/1
       (ecto_sql) lib/ecto/adapters/sql/sandbox.ex:487: Ecto.Adapters.SQL.Sandbox.lookup_meta!/1
       (ecto_sql) lib/ecto/adapters/sql/sandbox.ex:415: Ecto.Adapters.SQL.Sandbox.checkout/2
       (macrostax) test/support/data_case.ex:30: Macrostax.DataCase.__ex_unit_setup_0/1
       (macrostax) test/support/data_case.ex:1: Macrostax.DataCase.__ex_unit__/2
       test/macrostax/utils/kitchen_schema_migrator_test.exs:1: Macrostax.Utils.KitchenSchemaMigratorTest.__ex_unit__/2

After resetting the test db, we don’t get warnings about the code. Instead, it’s just all green:

robb@arbor ~/s/M/phoenix (master)> mix test
Excluding tags: [:skip, :hits_external_api]

..........................................................................................................................

Finished in 12.3 seconds
142 tests, 0 failures, 20 excluded

Randomized with seed 149348
benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

This is helpful thanks. As one more thing can you mix deps|grep ecto and mix deps|grep postgrex?

dogweather

dogweather OP

Thanks - maybe it’s been too long since we’ve updated?

robb@arbor ~/s/M/phoenix (master)> mix deps|grep ecto
* ecto 3.2.5 (Hex package) (mix)
  locked at 3.2.5 (ecto) 01251d9b
* ecto_sql 3.2.1 (Hex package) (mix)
  locked at 3.2.1 (ecto_sql) 4790973b
* ecto_enum 1.4.0 (Hex package) (mix)
  locked at 1.4.0 (ecto_enum) 8fb55c08
* scrivener_ecto 2.2.0 (Hex package) (mix)
  locked at 2.2.0 (scrivener_ecto) 3eadfc0a
* timber_ecto 2.1.1 (Hex package) (mix)
  locked at 2.1.1 (timber_ecto) 4adc8e60
* phoenix_ecto 4.1.0 (Hex package) (mix)
  locked at 4.1.0 (phoenix_ecto) c5e666a3
robb@arbor ~/s/M/phoenix (master)> mix deps|grep postgrex
* postgrex 0.15.1 (Hex package) (mix)
  locked at 0.15.1 (postgrex) 12cd418e
robb@arbor ~/s/M/phoenix (master)> elixir --version
Erlang/OTP 21 [erts-10.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe]

Elixir 1.8.1 (compiled with Erlang/OTP 20)
— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
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
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews