SQLITE_LOCKED_SHAREDCACHE: record locked in shared cache
In shared-cache mode, another connection sharing the same cache is modifying the data this connection needs, so access is blocked.
- Result code
SQLITE_LOCKED_SHAREDCACHE- Name
262- Category
- Extended result codes
What it means
SQLITE_LOCKED_SHAREDCACHE (262) only occurs in shared-cache mode, where several connections in one process share a page cache. While one of them is modifying a record, the others are blocked from it so they never see a half-finished change.
Common causes
- Opening connections with
cache=shared(often an in-memory database shared between connections) and writing from one while reading from another.
How to fix it
-
Prefer separate caches with WAL mode for concurrency; SQLite discourages shared-cache mode for most uses.
PRAGMA journal_mode = WAL;
-
If you need shared cache, coordinate access in the application, or use
sqlite3_unlock_notify()to wait for the lock to be released.
Related errors
More extended result codes errors
SQLITE_ERROR_MISSING_COLLSEQno such collation sequenceSQLITE_BUSY_RECOVERYanother process is recovering the WALSQLITE_CONSTRAINT_CHECKCHECK constraint failedSQLITE_ABORT_ROLLBACKstatement aborted by ROLLBACKSQLITE_BUSY_SNAPSHOTstale read can't become a writeSQLITE_IOERR_SHORT_READread returned fewer bytesSQLITE_CANTOPEN_ISDIRthe path is a directorySQLITE_BUSY_TIMEOUTblocking file lock timed out
The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.
Work on SQLite in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.