Repository navigation
fleet/tests: exclusive-create claim-race stub lock (uutils mkdir is not exclusive) - #5212
Merged
Merged
Conversation
The claim-race suites' gh stubs serialized on a `mkdir` lock directory. ubuntu-latest is now ubuntu-26.04, whose /usr/bin/mkdir is uutils coreutils 0.10.0, and that mkdir can report success to both sides of a concurrent create (14 of 3000 races on the runner). Two stub calls then shared the critical section, one rmdir'd the other's lock, and the second rmdir killed its claimant under set -e, so a race schedule ended with no winner. Lock with bash's noclobber redirection instead (O_CREAT|O_EXCL, 0 of 3000 on the same runner), through race_lock/race_unlock in lib_claim_race.sh; the amending x cleanup suite gets the same primitive inline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jakildev
commented
Nov 19, 2026
jakildev
left a comment
Owner
Author
There was a problem hiding this comment.
Review — fleet/tests: exclusive-create claim-race stub lock (uutils mkdir is not exclusive)
Verdict: approve
The replacement lock uses Bash noclobber's exclusive create rather than the concurrent mkdir behavior that made the hermetic stubs flaky. The shared helper keeps acquire and release paired, and the separately implemented cleanup-race stub now uses the same primitive. I found no correctness or test-coverage issue in the scoped change.
Validation
fleet-jobs: 20261119T202406Z-fleet-tests-7b6e82 succeeded exit=0—bash scripts/fleet/tests/run_all.sh --only claim: 48 suites passed.- The PR's head checks are green except the Fleet Tests job, which was still in progress when reviewed; it is not treated as a passing check here.
🤖 Reviewed by Codex (GPT-5, review-pr skill)
Opus recheck not required.
This was referenced Nov 20, 2026
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.
Summary
Fixes the chronic
test_fleet_claim_cross_lane.sh/test_fleet_claim_acquire_race.shreds on master: the gh stubs' state lock was amkdirmutex, and the CI runner'smkdiris not exclusive.ubuntu-latestis now theubuntu-26.04image, whose/usr/bin/mkdiris uutils coreutils 0.10.0 (/usr/bin/mkdir -> ../lib/cargo/bin/coreutils/mkdir). When two processes create the same directory at the same moment, uutilsmkdircan report success to both. Two stub calls then end up inside the "locked" section together. One of themrmdirs the other's lock, and the secondrmdirfails underset -e. That killed a claimant mid-call, so a race schedule ended with zero winners (live labels unavailable/rmdir: failed to remove '…/labels.lock': No such file or directory).The stub lock is now an exclusive-create file (
( set -C; : > lock )). Bash's noclobber opens withO_CREAT|O_EXCL, so it doesn't depend on the coreutils implementation.lib_claim_race.shgainsrace_unlockbesiderace_lock.test_fleet_claim_amending_cleanup_race.shhand-rolls the samemkdirlock without the lib, so it gets the same primitive inline.Closes #5208
Evidence
All CI runs below were
workflow_dispatchruns of a throwaway diagnostic branch on the sameubuntu-26.04runner image.mkdiris not exclusive under a concurrent createcoreutils mkdir: both-succeeded 14 / 3000,python os.mkdir: 0 / 3000,bash noclobber: 0 / 3000;mkdir (uutils coreutils) 0.10.0LOCK pid=35237 cl=amendandLOCK pid=35236 cl=review64 µs apart, thenDIAG rmdir failed pid=35236total failures: 0 / 120bash scripts/fleet/tests/run_all.sh --only claim(macOS): 48 suites, 48 passedNot in this PR
Production fleet scripts use the same
mkdir-as-mutex pattern: the claim lock and amend lock infleet-claim, plus locks infleet-dispatcher,fleet-rebase,fleet-gh-token,fleet-queue-ingest, andfleet-common.sh. On a fleet host with uutils coreutils, those locks are not exclusive either. That needs its own design pass, because the amend lock relies on directory semantics (an owner token inside the lock, and anrmdirthat refuses while a successor's token is present). Filed as #5211.Open-PR overlap
fleet-pr-overlap(self = this PR):#5127 reworks the same race fixtures and is parked waiting for this incident to close, so it rebases onto this change. Its new
lib_claim_race_labels.shkeeps nomkdirmutex of its own (mkdir -ponly). The conflict is that both PRs editlock_state/unlock_statein the two suites.🤖 Generated with Claude Code