SQLITE_INTERRUPTWARNINGTier 2 — Caution⚠️ MEDIUM confidenceOperation terminated by sqlite3_interrupt()
🔴 Production Risk Error
Low — the interrupt is intentional; handle the error and retry or report to user.
What this means
SQLITE_INTERRUPT (9) is returned when sqlite3_interrupt() is called from another thread while an SQL operation is in progress, causing it to terminate early.
Why it happens
- 1sqlite3_interrupt() called from a signal handler or timeout thread.
- 2Application-level query timeout mechanism fired.
How to reproduce
Long-running queries interrupted by a watchdog thread.
import sqlite3, threading, time
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t(x)')
conn.executemany('INSERT INTO t VALUES(?)', [(i,) for i in range(100000)])
def interrupt():
time.sleep(0.01)
conn.interrupt()
threading.Thread(target=interrupt, daemon=True).start()
try:
conn.execute('SELECT sum(x*x) FROM t, t, t').fetchall()
except sqlite3.OperationalError as e:
print(e) # interruptedFix 1
Why this works
Retry the query if the interrupt was from a soft timeout and the operation should succeed.
Fix 2
Why this works
Increase the timeout threshold before calling interrupt().
Fix 3
Why this works
Break large queries into smaller chunks to avoid needing interrupts.
Sources
📚 Official docs: https://www.sqlite.org/rescode.html#interrupt
🔧 Source ref: sqlite3.h — SQLITE_INTERRUPT = 9
📖 Further reading: sqlite3_interrupt()
Confidence assessment
⚠️ MEDIUM confidence
Stable.
See also
🔗 Related errors
📄 Reference pages