SQLITE_IOERR_MMAP
SQLiteERRORNotableI/O Errorofficial confidence

I/O error during memory-mapped file access

Production Risk

High — may cause SIGBUS (process crash) rather than a graceful error.

What this means

SQLITE_IOERR_MMAP (6154) is returned when an error occurs while reading from a memory-mapped region of the database file, typically a SIGBUS due to an underlying I/O error.

Why it happens
  1. 1Hardware failure causing a SIGBUS on mmap read.
  2. 2NFS disconnect while the file is memory-mapped.
  3. 3File truncated externally while mmap is active.
How to reproduce

mmap-mode reads (PRAGMA mmap_size > 0) when the underlying file has I/O errors.

trigger — this will error
trigger — this will error
import sqlite3
conn = sqlite3.connect('my.db')
conn.execute('PRAGMA mmap_size=268435456')  # 256 MB mmap
# If disk fails while reading mmap region → SQLITE_IOERR_MMAP

expected output

sqlite3.DatabaseError: disk I/O error

Fix 1

Fix 2

Fix 3

What not to do

Version notes

Sources
Official documentation ↗

sqlite3.h — SQLITE_IOERR_MMAP = 6154

SQLite mmap I/O

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

← All SQLite errors