database
system_error
ai_generated
partial
sqlite3.OperationalError: disk I/O error
ID: database/sqlite-disk-io-error
75%Fix Rate
87%Confidence
1Evidence
2023-04-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| SQLite 3.39 | active | — | — | — |
| SQLite 3.40 | active | — | — | — |
| SQLite 3.43 | active | — | — | — |
Root Cause
SQLite encounters an operating system-level input/output error while reading or writing the database file, typically due to filesystem corruption, disk failure, or insufficient permissions on the storage device.
generic中文
SQLite 在读取或写入数据库文件时遇到操作系统级别的输入/输出错误,通常由文件系统损坏、磁盘故障或存储设备权限不足引起。
Official Documentation
https://www.sqlite.org/rescode.html#ioerrWorkarounds
-
70% success Run fsck on the filesystem (e.g., sudo fsck /dev/sda1) or on Windows run chkdsk /f C:. This may fix underlying corruption.
Run fsck on the filesystem (e.g., sudo fsck /dev/sda1) or on Windows run chkdsk /f C:. This may fix underlying corruption.
-
80% success Copy the .db file to another disk: cp mydb.db /healthy_disk/mydb.db. Then run: sqlite3 /healthy_disk/mydb.db 'PRAGMA integrity_check;'. If it passes, use the copy.
Copy the .db file to another disk: cp mydb.db /healthy_disk/mydb.db. Then run: sqlite3 /healthy_disk/mydb.db 'PRAGMA integrity_check;'. If it passes, use the copy.
-
75% success Run: sqlite3 corrupted.db '.dump' | sqlite3 new.db. This recreates the database from scratch, skipping corrupted pages if possible.
Run: sqlite3 corrupted.db '.dump' | sqlite3 new.db. This recreates the database from scratch, skipping corrupted pages if possible.
中文步骤
Run fsck on the filesystem (e.g., sudo fsck /dev/sda1) or on Windows run chkdsk /f C:. This may fix underlying corruption.
Copy the .db file to another disk: cp mydb.db /healthy_disk/mydb.db. Then run: sqlite3 /healthy_disk/mydb.db 'PRAGMA integrity_check;'. If it passes, use the copy.
Run: sqlite3 corrupted.db '.dump' | sqlite3 new.db. This recreates the database from scratch, skipping corrupted pages if possible.
Dead Ends
Common approaches that don't work:
-
100% fail
The underlying I/O issue persists; reopening will trigger the same error immediately.
-
80% fail
VACUUM requires a temporary file and may fail with the same I/O error if the disk is full or damaged.
-
90% fail
WAL mode still writes to disk; if the disk is faulty, the error will recur.