Repository navigation
fix(dash-spv): keep the data-directory lock file on drop off Unix - #1263
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Lock-file lifecycle by platform dash-spv/src/storage/lockfile.rs, dash-spv/src/storage/mod.rs, CHANGELOG.md |
Lock drops remove the file on Unix and retain it on non-Unix platforms. Tests check file retention and PID recording after reacquisition on non-Unix platforms, and removal on Unix. The changelog records the non-Unix behavior. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- dashpay/rust-dashcore#1257: Changes the same lock lifecycle, including truncation after lock acquisition and behavior when a locked file path is unlinked.
- dashpay/rust-dashcore#1178: Addresses the same lifecycle from the client shutdown side by waiting for detached tasks that retain the storage lock.
Suggested reviewers: zocolini
Merge Risk: 
Minimal · previous review 0e602
-
No actionable merge-blocking issue remains; normal Windows CI validation should complete before release.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
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.
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Bots are done — your move: post |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1263 +/- ##
==========================================
+ Coverage 80.70% 80.71% +0.01%
==========================================
Files 291 291
Lines 77763 77764 +1
==========================================
+ Hits 62755 62767 +12
+ Misses 15008 14997 -11
|
|
/self-reviewed |
|
Ready for review — files with no dedicated owner: QuantumExplorer or ZocoLini or xdustinface · |
xdustinface
left a comment
There was a problem hiding this comment.
-
Gate
pathandDropon Unix instead of suppressingdead_code. Off Unix,LockFile::pathis only read inDrop, whose body is now empty there, so#[cfg_attr(not(unix), allow(dead_code))]just hides a dead field. Put#[cfg(unix)]on thepathfield, on thepath,initialiser inLockFile::new, and on the wholeimpl Drop for LockFile, and drop the inner#[cfg(unix)]onremove_file. I checked this locally: clippy with-D warningsand the storage tests pass on Unix, and a cfg-flipped build oflockfile.rsis clean on the non-Unix side too. OnceDroponly exists on Unix, the Windows explanation in its doc comment should move to theLockFilestruct doc, and the non-Unixis_atdoc should stop pointing atLockFile'sDrop. -
Drop
test_lock_file_kept_on_drop, it adds no coverage. Its "file stays" assert is already intest_lock_lifecycle(the#[cfg(not(unix))]assert you added instorage/mod.rs), and re-acquiring after drop is covered on every platform bytest_lock_released_on_drop. Theread_pidassert can't show a takeover either: both holders are the same process, so the PID matches whether or not the file was truncated (a_stale_lock_file_holds_only_the_new_pidcovers truncation). Instead, turntest_lock_file_removed_on_dropinto one test for all platforms with#[cfg(unix)] assert!(!lock_path.exists())and#[cfg(not(unix))] assert!(lock_path.exists()), the same split you used intest_lock_lifecycle.
|
Bots are done — your move: address xdustinface requested changes, then post |
0e60269 to
4b3f047
Compare
|
Thanks, both done in 4b3f047. The 🤖 Posted autonomously by Claude on behalf of pasta. |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
4b3f047 to
4c4582f
Compare
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
LockFile's Drop deleted the lock file while still holding the lock. On Unix an opener that locked the deleted file notices (device and inode no longer match the path) and opens again; elsewhere std exposes no file identity on stable Rust to compare. On Windows, deleting a file that is still open either frees the name at once (POSIX semantics), so an opener holding the deleted file and a later opener of a new file at the path could both hold the lock, or leaves it delete-pending, so a later opener fails to open the path until the old handles close. Off Unix the file now stays: unless something else deletes or replaces it, every opener opens the same file and the OS lock excludes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
4c4582f to
77d1f7a
Compare
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
Follow-up to #1257. On Unix,
LockFile'sDropdeletes the lock file while it still holds the lock. An opener that locks a deleted file then notices, because its file's device and inode no longer match the file at the path, and it opens again. On Windows that check is skipped: std exposes no file identity there on stable Rust. Depending on the Windows version and file system, deleting a file that is still open either frees the name at once (POSIX semantics) or leaves the file delete-pending until its last handle closes. With POSIX semantics, an opener that opened the old file can lock it after the holder drops it, while a later opener creates and locks a new file at the same path, and both hold the lock. With delete-pending, a later opener fails to open the path until the earlier handles close, instead of being refused by the lock.Off Unix, the lock file is now kept on drop instead. As long as nothing else deletes or replaces it, every opener opens the same file, so the OS lock alone excludes them. The next holder truncates the file once it has the lock and writes its PID, as before.
Tests:
test_lock_file_removed_on_dropruns on every platform: it asserts that the file is removed after drop on Unix and that it stays elsewhere.test_lock_lifecycleinstorage/mod.rsasserts removal on Unix and presence elsewhere.-D warningspasses for the workspace and forx86_64-pc-windows-gnuwith--all-targets. The Windows side runs in CI's Windows job.🤖 Generated with Claude Code
PR Hygiene ·
77d1f7a/skip-botsproceeds without the ones not yet reported/self-reviewedCHANGELOG.md) — QuantumExplorer or ZocoLini or xdustinfacedash-spv(dash-spv/src/storage/lockfile.rs,dash-spv/src/storage/mod.rs) — QuantumExplorer or ZocoLini or xdustinfaceWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.