SQLITE_LOCKED_SHAREDCACHE
SQLiteWARNINGNotableLockingofficial confidence

Locked due to shared-cache contention

Production Risk

Medium — causes contention; migrate away from shared-cache.

What this means

SQLITE_LOCKED_SHAREDCACHE (262) is an extended result code returned in shared-cache mode when one connection attempts to access a table that another connection in the same shared cache has locked.

Why it happens
  1. 1Shared-cache mode enabled (SQLITE_ENABLE_SHARED_CACHE) with concurrent connections reading/writing the same table.
  2. 2Two connections sharing the same page cache holding conflicting table-level locks.
How to reproduce

Shared-cache mode (deprecated since SQLite 3.36.0).

trigger — this will error
trigger — this will error
-- Enable shared cache (deprecated):
PRAGMA cache = shared;
-- Concurrent connection locking same table triggers SQLITE_LOCKED_SHAREDCACHE

expected output

sqlite3.OperationalError: database table is locked

Fix 1

Fix 2

What not to do

Version notes

Sources
Official documentation ↗

sqlite3.h — SQLITE_LOCKED_SHAREDCACHE = 262

Shared cache mode

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

← All SQLite errors