transaction-correctness
A technical guide to Turso's WAL-based storage architecture, concurrency rules, and crash recovery mechanics.
Install
mkdir -p .claude/skills/transaction-correctness && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/7245" && unzip -o skill.zip -d .claude/skills/transaction-correctness && rm skill.zipInstalls to .claude/skills/transaction-correctness
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
How WAL mechanics, checkpointing, concurrency rules, recovery work in tursodbKey capabilities
- →Sequential write path using WAL files
- →Consistent read snapshots via read marks
- →Multiple checkpointing modes including PASSIVE and TRUNCATE
- →Crash recovery via WAL replay
- →In-memory WAL index management
How it works
Turso uses Write-Ahead Logging where writers append data to a WAL file and readers access a consistent snapshot using in-memory read marks. Checkpointing periodically transfers these WAL pages back to the main database file.
Inputs & outputs
When to use transaction-correctness
- →Debugging database transaction bottlenecks
- →Explaining Turso crash recovery processes
- →Optimizing checkpoint strategies
About this skill
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
- Writer appends frames (page data) to WAL file (sequential I/O)
- COMMIT = frame with non-zero db_size in header (marks transaction end)
- Original DB unchanged until checkpoint
Read Path
- Reader acquires read mark (mxFrame = last valid commit frame)
- For each page: check WAL up to mxFrame, fall back to main DB
- 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 reused
Checkpoint 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:
- First connection acquires exclusive lock
- Replays valid commits from WAL
- 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 handle
DatabaseStorage- main.dbfileBufferPool- shared memory allocation
Correctness Invariants
- Durability: COMMIT record must be fsynced before returning success
- Atomicity: Partial transactions never visible to readers
- Isolation: Each reader sees consistent snapshot
- No lost updates: Checkpoint can't overwrite uncommitted changes
References
When not to use it
- →Multi-process database access
Limitations
- →Multi-process access is not supported
- →Checkpointing must stop at pages required by active readers
How it compares
Unlike standard SQLite which uses a shared memory file for the WAL index, Turso uses an in-memory hashmap and atomic read marks to support its architecture.
Compared to similar skills
transaction-correctness side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| transaction-correctness (this skill) | 1 | 6mo | No flags | Advanced |
| altinity-expert-clickhouse-metrics | 0 | 6mo | No flags | Intermediate |
| monitoring-database-transactions | 1 | 27d | Review | Advanced |
| postgres-pro | 0 | 3mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by tursodatabase
View all by tursodatabase →You might also like
altinity-expert-clickhouse-metrics
ntk148v
Real-time monitoring of ClickHouse metrics, events, and asynchronous metrics. Use for load average, connections, queue monitoring, and resource saturation.
monitoring-database-transactions
jeremylongshore
Monitor use when you need to work with monitoring and observability. This skill provides health monitoring and alerting with comprehensive guidance and automation. Trigger with phrases like "monitor system health", "set up alerts", or "track metrics".
postgres-pro
Jeffallan
Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.
supabase-observability
jeremylongshore
Execute set up comprehensive observability for Supabase integrations with metrics, traces, and alerts. Use when implementing monitoring for Supabase operations, setting up dashboards, or configuring alerting for Supabase integration health. Trigger with phrases like "supabase monitoring", "supabase metrics", "supabase observability", "monitor supabase", "supabase alerts", "supabase tracing".
audit
senda-labs
Run complete system health audit of DQIII8 — checks DB integrity, agent performance, pipeline connections, error log, and services. Produces a scored Markdown report.
db-performance
psalmprax
Debug and troubleshoot database performance in ettametta. Use when investigating slow queries, connection pool issues, migration conflicts, N+1 patterns, or schema drift.