current transaction is aborted, commands ignored until end of transaction block
Symptoms
An earlier statement in the transaction failed, so the whole transaction is now in an aborted state. Every subsequent command is rejected with SQLSTATE 25P02 (in_failed_sql_transaction) until you roll back (or roll back to a savepoint).
- The real error came earlier; this message is the follow-on.
- All commands are ignored until
ROLLBACK. - Common in scripts that keep issuing statements after a failure.
What the server log shows
ERROR: current transaction is aborted, commands ignored until end of transaction block
Why PostgreSQL raises this — what the manual says
Section 3.4 Transactions:
“Moreover, ROLLBACK TO is the only way to regain control of a transaction block that was put in aborted state by the system due to an error, short of rolling it back completely and starting again.”
When a statement errors inside a transaction, PostgreSQL marks the transaction aborted to preserve atomicity. It then refuses further work (25P02) until the application ends the block with ROLLBACK, or rewinds to a SAVEPOINT taken before the failure.
Common causes
- Continuing to run statements after a prior error in the same transaction.
- Not checking for errors between batched statements.
- Missing savepoints around a statement that may fail.
How to fix it
- Issue
ROLLBACKto end the transaction, then start fresh. - Wrap fallible statements in
SAVEPOINT/ROLLBACK TO SAVEPOINTto recover without losing the whole transaction. - Find and fix the original error (it appears earlier in the log).
Related & next steps
Reference: PostgreSQL 18 Section 3.4 “Transactions”.