Repository navigation
fix(dash-spv): keep the data-directory lock exclusive - #1257
Conversation
LockFile::new truncated the lock file when it opened it, before try_lock, so a refused open erased the holder's PID. Open without truncating and empty the file only once the lock is ours. Drop unlinks the file before the lock is released, so an opener that opened the file earlier could lock the unlinked inode while a later opener created and locked a new file at the path: two holders of one data directory. On Unix the locked file must now be the one at the path (same device and inode), otherwise the open is retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Lock acquisition and validation dash-spv/src/storage/lockfile.rs, CHANGELOG.md |
LockFile::new opens without truncation, checks file identity on Unix, and retries if the path no longer refers to the opened file. It truncates and writes the PID only after acquiring the lock. Tests cover stale contents, refused locks, and an unlinked-file case. The changelog records these changes. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Merge Risk: 
Minimal · up to 14c74
-
The change keeps the data-directory lock exclusive by no longer truncating a holder's PID file on refused opens and by rechecking file identity on Unix. No merge-blocking issue was found; the only remaining gap is a minor, existing PID-file behavior on platforms without advisory locking.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 75.00% which is insufficient. 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 4 functions across 1 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
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 |
|
@coderabbitai review 🤖 Posted autonomously by Claude on behalf of pasta. |
Action performed
|
|
Bots are done — your move: post |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1257 +/- ##
=======================================
Coverage 80.49% 80.50%
=======================================
Files 291 291
Lines 77412 77463 +51
=======================================
+ Hits 62312 62360 +48
- Misses 15100 15103 +3
|
|
/self-reviewed |
|
Ready for review — files with no dedicated owner: QuantumExplorer or ZocoLini or xdustinface · |
The data-directory lock in
dash-spv(storage/lockfile.rs) has two gaps:LockFile::newopens the lock file withtruncate(true)before it callstry_lock. A second process that's refused the lock has already emptied the holder's file and erased its PID.Dropremoves the file while the lock is still held. A process that opened the file just before then can lock the now-unlinked inode, while a third process creates a new file at the path and locks that. Both think they own the data directory.The fix:
Testing:
a_refused_lock_leaves_the_holders_file: it fails ondev(the holder's PID is gone after a refused open) and passes here.a_lock_on_an_unlinked_file_is_not_helddrives the open/drop/lock interleaving directly. It fails if the inode check is disabled.cargo test -p dash-spvpasses, including the dashd regtest integration tests, as docargo clippy --workspace --all-features --all-targets -- -D warningsandcargo fmt --check.🤖 Generated with Claude Code
PR Hygiene ·
14c744bCHANGELOG.md) — QuantumExplorer or ZocoLini or xdustinfacedash-spv(dash-spv/src/storage/lockfile.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.Summary by CodeRabbit