Erlang: Who supervises the supervisor?
Asked Answered
M

3

11

In all Erlang supervisor examples I have seen yet, there usually is a "master" supervisor who supervises the whole tree (or at least is the root node in the supervisor tree). What if the "master"-supervisor breaks? How should the "master"-supervisor be supervised?? any typical pattern?

Molech answered 18/4, 2011 at 8:33 Comment(0)
B
12

The top supervisor is started in your application start/2 callback using start_link, this means that it links with the application process. If the application process receives an exit signal from the top supervisor dying it does one of two things:

  1. If the application is started as an permanent application the entire node i terminated (and maybe restarted using HEART).

  2. If the application is started as temporary the application stops running, no restart attempts will be made.

Barratry answered 18/4, 2011 at 9:23 Comment(0)
J
4

Typically Supervisor is set to "only" supervise other processes. Which mens there is no user written code which is executed by Supervisor - so it very unlikely to crash.

Of course, this cannot be enforced ... So typical pattern is to not have any application specific logic in Supervisor ... It should only Supervise - and do nothing else.

Jyoti answered 18/4, 2011 at 8:48 Comment(3)
But Erlang is usually used for cloud computing.. The supervisor may crash if, for example, the server containing the "master"-supervisor crashes (someone accidentally pulls the plug?). Also, there usually is more than just your application thread running on the OS. This does not mean that the whole cloud should crash in that case..Molech
@dkk Erlang is not usually used for cloud computing. Cloud computing is a loaded term that appeared in the last few years while Erlang has been around for over 20 years. Erlang usually rather runs on small to medium-sized clusters of serversPlethora
@dkk: you dont watch other nodes with supervisors, you have one master supervisor per application on each node.Exedra
E
3

Good question. I have to concur that all of the examples and tutorials mostly ignore the issue - even if occasionally someone mentions the issue (without providing an example solution):

If you want reliability, use at least two computers, and then make them supervise each other. How to actually implement that with OTP is (with the current state of documentation and tutorials), however, appears to be somewhere between well hidden and secret.

Esemplastic answered 18/4, 2011 at 18:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.