[erlang-questions] Supervisor does not restart Gen Server
Gunilla Arendt
gunilla@REDACTED
Thu Mar 1 16:35:04 CET 2007
Hi,
This is a really tricky one!
My guess is that you start the supervisor from the Erlang shell, right?
Since supervisor only has the start_link alternative, you'll get a link
between the shell process and the supervisor.
Then you call zuzu:do(0), which I would guess calls gen_server:call/2.
The gen_server receives the request, does a division by zero and
subsequently terminates.
The supervisor notices the gen_server has terminated and restarts it.
Unfortunately, since the original gen_server process terminated,
the call to zuzu:do(0) failed. Which means that the shell process
terminates.
And the shell process was linked to the supervisor, which means that
now also the supervisor terminates.
Solution? Calling "catch zuzu:do(0)" should do the trick.
Regards,
Gunilla, Erlang/OTP team
Gurgen Tumanian wrote:
> Hello everybody.
>
> In my application i have a set of gen_servers orginized in a simple one
> level supervision tree, with one superviser above all. Now the problem
> that i have , is that once one of my gen_servers is crashed, the
> supervisor does not restart it, and what is even worse - dies himself.
> I have simplified the problem, creating a simple gen server in which a
> badarith can be initiated(divide by zero) and a
> simple supervisor, which should have restarted it in case of crash by
> one_to_one strategy.
>
> now when starting the supervisor, and then calling the zuzu:do(0)
> (causing the badmatch)
> i get the crash of the worker gen_serv, and then the supervisor
> crashes.Supervior's crash report is
> =CRASH REPORT==== 20-Feb-2007::16:35:12 ===
> crasher:
> pid: <0.41.0>
> registered_name: []
> error_info: {{badarith,[{zuzu,handle_call,3},
> {gen_server,handle_msg,6},
> {proc_lib,init_p,5}]},
> {gen_server,call,[zuzu_serv,{do,0},35000]}}
> initial_call: {gen,init_it,
> [gen_server,
> <0.39.0>,
> <0.39.0>,
> supervisor,
> {self,bubu,[]},
> []]}
> ancestors: [<0.39.0>]
> messages: []
> links: []
> dictionary: []
> trap_exit: true
> status: running
> heap_size: 233
> stack_size: 21
> reductions: 227
> neighbours:
>
> I get the feeling that the supervisor dies as it pasess the restart
> limit, but that's a quite surprise for me, as the first start of the
> worker proc pases normally.
> I will be greatfull for any advice on this issue.
>
> Regards
> Gurgen Tumanyan, Smart Tech
More information about the erlang-questions
mailing list