pgref.dev/sqlite/errors/SQLITE_IOERR_SHORT_READ
SQLITE_IOERR_SHORT_READERRORTier 3 — Handle with care⚠️ MEDIUM confidence

I/O error: short read (unexpected EOF)

Category: I/O ErrorVersions: 3.0+

🔴 Production Risk Error

Critical — database file is likely truncated or corrupt.

What this means

SQLITE_IOERR_SHORT_READ (522) is returned when a read from the database file returned fewer bytes than requested — typically indicating a truncated or corrupt file.

Why it happens

  1. 1Database file was truncated (e.g., by a disk-full condition during write).
  2. 2File copied incompletely.
  3. 3Partial write failure left the file smaller than its page count suggests.

How to reproduce

Any read operation that hits an unexpected end-of-file.

trigger — this will ERROR
# Truncate a database file to simulate:
# truncate -s 1024 my.db
# Then try to openSQLITE_IOERR_SHORT_READ
sqlite3.DatabaseError: disk I/O error

Fix 1

Why this works

Restore the database from a known-good backup.

Fix 2

Why this works

Check disk space on the filesystem where the database resides.

Fix 3

Why this works

Use PRAGMA integrity_check to verify database consistency.

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_IOERR_SHORT_READ = 522

Confidence assessment

⚠️ MEDIUM confidence

Stable.

See also

⚙️ 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 →