Diagnostic Queries
Symptoms
A command was issued in a transaction that already failed; PostgreSQL ignores all commands until the transaction is ended. It raises SQLSTATE 25P02 (in_failed_sql_transaction).
- An earlier error aborted the transaction.
- All subsequent commands are rejected until rollback.
- Common when error handling doesn’t roll back.
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:
“The essential point of a transaction is that it bundles multiple steps into a single, all-or-nothing operation.”
Once a statement errors inside a transaction, PostgreSQL marks the whole transaction aborted. To prevent partial/inconsistent work, it rejects every further command with 25P02 until you ROLLBACK (optionally to a savepoint).
Common causes
- A prior statement in the transaction raised an error.
- Error handling that continues issuing commands without rolling back.
- No savepoint to recover to after a failed statement.
How to fix it
- Issue
ROLLBACKto end the transaction, then start fresh. - Use
SAVEPOINTandROLLBACK TO SAVEPOINTto recover within the transaction. - Fix the original failing statement that aborted the transaction.
Related & next steps
Reference: PostgreSQL 18 Section 3.4 “Transactions”.
Thanks — noted. This helps keep the database accurate.