marick

marick

Sudden occurrence of Supervisor "failed to start child" without code change

I’ve been setting up my first Phoenix deployment on gigalixir. I’m deploying with mix, and I was having some trouble, so I did an iex -S mix to practice at home. That resulted in this:

[info] Application crit exited: Crit.Application.start(:normal, []) returned an error: shutdown: failed to start child: Crit.Setup.InstitutionSupervisor
    ** (EXIT) bad child specification, more than one child specification has the id: "critter4us".

mix phx.server also fails. I now get the same failure for a git revision from a week ago, well before I started to deploy. Moreover:

  • I did both a mix clean and removed the _build directory.
  • It happens with a new shell (so not an environment issue).
  • I hadn’t changed the version of Elixir or Erlang I was running. (Both are up-to-date.)
  • ps shows that there are no Erlang processes running.
  • Anyway, the app is not distributed. It’s a very basic Phoenix app.

For what it’s worth, the application.ex looks like this:

    # List all child processes to be supervised
    children = [
      # Start the Ecto repository
      Crit.Repo,
      # Start the endpoint when the application starts
      CritWeb.Endpoint,
      # Starts a worker by calling: Crit.Worker.start_link(arg)
      Crit.Audit.ToEcto.Server,
      Crit.Setup.InstitutionSupervisor,
      {ConCache, [name: Crit.Cache,
                  ttl_check_interval: :timer.hours(24),
                  global_ttl: :timer.hours(48)]}
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: Crit.Supervisor]
    Supervisor.start_link(children, opts)

The problem is definitely around InstitutionSupervisor. If I delete it from application.ex, mix phx.server starts.

Marked As Solved

lucaong

lucaong

Most likely the problem is not with InstitutionSupervisor itself, but with one of its children having a duplicated id. Check how the id of its children is computed, and if there is the possibility that two children get assigned the same id. In case you cannot find it, as @NobbZ noted, you can post the children specification inside InstitutionSupervisor and someone here might be able to spot the problem.

Also Liked

NobbZ

NobbZ

Are you generating the names from a database?

You really should use :via tuples and Registry then instead of creating random atoms from the database…

NobbZ

NobbZ

As far as I read the error, a child of that supervisor has the double ID, can you please show the start and children of InstitutionSupervisor?

marick

marick

Argh!

There’s one process per “institution”, with the institution’s name as the process id*, and I somehow ended up running the seeding process twice, meaning copies of institutions.

Thank you! Time for a create unique_index.

  • I know I should be using names less prone to duplication, like illinois_institution_process. Haven’t done that yet.

Where Next?

Popular in Questions Top

New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement