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

Nodejs process restart doesn't kill child threads and they become zombie process. #14445

Closed
gaurav-moonfroglabs opened this issue Jul 24, 2017 · 5 comments
Labels
child_process Issues and PRs related to the child_process subsystem. cluster Issues and PRs related to the cluster subsystem. invalid Issues and PRs that are invalid. question Issues that look for answers.

Comments

@gaurav-moonfroglabs
Copy link

Hi,

We are using forever to start our nodejs server. We have been using cluster module. So whenever we restart the process using forever restart, so we see that process gets restarted and new workers gets created but sometimes old workers are still running and i see they are consuming some memory but no cpu and not processing anything (as i have put logs to print worker id for every request processing).

  • Version: v6.10.3
  • Platform: Linux ip-172-31-11-169 3.13.0-92-generic Parallel non-io tests #139-Ubuntu SMP Tue Jun 28 20:42:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem:
@bnoordhuis
Copy link
Member

Any reason to report that here and not against forever?

@gaurav-moonfroglabs
Copy link
Author

Because forever has nothing to do with this bug, what forever do is managing the process not the threads, but when you restart process by sending sigkill the master gets killed and child process doesn't. We are facing this issue now when we moved to node 6.10.3 and it was working fine in node 4.2.6.

@bnoordhuis
Copy link
Member

Then you (where you = forever or your script) should send a signal to the process group, not just the master process. SIGKILL kills a process without giving it any chance to clean up. That has nothing to do with node.js and everything with UNIX process management.

@mscdex mscdex added child_process Issues and PRs related to the child_process subsystem. question Issues that look for answers. cluster Issues and PRs related to the cluster subsystem. labels Jul 24, 2017
@bnoordhuis
Copy link
Member

I'll close this out, the previous comment said all there is to say. If you still feel this is a node.js bug, please post a standalone test case (i.e., without forever.)

@bnoordhuis bnoordhuis added the invalid Issues and PRs that are invalid. label Jul 24, 2017
@andrasq
Copy link

andrasq commented Jul 24, 2017

@gaurav-moonfroglabs normally a cluster worker exits when the master closes the IPC socket it uses to talk to it. Not sure why v6 would behave differently than v4 for you (my simple little test worked, the workers exited when the master was killed with SIGKILL). You might try to trace what the workers are doing to not react to the socket closing.

var cluster = require('cluster');
if (cluster.isMaster) {
    cluster.fork();
    setTimeout(function() { process.kill(process.pid, 'SIGKILL') }, 500);
}
else {
    process.on('exit', function(x) { console.log("exiting:", x) });
    setTimeout(function() { console.log("alive 200") }, 200);
    setTimeout(function() { console.log("alive 800") }, 800);
}

outputs

% node-v6.10.2 fork-test.js
alive 200
Killed
% exiting: 0

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

No branches or pull requests

4 participants