[erlang-questions] (no subject)

Khitai Pang <>
Tue Mar 15 10:31:09 CET 2016


I have been trying to use gproc with 
https://github.com/garret-smith/gen_leader_revival.  I found that 
registering a name which is already registered will destroy the existing
 registration of the name, and a remote node is unaware of this.  See 
the following steps:





Register node1 shell as global name 'abcde' on node1, the name is 
visable on node2 and sending messages from node2 shell to 'abcde' works 
fine:



(node1)1> gproc:reg({n, g, abcde}).

true

(node1)2> gproc:where({n, g, abcde}).

<0.229.0>



(node2)1> gproc:where({n, g, abcde}).

<8049.229.0>

(node2)2> gproc:send({n, g, abcde}, hello).

hello



(node1)3> flush().

Shell got hello

ok





Now on node1 shell register with the name again, it removes the existing registration:



(node1)4> gproc:reg({n, g, abcde}).

** exception error: bad argument

     in function  gproc:reg/1

        called as gproc:reg({n,g,abcde})

(node1)5> gproc:where({n, g, abcde}).

undefined





But on node2 the shell still gets <8049.229.0>:



(node2)3> gproc:where({n, g, abcde}).

<8049.229.0>





And sending message from node2 shell to 'abcde' still works 'fine', but the node1 shell doesn't get any message:



(node2)4> gproc:send({n, g, abcde}, hello).

hello



(node1)6> flush().

ok





Now if I register node1 shell as {n, g, abcde} again, everything works fine again:



(node1)7> gproc:reg({n, g, abcde}).

true



(node2)5> gproc:where({n, g, abcde}).

<8049.268.0>

(node2)6> gproc:send({n, g, abcde}, hello).

hello



(node1) 8> flush().

Shell got hello

ok





This doesn't look right to me.

1) When registering with a name already registered, why doesn't gproc return something like {error, already_registered}?

2) After the registration is removed, why does a remove node still sees the non-existent registration?





Thanks

Khitai 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160315/5ecb1fa4/attachment.html>


More information about the erlang-questions mailing list