TR

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.zip

Installs 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 tursodb
77 charsno explicit “when” trigger
Advanced

Key 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

You give it
Database transaction commit
You get back
WAL frame appended to .db-wal file

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

  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 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:

  1. First connection acquires exclusive lock
  2. Replays valid commits from WAL
  3. Releases lock, normal operation resumes

Turso Implementation

Key files:

Connection-Private vs Shared

Per-Connection (private):

  • Pager - page cache, dirty pages, savepoints, commit state
  • WalFile - connection's snapshot view:
    • max_frame / min_frame - frame range for this connection's snapshot
    • max_frame_read_lock_index - which read lock slot this connection holds
    • last_checksum - rolling checksum state

Shared across connections:

  • WalFileShared - global WAL state:
    • frame_cache - page-to-frame index (replaces .shm file)
    • max_frame / nbackfills - global WAL progress
    • read_locks[5] - read mark slots (TursoRwLock with embedded frame values)
    • write_lock - exclusive writer lock
    • checkpoint_lock - checkpoint serialization
    • file - WAL file handle
  • DatabaseStorage - main .db file
  • BufferPool - 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

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.

SkillInstallsUpdatedSafetyDifficulty
transaction-correctness (this skill)16moNo flagsAdvanced
altinity-expert-clickhouse-metrics06moNo flagsIntermediate
monitoring-database-transactions127dReviewAdvanced
postgres-pro03moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

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.

00

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".

11

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.

02

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".

01

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.

00

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.

00

Search skills

Search the agent skills registry