
Transaction Correctness
- 925 installs
- 23.5k repo stars
- Updated July 28, 2026
- tursodatabase/turso
transaction-correctness is a Turso database skill that explains WAL-based transaction mechanics so developers who write concurrent SQLite-compatible code can avoid consistency bugs.
About
transaction-correctness is a reference skill from tursodatabase/turso that documents how Turso's exclusive Write-Ahead Logging (WAL) model handles commits, reads, checkpoints, and recovery. Turso stores data in `.db` and `.db-wal` files and uses an in-memory WAL index instead of a `.db-shm` shared-memory file. The guide walks through the write path where writers append frames and COMMIT marks the transaction end, plus the read path where readers acquire a read mark and merge WAL frames with the main database for a consistent snapshot. Developers reach for transaction-correctness when implementing concurrent writers, diagnosing stale reads, or reasoning about checkpoint timing in embedded Turso deployments.
- Explains WAL write and read paths with frame mechanics and commit rules
- Details four checkpoint types: PASSIVE, FULL, RESTART, TRUNCATE
- Clarifies Turso's in-memory WAL index replacing the -shm file
- Outlines strict concurrency rules (single writer, non-blocking readers)
- Provides recovery and snapshot isolation behavior for reliable transaction design
Transaction Correctness by the numbers
- 925 all-time installs (skills.sh)
- +45 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Ranked #91 of 923 Databases skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/tursodatabase/turso --skill transaction-correctnessAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 925 |
|---|---|
| repo stars | ★ 23.5k |
| Security audit | 3 / 3 scanners passed |
| Last updated | July 28, 2026 |
| Repository | tursodatabase/turso ↗ |
How does Turso WAL handle concurrent reads and writes?
Correctly reason about Turso's WAL-based transaction model when writing concurrent database code or debugging consistency issues.
Who is it for?
Backend developers integrating Turso who need precise WAL concurrency semantics before shipping multi-writer or high-read workloads.
Skip if: Developers on non-Turso databases or teams only needing basic CRUD without concurrency or consistency debugging.
When should I use this skill?
The user writes concurrent Turso transactions, sees consistency anomalies, or asks how WAL checkpointing and read marks work.
What you get
Correct mental model of Turso WAL commits, read marks, checkpoint timing, and `.db`/`.db-wal` file behavior for concurrent code.
- Concurrency-safe transaction design
- WAL debugging rationale
By the numbers
- Turso uses two on-disk WAL artifacts: `.db` and `.db-wal` (no `.db-shm`)
Files
Transaction Correctness Guide
Turso uses WAL (Write-Ahead Logging) mode exclusively.
Files: .db, .db-wal (no .db-shm - Turso uses in-memory WAL index)
WAL Mechanics
Write Path
1. Writer appends frames (page data) to WAL file (sequential I/O) 2. COMMIT = frame with non-zero db_size in header (marks transaction end) 3. Original DB unchanged until checkpoint
Read Path
1. Reader acquires read mark (mxFrame = last valid commit frame) 2. For each page: check WAL up to mxFrame, fall back to main DB 3. Reader sees consistent snapshot at its read mark
Checkpointing
Transfers WAL content back to main DB.
WAL grows → checkpoint triggered (default: 1000 pages) → pages copied to DB → WAL reusedCheckpoint types:
- PASSIVE: Non-blocking, stops at pages needed by active readers
- FULL: Waits for readers, checkpoints everything
- RESTART: Like FULL, also resets WAL to beginning
- TRUNCATE: Like RESTART, also truncates WAL file to zero length
WAL-Index
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.
Concurrency Rules
- One writer at a time
- Readers don't block writer, writer doesn't block readers
- Checkpoint must stop at pages needed by active readers
Recovery
On crash: 1. First connection acquires exclusive lock 2. Replays valid commits from WAL 3. Releases lock, normal operation resumes
Turso Implementation
Key files:
- WAL implementation - WAL implementation
- Page management, transactions
Connection-Private vs Shared
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 state
Shared across connections:
WalFileShared- global WAL state:frame_cache- page-to-frame index (replaces.shmfile)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.dbfileBufferPool- shared memory allocation
Correctness Invariants
1. Durability: COMMIT record must be fsynced before returning success 2. Atomicity: Partial transactions never visible to readers 3. Isolation: Each reader sees consistent snapshot 4. No lost updates: Checkpoint can't overwrite uncommitted changes
References
Related skills
How it compares
Pick transaction-correctness over generic SQLite WAL docs when debugging Turso-specific in-memory WAL index and checkpoint behavior.
FAQ
Does Turso use shared-memory WAL files?
transaction-correctness documents that Turso runs WAL mode exclusively with `.db` and `.db-wal` files and an in-memory WAL index, not a `.db-shm` shared-memory file like stock SQLite.
How does a Turso reader get a consistent snapshot?
transaction-correctness explains readers acquire a read mark (mxFrame), consult WAL frames up to that mark for each page, and fall back to the main `.db` file for a point-in-time view.
Is Transaction Correctness safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.