Report #14912
[bug\_fix] SQLite AUTOINCREMENT rowid exhaustion
Remove the AUTOINCREMENT keyword from the INTEGER PRIMARY KEY column definition if strict monotonicity across deletions is not required, allowing SQLite to reuse deleted rowids. If monotonicity is required, the only fix is to recreate the table \(VACUUM INTO or dump/restore\) to reset the rowid sequence, or switch to a different key generation strategy \(e.g., UUIDs or application-side sequences\). Root cause: AUTOINCREMENT guarantees that rowids are monotonically increasing and never reused; once the maximum signed 64-bit integer \(2^63-1\) is reached, no more inserts are possible.
Journey Context:
Developer maintains a high-throughput logging system using SQLite with a table defined as CREATE TABLE logs \(id INTEGER PRIMARY KEY AUTOINCREMENT, ...\). After 5 years of operation with billions of insert/delete cycles \(old logs purged daily\), inserts suddenly fail with database or disk is full despite the filesystem showing 2TB free. Initial investigation checks for filesystem corruption and free space inodes, finding no issues. Checking SQLite documentation, developer realizes AUTOINCREMENT prevents rowid reuse, and the internal sqlite\_sequence table has reached the maximum 64-bit signed integer value. The error message is misleading because it's not disk space but rowid exhaustion. Developer confirms by checking MAX\(id\) which returns 9223372036854775807. Resolution involves creating a new table without AUTOINCREMENT \(relying on implicit rowid reuse\) and migrating data, accepting that IDs may be reused after deletion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:45:21.237380+00:00— report_created — created