amarandon

amarandon

Hello everybody,

Sometimes my test suite fails with errors like this:

** (RuntimeError) could not lookup Manager.Repo because it was not started or it does not exist

On my colleague’s machine it happens a lot, much less on my machine and almost never on our CI server. So I guess it’s some kind of race condition but I don’t know what’s causing it. The ecto repo is the first child of our top-level supervisor but apparently that’s not always enough.

Is there a way to ensure the ecto repo is correctly started before trying to run any test?

Showing Posts 1 to 7

hubertlepicki

hubertlepicki

Tell us more about your app. Is this umbrella project by any chance and the failing tests come from different app than the one which defined Repo?

shamanime

shamanime

I also have this issue from time to time.

I’m sure it started after upgrading libraries but I didn’t bother inspecting it yet. Might do it tomorrow.

Your colleague is not alone.

amarandon

amarandon OP

It is an umbrella app in which only one app has a repo. Failing tests are from the app that has the repo.

The problem occurs both when we run tests from the umbrella top level directory and we run them from the app subdirectory.

That being said, that app which has a repo and failing tests also specifies another app, which also has its own repo, as a :path dependency in its mix.exs deps entry. I don’t see any reference to that other app in the tests errors though.

andreapavoni

andreapavoni

Same problem for me. I have an umbrella app that I’m trying to migrate from Ecto 2.x to Ecto 3.x

Running the tests on the single apps (10+ apps) works as expected.

Running the tests from the umbrella gives several errors on all the apps, like this:

** (RuntimeError) could not lookup SomeApp.Repo because it was not started or it does not exist

Checked configs and settings, it looks like all is correct, after all they all passed (1000+ tests) before migration to ecto 3.x and, as I said, tests are failing only when I run them from the umbrella.

josevalim

josevalim

Creator of Elixir

What is most likely happening is that your supervision tree is restarting, temporarily bringing down the ecto repo supervisor. You can verify it by adding this to your repo:

  def init(_type, config) do
    IO.puts "STARTING REPO"
    {:ok, config}
  end
andreapavoni

andreapavoni

Hi @josevalim thank you for your quick reply.

Sorry for delay, but the next day I went on vacation and I didn’t tried.

Now that I’m back to work, I tried your suggestion and added the puts on all the Repo modules in the apps of the umbrella. What I’ve noted is that the message STARTING X REPO for each app is displayed at the very beginning of the test run (mix test on the umbrella app), but then I get the same errors when tests are executed.

So, your hypothesis is correct, do you have any suggestions on how to fix this?

Thank you in advance.

josevalim

josevalim

Creator of Elixir

You need to figure out what is causing your supervision tree to restart and change it accordingly so it doesn’t restart all the time. You can enable handle_sasl_reports in Logger to get more complete reports.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews