npx skills add https://github.com/tursodatabase/turso --skill mvcc多版本并发控制。开发中,尚未达到生产就绪状态。
重要提示:调试时请忽略 MVCC,除非错误是 MVCC 特有的。
PRAGMA journal_mode = 'mvcc';
此为运行时配置,非编译时功能标志。按数据库设置。
标准 WAL:每页单一版本,读取者在读取标记时间看到快照。
MVCC:多行版本,快照隔离。每个事务在开始时看到一致的快照。
| 方面 | WAL | MVCC |
|---|---|---|
| 写入粒度 | 每次提交写入完整页面 | 仅受影响的行 |
| 读取者/写入者 | 互不阻塞 | 互不阻塞 |
| 持久化 | .db-wal | .db-log(逻辑日志) |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 隔离级别 | 快照(页面级) | 快照(行级) |
每个行版本追踪:
begin - 变为可见时的时间戳end - 被删除/替换时的时间戳btree_resident - 在启用 MVCC 前已存在Database
└─ mv_store: MvStore
├─ rows: SkipMap<RowID, Vec<RowVersion>>
├─ txs: SkipMap<TxID, Transaction>
├─ Storage (.db-log file)
└─ CheckpointStateMachine
每个连接:mv_tx 追踪当前的 MVCC 事务。
共享:MvStore 包含无锁的 crossbeam_skiplist 结构。
core/mvcc/mod.rs - 模块概览core/mvcc/database/mod.rs - 主要实现(约 3000 行)core/mvcc/cursor.rs - 合并的 MVCC + B 树游标core/mvcc/persistent_storage/logical_log.rs - 磁盘格式core/mvcc/database/checkpoint_state_machine.rs - 检查点逻辑定期将行版本刷新到 B 树。
PRAGMA mvcc_checkpoint_threshold = <pages>;
流程:获取锁 → 开始分页事务 → 写入行 → 提交 → 截断日志 → 同步到磁盘 → 释放锁。
未实现:
已知问题:
# 运行 MVCC 特定测试
cargo test mvcc
# 使用 MVCC 的 TCL 测试
make test-mvcc
使用 #[turso_macros::test(mvcc)] 属性来运行启用 MVCC 的测试。
#[turso_macros::test(mvcc)]
fn test_something() {
// 在启用 MVCC 的情况下运行
}
core/mvcc/mod.rs 记录了数据异常(脏读、更新丢失等)每周安装量
361
代码仓库
GitHub 星标数
17.9K
首次出现
2026年1月28日
安全审计
安装于
claude-code286
github-copilot166
opencode102
codex101
gemini-cli101
cursor97
Multi-Version Concurrency Control. Work in progress, not production-ready.
CRITICAL : Ignore MVCC when debugging unless the bug is MVCC-specific.
PRAGMA journal_mode = 'mvcc';
Runtime configuration, not a compile-time feature flag. Per-database setting.
Standard WAL: single version per page, readers see snapshot at read mark time.
MVCC: multiple row versions, snapshot isolation. Each transaction sees consistent snapshot at begin time.
| Aspect | WAL | MVCC |
|---|---|---|
| Write granularity | Every commit writes full pages | Affected rows only |
| Readers/Writers | Don't block each other | Don't block each other |
| Persistence | .db-wal | .db-log (logical log) |
| Isolation | Snapshot (page-level) | Snapshot (row-level) |
Each row version tracks:
begin - timestamp when visibleend - timestamp when deleted/replacedbtree_resident - existed before MVCC enabledDatabase
└─ mv_store: MvStore
├─ rows: SkipMap<RowID, Vec<RowVersion>>
├─ txs: SkipMap<TxID, Transaction>
├─ Storage (.db-log file)
└─ CheckpointStateMachine
Per-connection : mv_tx tracks current MVCC transaction.
Shared : MvStore with lock-free crossbeam_skiplist structures.
core/mvcc/mod.rs - Module overviewcore/mvcc/database/mod.rs - Main implementation (~3000 lines)core/mvcc/cursor.rs - Merged MVCC + B-tree cursorcore/mvcc/persistent_storage/logical_log.rs - Disk formatcore/mvcc/database/checkpoint_state_machine.rs - Checkpoint logicFlushes row versions to B-tree periodically.
PRAGMA mvcc_checkpoint_threshold = <pages>;
Process: acquire lock → begin pager txn → write rows → commit → truncate log → fsync → release.
Not implemented:
Known issues:
# Run MVCC-specific tests
cargo test mvcc
# TCL tests with MVCC
make test-mvcc
Use #[turso_macros::test(mvcc)] attribute for MVCC-enabled tests.
#[turso_macros::test(mvcc)]
fn test_something() {
// runs with MVCC enabled
}
core/mvcc/mod.rs documents data anomalies (dirty reads, lost updates, etc.)Weekly Installs
361
Repository
GitHub Stars
17.9K
First Seen
Jan 28, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code286
github-copilot166
opencode102
codex101
gemini-cli101
cursor97
GSAP React 动画库使用指南:useGSAP Hook 与最佳实践
1,700 周安装