Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens after all children of a supervisor die?

Let's say a supervisor has a child that's continuously failing for some reason. As per restart strategy, it will restart the failing child until it reaches max restart count. What will happen to the supervisor after it reaches the max restart count?

like image 962
Regupathy Avatar asked Dec 29 '18 05:12

Regupathy


People also ask

What is supervisor elixir?

In Elixir, this is done by a Supervisor. A Supervisor is a process that supervises other processes and restarts them whenever they crash. To do so, Supervisors manage the whole life-cycle of any supervised processes, including startup and shutdown.

What is a supervision tree?

1.1 Supervision Trees Supervisors are processes that monitor the behaviour of workers. A supervisor can restart a worker if something goes wrong. The supervision tree is a hierarchical arrangement of code into supervisors and workers, which makes it possible to design and program fault-tolerant software.


2 Answers

It'll terminate itself and its supervisor decides whether to restart it according to the supervisor's policy. If it doesn't have a supervisor (it's a root), then it won't be restarted. That's the point of supervision trees.

like image 58
Alexey Romanov Avatar answered Sep 30 '22 08:09

Alexey Romanov


as Alexey Romanov already answered, the supervisor will also fail and so the parent supervisor itself is executing its own strategy. The supervisor strategies have to be aligned between the parent and child supervisors, otherwise a parent supervisor might never fail if its MaxTime for restarts is set incorrectly compared to the child supervisor. If there is no supervisor left, the application itself will crash. If the application is running for example as a windows service, that service itself can have a restart strategy set.

Example:

child supervisor: max restarts 10, max time: 10secs -> child supervisor will crash if its own children have more than 10 crashes within 10secs

parent supervisor: max restarts: 20, max time: 5 secs -> child supervisor has to crash 20 times in 5 secs. That also means that the child of the child supervisor would have to crash > 200 times within 5 seconds in order to crash the parent supervisor

Also check out the following https://learnyousomeerlang.com/supervisors

like image 30
CitrusO2 Avatar answered Sep 30 '22 10:09

CitrusO2