pgref.dev/sqlite/errors/SQLITE_IOERR_TRUNCATE
SQLITE_IOERR_TRUNCATEFATALTier 3 — Handle with care⚠️ MEDIUM confidence

I/O error during file truncation

Category: I/O ErrorVersions: 3.0+

🔴 Production Risk Error

Critical — database file may be left in an inconsistent size.

What this means

SQLITE_IOERR_TRUNCATE (1546) is returned when the OS reports an error during ftruncate() on the database or journal file. This can happen when freeing space after a transaction.

Why it happens

  1. 1Hardware failure during file truncation.
  2. 2Filesystem does not support ftruncate() (e.g., certain network filesystems).
  3. 3Insufficient permissions to modify file size.

How to reproduce

File truncation after a transaction commit or WAL checkpoint.

trigger — this will ERROR
# Surfaces as disk I/O error during or after COMMIT
sqlite3.DatabaseError: disk I/O error

Fix 1

Why this works

Check disk health and filesystem for errors.

Fix 2

Why this works

Ensure the process has write permission to the database file.

Fix 3

Why this works

Use a local filesystem instead of a network mount.

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_IOERR_TRUNCATE = 1546

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 →