fix(drive,daemon,gmail,docs): move the lease ledger lock to flock - #1712
Merged
Merged
Conversation
The lock guarding the Drive lease ledger and gmail insert's ledger was a create_new marker released by Drop unlinking it by path. That made it ledger-global and non-waiting (an unrelated concurrent leased write hard failed instead of queuing), left a permanent lock behind a SIGKILLed holder with no stale-lock detection, and its own "remove the lock file and retry" advice let a second acquirer's marker be deleted by the first holder's Drop with no identity check, reopening a lease-token double-spend. drive lease prune also deleted a row's backup before securing the lock that would record its removal, so a lock collision could strand a row pointing at an already-deleted backup and abort the rest of the batch. Move to flock(2) on a persistent sibling <path>.lock file, kernel-released on process death, so Drop never unlinks anything and a crashed holder never leaves a stale lock. Every leased write now waits for a busy lock instead of failing outright; prune now takes its lock before touching a row's backup, so a collision leaves both untouched instead of stranding one. gmail insert's identical lock gets the same fix but stays non-waiting, since it is held for a whole multi-message run. The new FileLock primitive lives in src/daemon/paths.rs, shared by both ledgers. Fixes #1687.
…lter for issue #1687 The new flock regression test used nix's Unix-only flock symbols with no #[cfg(unix)], breaking the Windows build. The "waiting for lock" notice was emitted via tracing::info!, which the CLI's default `warn` filter silently drops, contradicting the documented "prints a one-line notice" behavior — switched to tracing::warn! to match the module's existing convention. Doc comments and the CHANGELOG entry claimed "Drop never unlinks the lock file" unconditionally; non-Unix falls back to the old marker-plus-unlink scheme, so that guarantee is Unix-only — callouts added.
CoverageTotal: 97.27% ⚪ -0.01 pp vs Comparing
🔇 5 ignored region(s), 0 tolerated region(s)
Patch coveragePatch: 89.55% (197/220 new lines covered)
Uncovered new lines (23)
Indirect coverage changes🔴 1 lines lost coverage, 🟢 0 lines gained coverage on unchanged code. Indirect changes
|
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.
Summary
create_new-marker-plus-Drop-unlink lock with a persistent-siblingflock(2)lock, closing a lease-token double-spend window and adding wait-instead-of-hard-fail semantics for concurrent leased writes.drive lease prunenow secures the lock before touching a row's backup, not after.gmail insert's own ledger lock.Test plan
cargo buildcargo test --lib drive::lease::ledger(27 passed)cargo clippy --all-targets -- -D warnings/code-review high; fixed the findings (missing#[cfg(unix)]on a new Windows-breaking test, atracing::info!notice silently dropped by the CLI's defaultwarnfilter, and doc/CHANGELOG claims aboutDropnever unlinking that didn't carve out the non-Unix fallback)