pgref.dev/sqlite/errors/SQLITE_ABORT
SQLITE_ABORTWARNINGTier 2 — Caution⚠️ MEDIUM confidence

Callback routine requested an abort

Category: TransactionVersions: 3.0+

🔴 Production Risk Error

Medium — statements must be retried or the transaction redesigned.

What this means

SQLITE_ABORT (4) is returned when an operation was aborted before completing. Commonly seen when a ROLLBACK is executed while a read is in progress, or when sqlite3_exec() callback returns non-zero.

Why it happens

  1. 1sqlite3_exec() callback returned non-zero, requesting abort.
  2. 2ROLLBACK issued while a prepared statement was active.
  3. 3sqlite3_interrupt() called from another thread.

How to reproduce

Multi-statement exec callbacks, or concurrent rollback during active read.

trigger — this will ERROR
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t(x)')
conn.execute('INSERT INTO t VALUES (1)')
# Abort extended code also appears after ROLLBACK during active SELECT
sqlite3.OperationalError: abort due to ROLLBACK

Fix 1

Why this works

Ensure all prepared statements are finalised (closed) before issuing ROLLBACK.

Fix 2

Why this works

Use savepoints (SAVEPOINT / ROLLBACK TO) for partial rollback without invalidating other statements.

Fix 3

Why this works

In exec callbacks, return 0 to continue or 1 to abort intentionally.

What not to do

Why it's wrong:

Dangerous variant

⚠️ Warning

SQLITE_ABORT_ROLLBACK (516) — statement aborted because transaction was rolled back.

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_ABORT = 4

📖 Further reading: SQLite transactions

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 →