pgref.dev/sqlite/errors/SQLITE_IOERR_FSYNC
SQLITE_IOERR_FSYNCFATALTier 3 — Handle with care⚠️ MEDIUM confidence

I/O error during fsync()

Category: I/O ErrorVersions: 3.0+

🔴 Production Risk Error

Critical — committed data may not be durable.

What this means

SQLITE_IOERR_FSYNC (1034) is returned when the OS reports an error during an fsync() or FlushFileBuffers() call. SQLite calls fsync() to ensure data is durably written to disk before completing a transaction commit.

Why it happens

  1. 1Disk hardware failure during fsync.
  2. 2Some filesystems (e.g., certain NFS mounts) return EIO on fsync.
  3. 3SSD firmware bug causing fsync failure.

How to reproduce

Transaction commit (COMMIT statement) when fsync() fails.

trigger — this will ERROR
# Triggered by hardware or filesystem issues during COMMIT
# PRAGMA synchronous = FULL forces fsync on every commit
sqlite3.DatabaseError: disk I/O error

Fix 1

Why this works

Check filesystem and disk health: dmesg | grep -i fsync

Fix 2

Why this works

Use PRAGMA synchronous = NORMAL as a less aggressive alternative to FULL.

Fix 3

Why this works

Move the database to a local filesystem rather than NFS.

What not to do

Why it's wrong:

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_IOERR_FSYNC = 1034

📖 Further reading: SQLite synchronous pragma

Confidence assessment

⚠️ MEDIUM confidence

Stable.

See also

📄 Reference pages

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