[erlang-questions] (no subject)

Ulf Wiger <>
Tue Mar 15 20:24:34 CET 2016


I have made a PR for this:

https://github.com/uwiger/gproc/pull/108 <https://github.com/uwiger/gproc/pull/108>

I’m not 100% happy with it, nor does it have a test case for the previously failing case.
However, the original test suite passes, and the manual test you describe also works for me (and didn’t before).

BR,
Ulf W

> On 15 Mar 2016, at 02:31, Khitai Pang <> wrote:
> 
> I have been trying to use gproc with https://github.com/garret-smith/gen_leader_revival <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/ff5a2c95/attachment.html>


More information about the erlang-questions mailing list