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 can not kill worker if work's event loop is blocked #22703

Closed
killagu opened this issue Sep 5, 2018 · 0 comments
Closed

Cluster can not kill worker if work's event loop is blocked #22703

killagu opened this issue Sep 5, 2018 · 0 comments
Labels
cluster Issues and PRs related to the cluster subsystem.

Comments

@killagu
Copy link
Contributor

killagu commented Sep 5, 2018

  • Version: *
  • Platform: *
  • Subsystem: cluster

When worker event loop is blocked, it can not disconnect from the master. So the proc.kill will not be executed.

The SIGTERM can not work is good for me. I wish SIGKILL will work in this scenario as the doc.

'SIGKILL' cannot have a listener installed, it will unconditionally terminate Node.js on all platforms.

And here is the code.

'use strict';

const cluster = require('cluster');
const assert = require('assert');
const isMaster = cluster.isMaster;

if (isMaster) {
  const worker = cluster.fork();
  setTimeout(() => {
    worker.kill('SIGKILL'); // worker.process.kill('SIGKILL');
  }, 1000);
  worker.on('exit', () => {
    console.log('worker exit');
  })
} else {
  let i = 2;
  while(true) {
    i = i % 2;
  }
}

worker.process.kill works, but looks like odd.

@hiroppy hiroppy added the cluster Issues and PRs related to the cluster subsystem. label Sep 5, 2018
cjihrig added a commit to cjihrig/node that referenced this issue Oct 4, 2018
worker.kill() relies on a graceful disconnect, which might not
always be possible. This commit calls this out in the docs, and
specifies worker.process.kill() as a non-graceful alternative.

PR-URL: nodejs#23165
Fixes: nodejs#22703
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
cjihrig added a commit to cjihrig/node that referenced this issue Oct 4, 2018
Verify that worker.process.kill() can terminate a cluster worker
stuck in an infinite loop.

PR-URL: nodejs#23165
Fixes: nodejs#22703
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
targos pushed a commit that referenced this issue Oct 5, 2018
worker.kill() relies on a graceful disconnect, which might not
always be possible. This commit calls this out in the docs, and
specifies worker.process.kill() as a non-graceful alternative.

PR-URL: #23165
Fixes: #22703
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
targos pushed a commit that referenced this issue Oct 5, 2018
Verify that worker.process.kill() can terminate a cluster worker
stuck in an infinite loop.

PR-URL: #23165
Fixes: #22703
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
jasnell pushed a commit that referenced this issue Oct 17, 2018
worker.kill() relies on a graceful disconnect, which might not
always be possible. This commit calls this out in the docs, and
specifies worker.process.kill() as a non-graceful alternative.

PR-URL: #23165
Fixes: #22703
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
jasnell pushed a commit that referenced this issue Oct 17, 2018
Verify that worker.process.kill() can terminate a cluster worker
stuck in an infinite loop.

PR-URL: #23165
Fixes: #22703
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
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

2 participants