Repository navigation
fix(storage): retry a writer lock that names our own pid (#552) - #557
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Nov 11, 2026
3 tasks
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.
What
lock_writernow retries for up to 150 ms (5 ms steps) when the writer lock is held and the recorded holder is our own pid.Why
Fixes #552. An
flockbelongs to the open file description, so a child forked by another thread of the same process (a command, job or hook) briefly holds a duplicate of our lock descriptor until it execs, even withO_CLOEXEC. A reopen right afterdrop(storage)in that window failed withLocked { holder: <our pid> }. It caused a spurious409onPOST /sessions {"resume"}, failures in the TUI/resumeand/new, and two flakytole-coretests.Changes
crates/tole-core/src/storage.rs: bounded retry inlock_writer, only for a hold that names our own pid. A holder with another pid still fails at once, and a genuine second open in this process (storage: no cross-process writer exclusion — a second writer corrupts the session file (live repro) #475) still fails after at most the bounded wait. The lock file is re-read from the start on each attempt.crates/tole-core/tests/writer_lock.rs: the probe from the issue as a regression test, plus a test that both real refusals stay (other pid: under 50 ms; same process: bounded).Testing
cargo fmt,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepass.Closes #552
Generated by Claude Code