fix(setup): recover locks while writers wait - #604
Merged
Merged
Conversation
tt-a1i
approved these changes
Sep 22, 2026
tt-a1i
left a comment
Collaborator
There was a problem hiding this comment.
复审提交 d448dad390bea4daaab8424fd8b09dd823f23655。
未发现阻断问题。等待锁时每 500ms 重新进入既有的 fail-closed 恢复判断,没有放宽活进程、未知 PID 身份或恢复 claim 的所有权规则;新增跨进程用例覆盖了“等待者已经挂起后持锁进程死亡”的原始竞态。当前 Node、Web E2E 和原生 Windows 检查均通过。
验证边界:本结论针对锁等待和恢复路径;不把 PR 描述中在 main 也可复现的 post-edit 全量测试失败归因于本改动。
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.
Problem
A setup writer waiting for
my-pi-setup.json.lockonly wakes on a lock-file event or at the 5-second deadline. If the lock owner dies without removing the lock, the file never changes, so the waiter times out even though the existing stale-lock recovery could reclaim it.This is not the config diagnostics or apply-failure rollback tracked by #498 and implemented in #557. #557 still checks the lock only at the deadline. No open PR covers this waiting-writer-after-owner-death sequence. There is no existing Issue for this exact timing.
Value
A Pi process killed while holding the setup lock no longer blocks the next configuration write for the full timeout. The next writer can recover inside the existing 5-second budget instead of failing a save that is already safe to retry.
Approach
Wake the waiter every 500ms, and at the deadline, then retry the existing fail-closed
recoverStaleSetupConfigLockpath. Lock ownership rules are unchanged: a live owner is never stolen, and an owner whose PID identity is unknown is not reclaimed. The periodic wake only gives the existing recovery another chance to run.Validation
bun run checkpassed ond448dad: config contract, docs contract, discipline ledger, web build, Biome format, Biome lint, andtsc --noEmit.node --test --experimental-strip-types tests/extensions/shared/setup-config.test.ts: 21/21 passed, including the new cross-process regression where writer B is already waiting when owner A dies and B recovers within the original deadline.bun run testdid not complete. It stopped intests/extensions/post-edit/lifecycle.test.ts: seven real-Pi cases timed out at 15 seconds and one assertion failed. The same file fails the same way on unmodifiedmainat6132d99, so this is a baseline failure, not a regression from this change. Those tests were not modified.Impact