MVCC & Transactions
Concurrent access and isolation
KiteDB supports concurrent transactions using Multi-Version Concurrency Control (MVCC). Multiple readers can access the database simultaneously without blocking each other or writers.
Snapshot Isolation
Each transaction sees a consistent snapshot of the database as it existed when the transaction started. Other transactions' uncommitted changes are invisible.
Snapshot Isolation Timeline
T2 still sees v1 — T1's changes are invisible until T2 restarts
Version Chains
When data is modified while readers exist, KiteDB keeps old versions in a chain:
Version Chain for Node "alice"
Each transaction follows the chain to find the version committed before it started.
Visibility Rules
Visibility Rules
A version is visible to transaction T if:
version.commitTs <= T.startTsVersion was committed before T started
version.txid == T.txidT created this version itself (read-your-own-writes)
Walk the chain from newest to oldest.
Return first visible version.
If none visible → entity doesn't exist for this transaction.
Write Conflicts
KiteDB uses First-Committer-Wins to handle conflicts:
First-Committer-Wins
Scenario: Both T1 and T2 modify "alice"
T1 commits first (ts=110)
Succeeds — no conflict
T2 tries to commit (ts=115)
Was "alice" modified after T2.startTs (105)? Yes!
Rolled back with ConflictError
Resolution: T2 must retry with fresh read
Lazy Version Chains
Version chains are only created when necessary. If there are no concurrent readers, modifications happen in-place without versioning overhead.
Lazy MVCC Optimization
When T1 modifies "alice":
No other transactions are active
→ Modify in-place (no version chain)
Other transactions are active
→ Create version chain (preserve old value)
Result: Serial workloads have zero MVCC overhead. Concurrent workloads get correct isolation.
Garbage Collection
Old versions are cleaned up when no transaction can see them:
Garbage Collection
minStartTs)commitTs >= minStartTsTriggered:
- • After transaction commits
- • Periodically in background
Note: Long-running transactions delay GC and hold memory.
Transaction API
Next Steps
- WAL & Durability – How commits are made durable
- Transactions Guide – Practical usage patterns
- Concurrency Guide – Multi-threaded access