Skip to content

fleet/tests: exclusive-create claim-race stub lock (uutils mkdir is not exclusive) - #5212

Merged
jakildev merged 1 commit into
masterfrom
claude/5208-claim-race-stub-lock
Nov 20, 2026
Merged

jakildev merged 1 commit into
masterfrom
claude/5208-claim-race-stub-lock

Conversation

@jakildev

@jakildev jakildev commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes the chronic test_fleet_claim_cross_lane.sh / test_fleet_claim_acquire_race.sh reds on master: the gh stubs' state lock was a mkdir mutex, and the CI runner's mkdir is not exclusive.

ubuntu-latest is now the ubuntu-26.04 image, whose /usr/bin/mkdir is uutils coreutils 0.10.0 (/usr/bin/mkdir -> ../lib/cargo/bin/coreutils/mkdir). When two processes create the same directory at the same moment, uutils mkdir can report success to both. Two stub calls then end up inside the "locked" section together. One of them rmdirs the other's lock, and the second rmdir fails under set -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 with O_CREAT|O_EXCL, so it doesn't depend on the coreutils implementation. lib_claim_race.sh gains race_unlock beside race_lock. test_fleet_claim_amending_cleanup_race.sh hand-rolls the same mkdir lock without the lib, so it gets the same primitive inline.

Closes #5208

Evidence

All CI runs below were workflow_dispatch runs of a throwaway diagnostic branch on the same ubuntu-26.04 runner image.

Criterion Result Evidence
Root cause: uutils mkdir is not exclusive under a concurrent create PASS (reproduced) Run 44593043736, 3000 two-way races per primitive: coreutils mkdir: both-succeeded 14 / 3000, python os.mkdir: 0 / 3000, bash noclobber: 0 / 3000; mkdir (uutils coreutils) 0.10.0
The failing suites hit exactly that double hold PASS (reproduced) Run 44591580578, an instrumented stub with 25× loops of both suites: 3/50 failed. The lock log shows LOCK pid=35237 cl=amend and LOCK pid=35236 cl=review 64 µs apart, then DIAG rmdir failed pid=35236
Master's failed suite passes with the fix PASS Run 44595059271, the three claim-race suites looped 40× on the fix, same uutils runner: total failures: 0 / 120
No regression in the claim suites PASS bash scripts/fleet/tests/run_all.sh --only claim (macOS): 48 suites, 48 passed

Not in this PR

Production fleet scripts use the same mkdir-as-mutex pattern: the claim lock and amend lock in fleet-claim, plus locks in fleet-dispatcher, fleet-rebase, fleet-gh-token, fleet-queue-ingest, and fleet-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 an rmdir that refuses while a successor's token is present). Filed as #5211.

Open-PR overlap

fleet-pr-overlap (self = this PR):

#5122 scripts/fleet/tests/test_fleet_claim_cross_lane.sh clean
#5127 scripts/fleet/tests/lib_claim_race.sh sequenced (Parked-until: #5208)
#5127 scripts/fleet/tests/test_fleet_claim_acquire_race.sh sequenced (Parked-until: #5208)
#5127 scripts/fleet/tests/test_fleet_claim_cross_lane.sh sequenced (Parked-until: #5208)
VERDICT: overlap

#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.sh keeps no mkdir mutex of its own (mkdir -p only). The conflict is that both PRs edit lock_state/unlock_state in the two suites.

🤖 Generated with Claude Code

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 jakildev added fleet:wip Work in progress — not ready for review fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend and removed fleet:wip Work in progress — not ready for review labels Nov 19, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge and removed fleet:reviewing-mac-pool-3 labels Nov 19, 2026
@jakildev
jakildev merged commit 3ced0c4 into master Nov 20, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

master red: fleet-tests.yml

1 participant