[erlang-questions] Can gen_fsm be restarted by a supervisor with state data kept?
Wed Jul 31 09:38:18 CEST 2013
What I usually do in the case a server (or FSM) keeps important data in its state is passing in an ets table id owned by the respective supervisor (e.g. created in its init function). In case of an error or exception, the important parts of the state can be saved in the ets table using the terminate callback of the server. When resurrecting, the server can retrieve the data from the table in its init callback function.
However, as mentioned before, restarting with the crash state of a server can be dangerous. You should be extremely careful when selecting the parts of the state to preserve, otherwise you might inject a crash loop which in turn can crash the whole supervision tree.
Von: erlang-questions-bounces@REDACTED [erlang-questions-bounces@REDACTED]" im Auftrag von "Bengt Kleberg [bengt.kleberg@REDACTED]
Gesendet: Mittwoch, 31. Juli 2013 09:20
Betreff: Re: [erlang-questions] Can gen_fsm be restarted by a supervisor with state data kept?
The FSM has crashed. Is it really a good idea to start it with the same
On Wed, 2013-07-31 at 14:41 +0800, Barco You wrote:
> Dear All,
> I have a gen_fsm instance which is supervised by a supervisor. The
> gen_fsm instance sometimes crashed and then restarted by the
> supervisor, but the state data was reinitialized. How can I restart
> this instance with the state data it has at crash point?
> Thank you.
> erlang-questions mailing list
erlang-questions mailing list
More information about the erlang-questions