-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
async_wrap: schedule destroy hook as unref #18241
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if this solves the flakiness in the test.
...this does introduce a change in the contract for async hooks... specifically, it means that there is chance that destroy may not be called for at least some set of hooks. It's likely best to document that fact if we can do so in a way that isn't too obscure.
The newly introduced |
Ah right yeah... Forgot about the RunBeforeExit. All good then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Pretty sure this fixes the flakes. I ran 6 Linux CIs and 3 full ones, not a single failure of that getasyncid test. |
Stress tests after #18245 lands: master: refs/pull/18241/head (this PR): refs/pull/18245/head |
Looks I need to rebase as that job doesn't do it. On it. Stress test CI: https://ci.nodejs.org/job/node-stress-single-test/1737/ |
Since the `DestroyAsyncIdsCallback` in Node.js can be scheduled as a result of GC, that means that it can accidentally keep the event loop open when it shouldn't. Replace `SetImmediate` with the newly introduced `SetUnrefImmediate` and in addition introduce RunBeforeExit callbacks, of which `DestroyAsyncIdsCallback` is now the first. These callbacks will run before the `beforeExit` event is emitted (which will now only be emitted if the event loop is still not active).
13abfbb
to
002937f
Compare
Stress test is green. Should we land this? |
Landed in 8803b69 |
Since the `DestroyAsyncIdsCallback` in Node.js can be scheduled as a result of GC, that means that it can accidentally keep the event loop open when it shouldn't. Replace `SetImmediate` with the newly introduced `SetUnrefImmediate` and in addition introduce RunBeforeExit callbacks, of which `DestroyAsyncIdsCallback` is now the first. These callbacks will run before the `beforeExit` event is emitted (which will now only be emitted if the event loop is still not active). PR-URL: #18241 Fixes: #18190 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
Node 9.x is failing to compile with this commit, should we backport?
|
Since the
DestroyAsyncIdsCallback
in Node.js can be scheduled as a result of GC, that means that it can accidentally keep the event loop open when it shouldn't. ReplaceSetImmediate
with the newly introducedSetUnrefImmediate
and in addition introduce RunBeforeExit callbacks, of whichDestroyAsyncIdsCallback
is now the first. These callbacks will run before thebeforeExit
event is emitted (which will now only be emitted if the event loop is still not active).Fixes: #18190
Linux CI to assess whether this fixes the above (all green):
https://ci.nodejs.org/job/node-test-commit-linux/15673/
https://ci.nodejs.org/job/node-test-commit-linux/15674/
https://ci.nodejs.org/job/node-test-commit-linux/15675/
CI:
https://ci.nodejs.org/job/node-test-pull-request/12615/
https://ci.nodejs.org/job/node-test-commit/15516/
https://ci.nodejs.org/job/node-test-commit/15517/
CitGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1212/
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
async_wrap