SQLITE_IOERR_LOCK
SQLiteERRORNotableI/O Errorofficial confidence

I/O error obtaining file lock

Production Risk

High — transaction cannot proceed; use local storage.

What this means

SQLITE_IOERR_LOCK (3850) is returned when the OS reports an error while SQLite is trying to acquire a file lock — distinct from SQLITE_BUSY, which indicates the lock is held by another process.

Why it happens
  1. 1Filesystem does not support POSIX advisory locks (some network filesystems).
  2. 2OS error (EIO, ENOMEM) during fcntl() lock call.
  3. 3Docker or container environment with non-standard file locking.
How to reproduce

Lock acquisition during BEGIN EXCLUSIVE or BEGIN IMMEDIATE.

trigger — this will error
trigger — this will error
# On NFS or some Docker volumes, fcntl() may return EIO
# → SQLITE_IOERR_LOCK instead of SQLITE_BUSY

expected output

sqlite3.OperationalError: disk I/O error

Fix 1

Fix 2

Fix 3

What not to do

Sources
Official documentation ↗

sqlite3.h — SQLITE_IOERR_LOCK = 3850

SQLite file locking

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

← All SQLite errors