Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

UDP datagram sockets don't seem to close properly when on a cluster.Worker #8195

Closed
jcmoore opened this issue Aug 16, 2014 · 6 comments
Closed

Comments

@jcmoore
Copy link

jcmoore commented Aug 16, 2014

Tested Mac OSX Mavericks in node.js 0.11.12 and 0.11.13 (hope that's recent enough).

Assertion will be thrown when doing the following:

https://gist.github.com/jcmoore/0ee16fe8fcfbe1a19f4c

My logs are as follows:

cluster internalMessage: online
sockets 0
sockets 1
cluster internalMessage: queryServer
cluster.queryServer: worker[86366, 1] (0.0.0.0:0:udp4:-1)
cluster internalMessage: undefined
sockets 2
cluster internalMessage: queryServer
cluster.queryServer: worker[86366, 1] (0.0.0.0:0:udp4:-1)
cluster.queryServer: CONFLICT! worker[86366, 1] (0.0.0.0:0:udp4:-1)

assert.js:98
  throw new assert.AssertionError({
        ^
AssertionError: false == true
    at SharedHandle.add (cluster.js:77:3)
    at queryServer (cluster.js:402:12)
    at Worker.onmessage (cluster.js:360:7)
    at ChildProcess.<anonymous> (cluster.js:611:8)
    at ChildProcess.<anonymous> (/Users/jmoore/Sites/toast/toast/sandbox/test.js:109:23)
    at ChildProcess.EventEmitter.emit (events.js:129:20)
    at handleMessage (child_process.js:323:10)
    at Pipe.channel.onread (child_process.js:351:11)
@greenboxal
Copy link

I have the same problem when using PM2 and ain2 to send UDP packets to syslog.
Calling socket.bind({ port: 0, exclusive: true }); seems to fix the problem as the worker doesn't try to share the handle with the master.

@greenboxal
Copy link

I was debugging the cluster module, when you close the socket the worker is not being removed from the SharedHandle list.
This could be fixed by sending the close message to the master. Doing this, an assertion is fired when the worker dies as the master try to remove the worker from the SharedHandle(at removeHandlesForWorker).

Also, changing the SharedHandle.add method to ignore if it worker is already on the list(maybe just for UDP sockets), would fix the issue.

In any case, I don't know which is the correct behaviour.

@sam-github
Copy link

@greenboxal

Doing this, an assertion is fired

I'm trying to fix this in:
#8642

@tjmehta
Copy link

tjmehta commented Apr 18, 2015

+1

1 similar comment
@anandkumarpatel
Copy link

+1

@tjmehta
Copy link

tjmehta commented Apr 18, 2015

This problem seems to be occurring in with Node v0.12.2 on OSX Mavericks (and ubuntu 14.04)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants