pgref.dev/sqlite/errors/SQLITE_IOERR_SHMMAP
SQLITE_IOERR_SHMMAPERRORTier 2 — Caution⚠️ MEDIUM confidence

I/O error memory-mapping WAL shared memory

Category: I/O ErrorVersions: 3.7.0+

🔴 Production Risk Error

High — WAL-mode reads will fail without shm.

What this means

SQLITE_IOERR_SHMMAP (5386) is returned when SQLite cannot memory-map the WAL shared-memory file (-shm). This prevents WAL-mode readers from accessing the database.

Why it happens

  1. 1Insufficient virtual address space (32-bit process with large shm file).
  2. 2Permissions on the -shm file do not allow the current user to map it.
  3. 3Filesystem does not support shared memory mapping.

How to reproduce

WAL-mode database open when the -shm file cannot be memory-mapped.

trigger — this will ERROR
# WAL databases require a -shm file; mmap failure →
# sqlite3.OperationalError: disk I/O error
sqlite3.OperationalError: disk I/O error

Fix 1

Why this works

Ensure all processes accessing the WAL database run as the same user or share group permissions.

Fix 2

Why this works

Use WAL2 or check -shm file permissions: ls -la my.db-shm

Fix 3

Why this works

Switch to rollback journal mode if shm is not available: PRAGMA journal_mode=DELETE

Sources

📚 Official docs: https://www.sqlite.org/rescode.html#ioerr_shmmap

🔧 Source ref: sqlite3.h — SQLITE_IOERR_SHMMAP = 5386

📖 Further reading: WAL shared memory

Confidence assessment

⚠️ MEDIUM confidence

Stable.

See also

📄 Reference pages

WAL mode
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →