restart=>transient vs permanent for erlang supervisor

356 views Asked by At

I have a 3 level supervision tree structure where top level is a supervisor which spawns second level supervisors which spawn workers. Both the second level supervisor and workers have a restart strategy of transient. Now my worker crashed and is restarted max_restart times. At this time I would expect the supervisor to crash max_restart times and then top level supervisor to crash. But my second level supervisor died and top level one did not restart it. The second level supervisor crashed with this log

Context:    shutdown
Reason:     reached_max_restart_intensity

Is this considered a "normal" shutdown and hence the supervisor was not restarted because I am using restart strategy of transient? Should the mid-level supervisors always use restart=permanent if we want them to be restarted?

1

There are 1 answers

0
José M On BEST ANSWER

From the supervisor documentation:

A transient child process is restarted only if it terminates abnormally, that is, with another exit reason than normal, shutdown, or {shutdown,Term}.

Since the exit reason is shutdown, you'll need to use a different restart policy.