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?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With