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 cleanand removed the_builddirectory. - 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.)
psshows 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
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
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
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
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










