Repository navigation
fix(test-lock): finish a decided stale retirement through transient rename refusals - #8823
Conversation
…ename refusals The generation-gate holder swallowed an EACCES/EPERM quarantine rename and gave up the gate, so the next waiter retired the lock it had judged stale. Retry the rename inside the gate for a bounded window, stop per-poll owner reads outside the gate, and make the generation worker trace its stages and refuse a silent exit 0.
|
✅ Deterministic PR hygiene checks passed. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Maintainer integration of #8823 at 1deb84e. This repairs the windows 9/14 failure in dev batch run 43832690786 (3c8e1e7):
Next step: one batched |
Fix a latent race in the Bun test-run lock that failed
generation gate prevents duplicate acquisition during stale verdicton Windows (dev batch run 43832690786, windows 9/14, job 133181709470:Private barrier timed out: A.acquired).Stale-lock retirement swallowed an EACCES/EPERM rename refusal and gave up the generation gate. The next waiter then retired the lock that the gate holder had already judged stale.
Root cause: child A held the generation gate while it decided the seeded lock was stale. When A then tried to move the stale lock directory aside, the rename was refused once.
reclaimStaleLocktreated EACCES/EPERM as "not now", returned false and dropped the gate. B, polling every 10 ms, entered the gate, retired the stale lock itself and acquired. A then waited behind a live owner (B). The fixture's cleanup wroteB.release, which let A acquire, and both children exited 0. The CI log matches this: bothlockChildTerminallines are printed byfinish()after the barrier threw, and the worker's only exit-0 path writesA.acquiredfirst.Mutual exclusion held throughout. The holder of the stale verdict lost the retirement it had decided, and the test asserts that ordering. On Windows, a rename of a directory is refused while any process has a file inside it open. Antivirus can cause that, and so could the lock itself: every waiter read
owner.jsonoutside the gate on each 10 ms poll. In real CI this costs a queue slot or a poll cycle, and the retirement step gave no signal about it.Summary
scripts/test-run-lock.ts: the quarantine rename now retries EACCES/EPERM inside the gate with backoff (5 ms to 100 ms) for up to 2 s while the generation is unchanged. If the rename is still refused after that, it defers as before. Other errors still throw.owner.jsonoutside the gate only to announce the wait or build the timeout message, instead of on every poll.tests/helpers/test-run-lock-generation-worker.ts: the worker traces each stage to stderr, and the fixture prints that with the exit code. An A or B worker that returns without its own generation now throws instead of exiting 0. A private fixture file enables a seam that refuses renames of the lock path for a time window.tests/ci-workflows/test-run-lock-generation.test.ts: a new case,stale verdict through a transient rename refusal, refuses A's rename for 300 ms. A barrier timeout now lists the barrier files present, soB.acquiredwould show up directly. The generation-gate assertions are unchanged.structure/ops/test-sandbox-cleanup.mddocuments both behaviors.Verification
All test runs were single files under
/usr/bin/lockf -k /tmp/ocx-test.lockon macOS. The host was under load, so no full suite was run.Private barrier timed out: A.acquired (present: A.blocked, A.refuse-rename-ms, A.resume, A.waited, B.acquired, B.waited). The traces show B acquired at 24 ms and A acquired at 20061 ms, with both exiting 0. This is the CI signature.bun test tests/ci-workflows/test-run-lock-generation.test.ts: 15 pass, 0 fail. The refusal case passes in 494 ms.bun test tests/ci-workflows/test-runner.test.ts: 92 pass, 0 fail (3 skipped by the file).bun test tests/ci-workflows/test-home-guard.test.ts: 27 pass, 0 fail.file-size-ratchet.test.ts9/9,tests/test-layout.test.ts2/2,structure-ssot.test.ts51/51.bun run typecheck,bun run structure:checkandbun run privacy:scan: passed.NOT RUN: full
bun run test(host load limit), and Windows. Windows evidence will come from the nextlane=allbatch ondev.Checklist
Summary by CodeRabbit
Bug Fixes
Documentation