3 ms·
It was restarted by a supervisor :) After tracing the code this is exactly what happened (in this code exactly): 1. Terminate child X 2. /Supervisor
by xlii 2y ago
It was restarted by a supervisor :)
After tracing the code this is exactly what happened (in this code exactly):
1. Terminate child X
2. /Supervisor restarts X/
3. Delete child X {:error, :running}
4. Supervisor.start_child Y {:ok, PID}
5. /X and Y are both running/
As for incorrectness:
> the supervisor does not restart the child in case it exits with reason :normal, :shutdown or {:shutdown, term}.
`terminate_child` is sending shutdown and yet it's being restarted.
And to emphasise on use case. The child is connection handler. Service node changed. It NEEDS to be restarted on crash, but has to be replaced during handoff.
I believe you start to get into "huh?" mode with me. I have a treasure trove of those. (Btw., in Erlang repository there's plenty of notes mentioning THIS exact behavior and if I didn't overskim - even some bugs caused by it - you can search for terminate_child.
- simoncion 2y ago> It NEEDS to be restarted on crash, but has to be replaced during handoff. I question why you're handing off things between supervisors. If this is something you actually need to do, then 'delete_child/2' so the supervisor doesn't restart the child, terminate the child yourself, and re-start the child on the new supervisor. EDIT: Actually, no, you can't 'delete_child/2'. You need to change the supervisor type from 'permanent', to the type that does exactly what you say you need. I'll leave it to you to read the docs. /EDIT > `terminate_child` is sending shutdown and yet it's being restarted. Here's the context for that partial quote that you pulled from [0]: > A supervisor restarts a child process depending on its :restart configuration. For example, when :restart is set to :transient, the supervisor does not restart the child in case it exits with reason :normal, :shutdown or {:shutdown, term}. Re-read that first sentence that you chose to not quote. Then read about the ':restart' supervisor configuration and how it describes when a supervised child is and is not restarted. [1] > I believe you start to get into "huh?" mode with me. Yep. Selective quoting when it's trivial for your conversation partner to find the lies by omission definitely put me into "huh?" mode with you. [0] <https://hexdocs.pm/elixir/1.18.3/Supervisor.html#module-exit-reasons-and-restarts https://hexdocs.pm/elixir/1.18.3/Supervisor.html#module-exit...> [1] <https://hexdocs.pm/elixir/1.18.3/Supervisor.html#module-restart-values-restart https://hexdocs.pm/elixir/1.18.3/Supervisor.html#module-rest...>