Unexpected behaviour of net_kernel

Dieter Schön dieter@REDACTED
Wed Sep 1 23:02:26 CEST 2021


Hi Lorenzo,


I played around with nodes in the last days, my experiments showed 
nominal behaviour.

So, no spurious nodeup/nodedown messages for not connected nodes..

Did you read the fine print in the documentation of 
net_kernel:monitor_nodes() ?

I would suspect some kind of race condition in your code.

Do you have timestamped logs which show when a node is shut down, and 
when nodeup/down messages

arrive?


Kind regards,

Dieter


On 01.09.21 13:00, Lorenzo Cian wrote:
> Dear all,
>
> I am a beginner in Erlang and I'm working on a project.
> I am working with nodes that need to connect and disconnect frequently 
> both in "visible" and "hidden" mode.
>
> I wonder if there is a bug in net_kernel, because I observe the 
> following unexpected behaviour and I'm unable to link it to any action 
> caused by my code.
>
> What happens in the execution of my program is roughly the following:
> initial state: node A is connected (in visible mode) to node B,
>                    node D is not connected to any other node
> then:
> 1) node A disconnects from B (using net_kernel:disconnect/1)
> 2) node A connects to node D (using net_kernel:connect_node/1)
> result: somehow D receives nodeup messages and connects to both A and B
> expected behaviour: node D should connect to just A, while B should be 
> connected to no one
>
> Note that steps 1 and 2 are executed sequentially in the same function 
> so there's no way they could be concurrent.
>
> Could this be a bug in net_kernel?
> I thought that maybe, somehow A has some messages related to 
> net_kernel that hang up in a way such that when step 2 happens, node A 
> is not yet disconnected completely from B?
> Is it possible that something like that happens? If yes, how can I 
> avoid this?
>
> Even if I'm pretty confident that my code works as intended and I 
> tried to debug and check it several times, of course the other option 
> is that this could be caused by a bug in my code.
> Of course there are a lot of other processes involved that I can't 
> explain here, but let's suppose that they don't cause any interference 
> with the example.
>
> I hope someone who knows Erlang better than me can help me clarify my 
> doubts.
>
> Thank you,
> Lorenzo.


More information about the erlang-questions mailing list