SQLITE_BUSY_SNAPSHOT
SQLiteWARNINGNotableLockingofficial confidence

Busy: WAL snapshot is out of date

Production Risk

Medium — write transactions will be blocked until the read transaction ends.

What this means

SQLITE_BUSY_SNAPSHOT (517) is returned in WAL mode when a read transaction sees an older snapshot and a write transaction cannot proceed because a checkpoint would need to overwrite pages that the read transaction is viewing.

Why it happens
  1. 1Long-running read transaction in WAL mode is blocking the checkpoint.
  2. 2Read connection holds a snapshot that is older than the write connection needs.
How to reproduce

WAL-mode database with concurrent long-running readers and active writers.

trigger — this will error
trigger — this will error
-- Connection A (read transaction, holds old snapshot):
BEGIN; SELECT * FROM big_table;

-- Connection B (write transaction, blocked):
-- BEGIN; INSERT INTO big_table ... → SQLITE_BUSY_SNAPSHOT

expected output

sqlite3.OperationalError: database is locked

Fix 1

Fix 2

Fix 3

What not to do

Sources
Official documentation ↗

sqlite3.h — SQLITE_BUSY_SNAPSHOT = 517

WAL mode

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All SQLite errors