How WAL mechanics, checkpointing, concurrency rules, recovery work in tursodb
Turso uses WAL (Write-Ahead Logging) mode exclusively.
Files: .db, .db-wal (no .db-shm - Turso uses in-memory WAL index)
Transfers WAL content back to main DB.
WAL grows → checkpoint triggered (default: 1000 pages) → pages copied to DB → WAL reused
Checkpoint types:
SQLite uses a shared memory file (-shm) for WAL index. Turso does not - it uses in-memory data structures (frame_cache hashmap, atomic read marks) since multi-process access is not supported.
On crash:
Key files:
Per-Connection (private):
Pager - page cache, dirty pages, savepoints, commit stateWalFile - connection's snapshot view:
max_frame / min_frame - frame range for this connection's snapshotmax_frame_read_lock_index - which read lock slot this connection holdslast_checksum - rolling checksum stateShared across connections:
WalFileShared - global WAL state:
frame_cache - page-to-frame index (replaces .shm file)max_frame / nbackfills - global WAL progressread_locks[5] - read mark slots (TursoRwLock with embedded frame values)write_lock - exclusive writer lockcheckpoint_lock - checkpoint serializationfile - WAL file handleDatabaseStorage - main .db fileBufferPool - shared memory allocationSpring Boot中的JPA/Hibernate模式,用于实体设计、关系处理、查询优化、事务管理、审计、索引、分页和连接池。