Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster: worker.disconnect waits for handles to close before firing "disconnect" event #4542

Closed
cjthompson opened this issue Jan 5, 2016 · 4 comments
Labels
cluster Issues and PRs related to the cluster subsystem.

Comments

@cjthompson
Copy link

In the classic (0.10) cluster scheduler (SCHED_NONE), when worker.disconnect() is called, the worker immediately emits a "disconnect" event, then proceeds to wait for exiting connections to close before terminating the child process:

Worker.prototype.disconnect = function() {

In the Round Robin mode, worker.disconnect() does not fire a disconnect event, and it waits for all the handles to close before disconnecting the child process.

Worker.prototype.disconnect = function() {

In short, the old behavior was to: 1) fire "disconnect", 2) wait for handles to close, 3) fire "exit". The new behavior is 1) disconnect IPC (but don't fire "disconnect" event), 2) wait for handles to close, 3) fire "disconnect" event, 4) fire "exit" event

The scenario I'm looking at is if a worker disconnects, I'd like the master to immediately start a new worker in its place, while waiting for the previous worker to terminate (or force terminate it if it takes too long to close on its own).

This was possible with the old scheduler, but not the round robin scheduler.

@cjthompson
Copy link
Author

I've also been able to trigger this error after a worker disconnects:

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: IPC channel is already disconnected
    at process.target.disconnect (internal/child_process.js:631:26)
    at Server.checkRemainingHandles (cluster.js:659:17)
    at Server.g (events.js:260:16)
    at emitNone (events.js:67:13)
    at Server.emit (events.js:166:7)
    at emitCloseNT (net.js:1521:8)
    at doNTCallback1 (node.js:430:9)
    at process._tickCallback (node.js:352:17)

@r-52 r-52 added the cluster Issues and PRs related to the cluster subsystem. label Jan 5, 2016
@cjihrig
Copy link
Contributor

cjihrig commented Jan 15, 2016

What version of Node are you using? What operating system? You're a lot more likely to get help if you provide code (with no external dependencies) to reproduce the problem.

@Trott
Copy link
Member

Trott commented Jan 16, 2016

Note also that there have been two possibly-relevant changes to disconnect behavior since the version of cluster.js linked to in this issue.

@cjthompson
Copy link
Author

I've been unable to reproduce the issue using a simple example, so I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants