Repository navigation
nightly-lock: collect a leftover that ends just as it is checked (flake fix) - #1438
Merged
Merged
Conversation
On a loaded runner the wrapper's leftover can end on SIGTERM after end_the_rest collected the ended children and before it looked at /proc again. That look shows only a zombie, so the wrapper lets the lock go with its zombie uncollected; init gets it. The test's alive() counted only Z as gone, so a check while init collected it (state X) read the process as alive: the flake of "what the command leaves running is stopped before the lock is free [stops on SIGTERM]" on a Fork tests run of a PR that does not touch the nightly lock. The new test drives end_the_rest in-process and lets the leftover end in exactly that window; it fails: the wrapper returns with the zombie still its own. alive() now counts X as gone too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a zombie end_the_rest collected ended children, then looked for live ones: one that ended between the two was seen only as a zombie and the lock was let go with it uncollected. Now each round looks first and collects after (still_running): a look that finds no live process leaves none waiting as our zombie either, and one that ends after the look is found gone on the next round. A 12-way parallel stress of the wrapper (sleep 60 & left behind): the leftover was still visible after the wrapper exited in 10 of 3600 runs before, 0 of 3600 after. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The flake
fork-ci/actions/nightly-lock/nightly_lock.test.py,Lock.test_what_the_command_leaves_running_is_stopped_before_the_lock_is_free [stops on SIGTERM], failed withassertFalse(alive(left))on a Fork tests run offork/capacity-severe-spikes(run 46320205989), a PR that does not touch nightly-lock.Root cause
end_the_restcalledreap()first and thendescendants(). On a loaded runner the leftover can end on SIGTERM between those two calls. The/proclook then shows only its zombie, so the wrapper lets the lock go without collecting it, and init gets the zombie. The test'salive()treated onlyZas gone. If the check lands while init collects the zombie (stateX), the test reads the process as alive.Reproduced locally with a 12-way parallel stress of the wrapper (
sleep 60 &left behind; the debug log showed the leftover asZ, its parent the wrapper, at the moment the wrapper let go). The leftover was still visible after the wrapper exited in 10 of 3600 runs before the fix and 0 of 3600 after.Fix
nightly_lock.py: each round now looks first and collects after (still_running()). A look that finds no live process therefore leaves none waiting as our zombie. One that ends after the look is found gone on the next round.nightly_lock.test.py:test_a_leftover_that_ends_just_as_it_is_checked_is_collected_before_the_lock_is_free. It drivesend_the_restin-process and makes the leftover end in exactly that window. It fails on the first commit (the leftover is still the wrapper's zombie) and passes with the fix.alive()now also countsX(being collected) as gone.Tests
python3 fork-ci/actions/nightly-lock/nightly_lock.test.py: 30 tests OK, 20 of 20 runs clean (~18 s per run, so the weight of ~16s stays).🤖 Generated with Claude Code