delayed child restart with incremental back-off

Loïc Hoguin essen@REDACTED
Mon May 3 20:32:26 CEST 2021

On 03/05/2021 19:03, Tristan Sloughter wrote:
>> But it might be difficult to make
>> it generic enough considering you often want to handle other events
>> while the backoff is in progress.
> Right, that could be done with the end of backoff being a timeout message. Handle other events in whatever state you want until you receive the backoff complete timeout. But how would you do this if it was handled by the supervisor? Difficulty being generic enough is another reason to not attempt to move this into the supervisor.

Yes they're two separate solutions.

Right now my immediate concern on this topic is that there's a duplicate 
supervisor module in RabbitMQ and it would be good to get rid of it. The 
exact solution to achieve that is not super important as long as there 
isn't a duplicate anymore and it's simple enough to maintain.

Then there's the hypothetical best solution which may be via gen_statem 
(but that sounds difficult to achieve) or via supervisor (easier, but 
less potential use cases covered).

> I don't know that this would actually fit well in gen_statem, I think an attempt at a generic version that is a module called from the user's statem would be a good way to find out.

Yeah. I don't know if much can be done there. In Gun for example there 
are three potential "init" states: 'domain_lookup', 'connecting' and 
'tls_handshake'. Then a 'not_connected' state that does a state_timeout 
and keeps track of how many retries it does. Perhaps this 
'not_connected' state could be abstracted somewhat. But it's not much.

Loïc Hoguin

More information about the erlang-questions mailing list