Can OTP worker resume from same state after being restarted by supervisor?

Tushar Deshpande <>
Sun Sep 19 01:37:03 CEST 2010


I've a question about OTP's restart strategy.

I wrote a simple OTP application with just a root supervisor
and a single worker.  The worker has an internal state defined
by a single integer (count).  The 'count' is initialized to zero.
Each call to the worker process increments this count by one.
I called the worker process 5 times using gen_server:call.
This updated current value of counter to be 5.

Then, I opened the appmon and killed the worker process.
OTP supervisor promptly restarted it.  I thought that the
process would be resume with the same state that it had at
the time of crash.  But, I observed that for the restarted process,
the 'counter' was reset to zero.

I would like the process to resume from the same state after
it's restarted by supervisor.

Is it possible to do this in OTP?

Best Regards,

Tushar Deshpande

More information about the erlang-questions mailing list