-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
child_process: emit IPC messages on next tick #6909
Conversation
I like this solution better. LGTM if CI agrees. |
LGTM. This is also a fix for #3072, I think? Is it possible to write a reliable regression test? |
I have a test: santigimeno@c07eae8, that passes with this change, and never exits without it. Feel free to use it / modify it if it works for you. |
Test LGTM. I'll pull it into this PR. |
LGTM with the test added and green CI |
Test LGTM2. @cjihrig Consider stress-testing it before you land the PR. |
Normal CI: https://ci.nodejs.org/job/node-test-pull-request/2742/. Will stress test next. |
The test timed out on Windows due to the different scheduling policy. I've added another commit, which addresses it, but for whatever reason, GitHub isn't currently showing it. Here it is. @bnoordhuis and @santigimeno what do you think? --- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -719,7 +719,11 @@ function workerInit() {
const handle = handles[key];
delete handles[key];
waitingCount++;
- handle.owner.close(checkWaitingCount);
+
+ if (handle.owner)
+ handle.owner.close(checkWaitingCount);
+ else
+ handle.close(checkWaitingCount);
}
checkWaitingCount(); |
c5efa43
to
7cfabab
Compare
GitHub seems to be working again. CI after latest commit: https://ci.nodejs.org/job/node-test-pull-request/2744/ |
CI is green, except for one PPC machine that seems hung or something. |
LGTM. The last commit seems to fix a different issue though. A couple of comments:
|
CI with all four commits: https://ci.nodejs.org/job/node-test-pull-request/2765/ |
CI was all green except for one flake (test-stdout-close-catch - #6918). Stress test (Ubuntu): https://ci.nodejs.org/job/node-stress-single-test/737/ |
LGTM. Looks like a flake on the fbsd10 buildbot. |
Currently, if an IPC event handler throws an error, it can cause the message to not be consumed, leading to messages piling up. This commit causes IPC events to be emitted on the next tick, allowing the channel's processing logic to move forward as normal. Fixes: nodejs#6561 PR-URL: nodejs#6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
The test in this commit runs correctly if IPC messages are properly consumed and emitted. Otherwise, the test times out. Fixes: nodejs#6561 PR-URL: nodejs#6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
When a worker is disconnecting, it shuts down all of the handles it is waiting on. It is possible that a handle does not have an owner, which causes a crash. This commit closes such handles without accessing the missing owner. Fixes: nodejs#6561 PR-URL: nodejs#6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
This test checks that ownerless cluster worker handles are closed correctly on disconnection. Fixes: nodejs#6561 PR-URL: nodejs#6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Currently, if an IPC event handler throws an error, it can cause the message to not be consumed, leading to messages piling up. This commit causes IPC events to be emitted on the next tick, allowing the channel's processing logic to move forward as normal. Fixes: nodejs#6561 PR-URL: nodejs#6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
The test in this commit runs correctly if IPC messages are properly consumed and emitted. Otherwise, the test times out. Fixes: nodejs#6561 PR-URL: nodejs#6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
@cjihrig lts? |
IMO yes. It keeps the IPC channel from getting constipated. |
Currently, if an IPC event handler throws an error, it can cause the message to not be consumed, leading to messages piling up. This commit causes IPC events to be emitted on the next tick, allowing the channel's processing logic to move forward as normal. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
The test in this commit runs correctly if IPC messages are properly consumed and emitted. Otherwise, the test times out. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
When a worker is disconnecting, it shuts down all of the handles it is waiting on. It is possible that a handle does not have an owner, which causes a crash. This commit closes such handles without accessing the missing owner. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
This test checks that ownerless cluster worker handles are closed correctly on disconnection. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
This test checks that ownerless cluster worker handles are closed correctly on disconnection. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Currently, if an IPC event handler throws an error, it can cause the message to not be consumed, leading to messages piling up. This commit causes IPC events to be emitted on the next tick, allowing the channel's processing logic to move forward as normal. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
The test in this commit runs correctly if IPC messages are properly consumed and emitted. Otherwise, the test times out. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
When a worker is disconnecting, it shuts down all of the handles it is waiting on. It is possible that a handle does not have an owner, which causes a crash. This commit closes such handles without accessing the missing owner. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
This test checks that ownerless cluster worker handles are closed correctly on disconnection. Fixes: #6561 PR-URL: #6909 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
This commit fixes a regression related to IPC 'message' events. When messages are not emitted in the next tick, a 'message' handler that throws can break the IPC read loop. Refs: nodejs#6909 Refs: nodejs#13459 Refs: nodejs#13648 PR-URL: nodejs#13856 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
This commit fixes a regression related to IPC 'message' events. When messages are not emitted in the next tick, a 'message' handler that throws can break the IPC read loop. Refs: #6909 Refs: #13459 Refs: #13648 PR-URL: #13856 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
This commit fixes a regression related to IPC 'message' events. When messages are not emitted in the next tick, a 'message' handler that throws can break the IPC read loop. Refs: #6909 Refs: #13459 Refs: #13648 PR-URL: #13856 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
This commit fixes a regression related to IPC 'message' events. When messages are not emitted in the next tick, a 'message' handler that throws can break the IPC read loop. Refs: #6909 Refs: #13459 Refs: #13648 PR-URL: #13856 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
Checklist
Affected core subsystem(s)
child_process
Description of change
Currently, if an IPC event handler throws an error, it can cause the message to not be consumed, leading to messages piling up. This commit causes IPC events to be emitted on the next tick, allowing the channel's processing logic to move forward as normal.
Refs: #6561
Refs: #6902
R= @santigimeno @bnoordhuis