Skip to content

test(config): rerun an uninstall refused by a busy lock in the ownership race test - #8822

Merged
lidge-jun merged 1 commit into
devfrom
fix/ownership-uninstall-race
Nov 16, 2026
Merged

lidge-jun merged 1 commit into
devfrom
fix/ownership-uninstall-race

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes the macOS failure in dev batch run 43832690786 (job 133181708969): config-ownership-concurrent-record.test.ts > "a registration racing uninstall is either removed or refused, never left unreported" failed at if (codes[i] === 0) expect(existsSync(path)).toBe(false).

The race was in the test. In the product, removeOwnedConfigState waits at most 50 ms for the ownership lock and then returns refused ("could not lock the ownership manifest: … busy …") without writing anything. In the test, the six gated children keep contending for that lock after the barrier releases it, so a loaded runner can make the single uninstall call lose. Every child then records its path and exits 0, the refused uninstall reports only the home directory as residual, and the assertion fails. The failing test ran for 208 ms, about one lock wait plus the children finishing. That busy refusal is reported and leaves no tombstone, so it does not break the #8093 contract. Under the lock, a registration either lands in the snapshot the uninstall removes, is refused by the tombstone (exit 3), or finds the metadata gone and stays unrecorded (exit 2, reported as residual).

The test now reruns an uninstall that was refused as busy, the way a user retries. After each busy refusal it asserts that the run left no tombstone. A second case holds the barrier lock through the first uninstall run, so the busy refusal happens on every run instead of depending on scheduling. Both cases keep the original contract assertion and add two checks: the final result is not refused, and the forced case actually saw a busy refusal. No product code changes.

Verification

All test runs used /usr/bin/lockf -k /tmp/ocx-test.lock and single files only, because the host is under heavy load.

  • Before the fix: the new forced case with the old single removeOwnedConfigState call fails at the same assertion and call stack as CI (Expected: false, Received: true inside names.forEach).
  • bun test tests/config/config-ownership-concurrent-record.test.ts: 60 pass, 0 fail.
  • bun test tests/config/config-ownership-concurrent-record.test.ts -t 'racing uninstall' repeated 20 times: 20 pass, 0 fail.
  • bun run typecheck: no type errors.
  • bun test tests/ci-workflows/file-size-ratchet.test.ts, tests/test-layout.test.ts, tests/test-layout-tooling.test.ts: all pass.
  • Not run: the full suite, bun run test:changed, macOS/Windows CI lanes. ci:full is requested for the PR run.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (None needed; test-only change.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (No security-sensitive surface touched.)

Summary by CodeRabbit

  • Tests
    • Expanded coverage for uninstall behavior when configuration ownership changes concurrently, including retries while a lock is busy and verification of cleanup outcomes.

…the racing test

The racing children can hold the ownership lock past the uninstall's 50 ms wait on a loaded runner; the refused run writes nothing, but the test read it as a contract break. Rerun busy refusals and add a case that forces one deterministically.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 16, 2026 09:12
@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T09:13:40.264851Z 6eb809e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The concurrent registration-versus-uninstall test now retries busy-lock refusals and checks that refused attempts do not write an uninstall timestamp. It covers cases where the held lock is released before uninstall or after the first busy refusal.

Changes: Uninstall retry test

Layer / File(s) Summary
Retry helper and lock scenarios
tests/config/config-ownership-concurrent-record.test.ts
uninstallRetryingBusyLock retries busy-lock refusals until a non-busy result or the BARRIER_MS deadline. The test covers early lock release and a forced busy refusal, while retaining the child outcome and residual-path checks.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 6eb80

This is a test-only change that makes a flaky concurrency test retry when the lock is busy. It has no production impact, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test file's subject (config ownership race test) and the change (rerunning an uninstall refused by a busy lock), which matches the raw summary's retry helper and the PR objectives.…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the test file's subject (config ownership race test) and the change (rerunning an uninstall refused by a busy lock), which matches the raw summary's retry helper and the PR objectives. It is specific, concise, and follows the test(config) convention. No unrelated content is present.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3c8e1e7 and 6eb809e.

Files selected for processing: 1

  • tests/config/config-ownership-concurrent-record.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration of #8822 at 6eb809e.

This repairs the macos 3/4 failure in dev batch run 43832690786 (3c8e1e7): config-ownership-concurrent-record.test.ts > "a registration racing uninstall…", where a child exited 0 but its file remained.

  • Cause (traced in the code; the product is correct): removeOwnedConfigState waits at most 50 ms for a busy ownership lock. If it can't get the lock, it refuses ("could not lock the ownership manifest: … busy") and writes nothing, which is the documented retry outcome. The test released its barrier lock and called uninstall once while six children kept trying to take that same lock. On a loaded runner the uninstall lost, and the children registered and exited 0. The failing case took 208 ms, which matches one lock wait.
  • Fix (test only): the uninstall is retried after a busy refusal, as a user would. After each refusal the test asserts that no tombstone was written. A second case forces the busy refusal. All original assertions are kept, and new ones require a final status other than refused and, in the forced case, at least one busy refusal.
  • Evidence: with the old single call, the forced case fails at CI's assertion and stack. With the fix, the file passes 60/60 and the race cases pass 20/20 repeats. Typecheck and the layout and ratchet guards pass.
  • CI on this exact head: all 31 checks passed, including test 1–5/5 (ci:full) and enforce-target. assert-mergeable-review: OK.

The windows 9/14 failure in the same run is repaired separately in #8823. One batched lane=all follows once both have merged.

@lidge-jun
lidge-jun merged commit 3a84020 into dev Nov 16, 2026
38 of 39 checks passed
@lidge-jun
lidge-jun deleted the fix/ownership-uninstall-race branch November 16, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). ci:full Run the four full Ubuntu test shards on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant