<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Absolutely, maybe it's us but I notice that you, as me, has tried all the possibilities and in fact in any case but on link disconnection bob (and we think is right, BTW!!!) remains alive and in good health.<br>I hope someone shows up with a clever explanation, if not it's perfectly understable to file a bug.<br><br>> I disconnect Alice from the network -> Bob joins his ancestors.<br>Ahahah, may it rest in peace with the ones he loved!!!<br><br><br><div>> Date: Wed, 17 Aug 2011 14:49:29 -0600<br>> From: erlang@nimqas.com<br>> To: maggio.vincenzo@hotmail.it<br>> CC: erlang-questions@erlang.org<br>> Subject: RE: [erlang-questions] Process surviving disconnect<br>> <br>> OK, I changed the spawn_link to spawn and subsequent monitor as you <br>> suggest: exactely the same behaviour.<br>> <br>> Alice terminates gracefully -> Bob gets informed and is alive.<br>> Alice terminates ungracefully -> Bob gets informed and is alive.<br>> I kill Alice's node -> Bob gets informed and is alive.<br>> I disconnect Alice from the network -> Bob joins his ancestors.<br>> <br>> So I will wait some days more here on erlang-questions and if nothing <br>> shows up here, I will file a bug and hopefully will be proven wrong.<br>> <br>> On Wed, 17 Aug 2011 22:23:06 +0200, Vincenzo Maggio wrote:<br>> > Use monitor(process, PID_TO_BE_MONITORED) after spawn.<br>> > BTW not having two PCs I simply tested your code killing alice and<br>> > guess what? bob survives! :)<br>> ><br>> >> Date: Wed, 17 Aug 2011 14:13:37 -0600<br>> >> From: erlang@nimqas.com<br>> >> To: maggio.vincenzo@hotmail.it<br>> >> CC: erlang-questions@erlang.org<br>> >> Subject: RE: [erlang-questions] Process surviving disconnect<br>> >><br>> >> Thank you for your quick answer.<br>> >><br>> >> > BTW, before filing a bug, could you please substitute spawn_link <br>> >> with<br>> >> > spawn_monitor and remove the process_flag lines? It would be<br>> >> > interesting to understand if either bob dies on its own or it's<br>> >> > killed<br>> >> > by no more being able to communicate with alice.<br>> >><br>> >> I am not sure how to replace spawn_link with spawn_monitor, as <br>> >> neither<br>> >> spawn_monitor/1 nor spawn_monitor/3 take a node parameter.<br>> >> How do I do that or how else can I get some more detailed <br>> >> information<br>> >> about Bob's sudden passing the Styx.<br>> >><br>> >><br>> >><br>> >> On Wed, 17 Aug 2011 21:48:30 +0200, Vincenzo Maggio wrote:<br>> >> > Hello,<br>> >> > I think something is wrong here.<br>> >> >> Bob die of noconnection.<br>> >> ><br>> >> > This is printed by<br>> >> >> {'EXIT', Bob, Reason} -><br>> >> >> io:format ("Bob died of ~p.~n", [Reason] ),<br>> >> ><br>> >> > So alice is in fact receiving bob last death cry :D and <br>> >> process_flag<br>> >> > translate it in a message instead of transmitting exit signal to<br>> >> > alice; I think this is ok from the point of view of Alice, so the<br>> >> > real<br>> >> > problem is that bob is dying (I know it's mundane, but I learned <br>> >> not<br>> >> > to make assumption).<br>> >> > Mmm, well I don't know if having no more a connection between the<br>> >> > process makes Erlang VM do some assumption of a virtual master <br>> >> node.<br>> >> > Well, if you want my opinion, I think that you should file a bug <br>> >> on<br>> >> > the Erlang bugs mailing list if no one comes up with a proper<br>> >> > explanation.<br>> >> > Even if what we're thinking is wrong and this is not a bug, in the<br>> >> > past I had a problem on node lookup and they resolved it.<br>> >> > These are my two cents, but if you can please let me know if there<br>> >> > are further updates 'cause it's a really interesting problem.<br>> >> ><br>> >> > BTW, before filing a bug, could you please substitute spawn_link <br>> >> with<br>> >> > spawn_monitor and remove the process_flag lines? It would be<br>> >> > interesting to understand if either bob dies on its own or it's<br>> >> > killed<br>> >> > by no more being able to communicate with alice.<br>> >> ><br>> >> > Vincenzo<br>> >> ><br>> >> >> Date: Wed, 17 Aug 2011 10:57:35 -0600<br>> >> >> From: erlang@nimqas.com<br>> >> >> To: maggio.vincenzo@hotmail.it<br>> >> >> CC: erlang-questions@erlang.org<br>> >> >> Subject: RE: [erlang-questions] Process surviving disconnect<br>> >> >><br>> >> >> Thank you very much Vincenzo. You affirmed my assertion that Bob<br>> >> >> should<br>> >> >> survive the disconnect.<br>> >> >> Nevertheless he dies.<br>> >> >> I will point out exactly what I do and maybe someone can spot <br>> >> the<br>> >> >> error<br>> >> >> in my code, my setup or my thinking and tell me what I am doing<br>> >> >> wrong.<br>> >> >><br>> >> >> I start a node on gca.local:<br>> >> >> unroot@gca:~$ erl -name 'bob@gca.local' -setcookie 123<br>> >> >><br>> >> >> I start a node on usa.local:<br>> >> >> unroot@usa:~$ erl -name 'alice@usa.local' -setcookie 123<br>> >> >><br>> >> >> I start sasl on bob@gca.local:<br>> >> >> (bob@gca.local)1> application:start (sasl).<br>> >> >><br>> >> >> I run alice:start/0 on alice@usa.local:<br>> >> >> (alice@usa.local)1> alice:start ().<br>> >> >> true<br>> >> >><br>> >> >> I look for bob on bob@gca.local and save its pid:<br>> >> >> (bob@gca.local)2> whereis (bob).<br>> >> >> <0.65.0><br>> >> >> (bob@gca.local)3> Pid = whereis (bob).<br>> >> >> <0.65.0><br>> >> >><br>> >> >> I cut the network cable and wait a minute for the timeout.<br>> >> >><br>> >> >> On alice@usa.local I get the following output:<br>> >> >> =ERROR REPORT==== 17-Aug-2011::10:53:21 ===<br>> >> >> ** Node 'bob@gca.local' not responding **<br>> >> >> ** Removing (timedout) connection **<br>> >> >> Bob die of noconnection.<br>> >> >><br>> >> >> Nice, Alice trapped Bob's death and reported it. I check for <br>> >> Alice:<br>> >> >> (alice@usa.local)2> whereis (alice).<br>> >> >> <0.42.0><br>> >> >><br>> >> >> Alice is up and running.<br>> >> >><br>> >> >> On bob@usa.local I get the following output:<br>> >> >> =ERROR REPORT==== 17-Aug-2011::10:53:10 ===<br>> >> >> ** Node 'alice@usa.local' not responding **<br>> >> >> ** Removing (timedout) connection **<br>> >> >><br>> >> >> But Bob is dead:<br>> >> >> (bob@gca.local)4> whereis (bob).<br>> >> >> undefined<br>> >> >> (bob@gca.local)5> is_process_alive (Pid).<br>> >> >> false<br>> >> >><br>> >> >> I really do not understand what is happening.<br>> >> >><br>> >> >><br>> >> >> Thank you in advance<br>> >> >><br>> >> >> Anchise<br>> >> >><br>> >> >> Here goes the code I used:<br>> >> >><br>> >> >> -module (alice).<br>> >> >> -compile (export_all).<br>> >> >><br>> >> >> start () -> register (alice, spawn (fun init/0) ).<br>> >> >><br>> >> >> stop () -> whereis (alice) ! stop.<br>> >> >><br>> >> >> init () -><br>> >> >> process_flag (trap_exit, true),<br>> >> >> Bob = spawn_link ('bob@gca.local', bob, start, [self () ] ),<br>> >> >> loop (Bob).<br>> >> >><br>> >> >> loop (Bob) -><br>> >> >> receive<br>> >> >> stop -> ok;<br>> >> >> {'EXIT', Bob, Reason} -><br>> >> >> io:format ("Bob died of ~p.~n", [Reason] ),<br>> >> >> loop (Bob);<br>> >> >> Msg -><br>> >> >> io:format ("Alice received ~p.~n", [Msg] ),<br>> >> >> loop (Bob)<br>> >> >> end.<br>> >> >><br>> >> >><br>> >> >> -module (bob).<br>> >> >> -compile (export_all).<br>> >> >><br>> >> >> start (Alice) -><br>> >> >> process_flag (trap_exit, true),<br>> >> >> register (bob, self () ),<br>> >> >> loop (Alice).<br>> >> >><br>> >> >> loop (Alice) -><br>> >> >> receive<br>> >> >> stop -> ok;<br>> >> >> {'EXIT', Alice, Reason} -><br>> >> >> io:format ("Alice died of ~p.~n", [Reason] ),<br>> >> >> loop (Alice);<br>> >> >> Msg -><br>> >> >> io:format ("Bob received ~p.~n", [Msg] ),<br>> >> >> loop (Alice)<br>> >> >> end.<br>> >> >><br>> >> >><br>> >> >> On Wed, 17 Aug 2011 12:47:02 +0200, Vincenzo Maggio wrote:<br>> >> >> > Hello,<br>> >> >> > without further info a debug is rather difficult.<br>> >> >> > But let's try to at least start analysis of the problem:<br>> >> >> ><br>> >> >> >> - Has this something to do that I initially spawn Bob from <br>> >> the<br>> >> >> >> Alice<br>> >> >> >> node?<br>> >> >> ><br>> >> >> > Absolutely not: this would hit the very foundation of Erlang,<br>> >> >> process<br>> >> >> > referential transparency. When a process is started is a brand<br>> >> >> new,<br>> >> >> > clean entity (indeed, default process heap space is always the<br>> >> >> same<br>> >> >> > size!).<br>> >> >> ><br>> >> >> >> - How can I make Bob to survive a connection loss?<br>> >> >> ><br>> >> >> > Look above: it SHOULD survive.<br>> >> >> ><br>> >> >> > Can you please start SASL (application:start(sasl) from the <br>> >> shell)<br>> >> >> > and see if shell log puts some further information?<br>> >> >> ><br>> >> >> > Vincenzo<br>> >> >><br>> >><br>> <br></div> </div></body>
</html>