docs: document single-writer transaction requirement#617
Conversation
GroveDb uses RocksDB's OptimisticTransactionDB which permits multiple concurrent transactions but only detects write conflicts at commit time. Since GroveDb builds in-memory Merk tree state (hashes, balancing, root propagation) during transactions that cannot be cheaply rolled back on commit failure, callers must ensure at most one write transaction is active at any given time. This adds documentation to: - GroveDb struct: concurrency and transaction safety overview - GroveDb::start_transaction: single-writer requirement details - GroveDb::commit_transaction: failure semantics - GroveDb::rollback_transaction: state invalidation after rollback - Storage trait: single-writer constraint at the trait level - RocksDbStorage struct: optimistic transaction semantics Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #617 +/- ##
========================================
Coverage 90.70% 90.70%
========================================
Files 182 182
Lines 50734 50734
========================================
Hits 46016 46016
Misses 4718 4718
🚀 New features to boost your workflow:
|
|
Yep |
Summary
GroveDbstruct,start_transaction,commit_transaction,rollback_transaction, theStoragetrait, andRocksDbStoragestruct!SynconStorageBatch/MerkCache), RocksDB catches conflicting writes at commit time, and Dash Platform processes blocks sequentiallyAnalysis
GroveDb uses RocksDB's
OptimisticTransactionDBwhich isSend + Sync, makingGroveDbitself shareable across threads. However, there is noMutexorRwLockenforcing single-writer access. The analysis found:OptimisticTransactionDBpermits concurrent transactions but detects write conflicts at commit time (returningBusy/TryAgain)StorageBatchusesRefCell(!Sync) andMerkCacheusesUnsafeCell(!Sync), preventing sharing a single transaction's state across threadsThis is a design constraint that should be documented, not a code fix. Adding a
Mutexwould add unnecessary overhead for the primary use case and change the API contract.Test plan
cargo check -p grovedb -p grovedb-storagecompiles cleanlycargo test --doc -p grovedbpasses (3 doc tests including thestart_transactionexample)🤖 Generated with Claude Code