test_runner: do not reuse a worker ID held by a running file - #65739
Open
vserpokryl wants to merge 1 commit into
Open
test_runner: do not reuse a worker ID held by a running file#65739vserpokryl wants to merge 1 commit into
vserpokryl wants to merge 1 commit into
Conversation
Collaborator
|
Review requested:
|
Worker IDs were handed out round-robin and never released, so a file that started after another finished could get an ID still held by a live process. Track the IDs in use, hand out the lowest free one, and release it in a finally block once the child process exits. Refs: nodejs#61394 Signed-off-by: Vasiliy Serpokryl <vasiliy.serpokryl@mail.ru>
vserpokryl
force-pushed
the
test-runner-exclusive-worker-id
branch
from
September 2, 2026 12:50
35a00d4 to
5416f6a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WorkerIdPoolhanded out worker IDs round-robin ((nextId++ % maxConcurrency) + 1)and never released them, so an ID was only unique among the first N test files.
As soon as files finished out of order, a file that started later was given an ID
still held by a live process, which defeats the purpose of
context.workerId:allocating a database, port or directory per worker.
With
--test-concurrency=2and three files, where the first one outlives thesecond:
Track the IDs that are actually in use and hand out the lowest free one, then
release it once the child process is gone. The release happens in a
finallyblock so an aborted run or a failed spawn does not leak the ID out of the pool.
The pool no longer needs to be told the concurrency level. That also removes a
mismatch: the pool was sized from
globalOptions.concurrency ?? concurrency,which can differ from the concurrency the root test actually enforces. Since IDs
are handed out lowest-first, the highest ID in use is now bounded by how many
files really run at once.
Refs: #61394