src: wake worker drain for foreground tasks - #65121
Conversation
Signed-off-by: ulofiai <monsterking@tutamail.com>
Did you validate that your testing hardness fails 100% of the time in the previous Node.js version (e.g. if you ran a test script 10,000 times, would running that script several times result in a consistent failure rate (say 1 in 10,000, or something))? |
|
Good question. I have not yet measured this against the actual parent Node.js revision. The 10,000-iteration result in the PR description came from a standalone synchronization harness, not 10,000 runs of the Node.js cctest, so it should not be read as a measured Node.js failure rate. The new cctest is intended to fail deterministically on the parent implementation, but that is currently a code-level expectation rather than an empirical A/B result. I’ll run the test unchanged against the parent revision, with only the new test applied, and against this PR head, then report the exact pass/fail counts and update the PR description. Thanks for catching the ambiguity. |
Fixes #54918.
Wake a blocking worker drain when an immediate foreground task is posted, and flush foreground work while waiting for user-blocking worker tasks. A generation counter updated under the worker queue mutex prevents a wakeup delivered during foreground flushing from being lost before the next condition-variable wait.
Add a bounded cctest in which a user-blocking worker posts a foreground task and waits for it. Without the fix, the test reports the timeout instead of hanging indefinitely.
Validation of the rebased patch:
git apply --check --whitespace=error-allagainst the exactcurrent/blobscore.autocrlf=trueThe patch-conflict bundle contains only the three affected source/test files, so a full Node.js cctest build was not possible from this snapshot.