1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Multi-Version Concurrency Control (MVCC)
//!
//! This module implements MVCC for KiteDB, enabling snapshot isolation for
//! concurrent transactions. MVCC allows multiple transactions to read data
//! concurrently without blocking each other, while maintaining consistency.
//!
//! # Concurrency Model
//!
//! KiteDB supports two levels of concurrency:
//!
//! ## 1. RwLock-based Concurrent Reads
//!
//! At the API level (Ray, NAPI bindings, Python bindings), read operations
//! use a shared read lock (`RwLock::read()`), allowing multiple concurrent
//! readers. Write operations use an exclusive write lock (`RwLock::write()`).
//!
//! ```text
//! ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
//! │ Reader 1 │ │ Reader 2 │ │ Reader 3 │
//! │ (shared) │ │ (shared) │ │ (shared) │
//! └──────┬──────┘ └──────┬──────┘ └──────┬──────┘
//! │ │ │
//! └───────────────────┼───────────────────┘
//! │
//! ┌──────▼──────┐
//! │ RwLock │
//! │ (shared) │
//! └──────┬──────┘
//! │
//! ┌──────▼──────┐
//! │ KiteDB │
//! └─────────────┘
//! ```
//!
//! ## 2. MVCC Transaction Isolation
//!
//! When MVCC is enabled, transactions get snapshot isolation:
//! - Each transaction sees a consistent snapshot from its start time
//! - Concurrent transactions can read without blocking
//! - Conflicts are detected at commit time (optimistic concurrency)
//!
//! # Components
//!
//! - [`tx_manager`] - Transaction lifecycle management (begin, commit, abort)
//! - [`version_chain`] - Version chain storage for nodes, edges, and properties
//! - [`visibility`] - Visibility rules for determining which versions a transaction can see
//! - [`gc`] - Garbage collection for old versions
//! - [`conflict`] - Conflict detection for optimistic concurrency control
//!
//! # Conflict Types
//!
//! - **Read-Write Conflict**: Transaction read a key modified by a concurrent committed transaction
//! - **Write-Write Conflict**: Transaction wrote a key also written by a concurrent committed transaction
//!
//! See [`ConflictDetector`] for conflict detection APIs.
// Re-export main types for convenience
pub use ;
pub use ;
pub use MvccManager;
pub use ;
pub use ;
pub use ;