Diagnostic Queries
Symptoms
A command that requires an open transaction (e.g. COMMIT, ROLLBACK, or ROLLBACK TO SAVEPOINT) was issued with no transaction in progress. PostgreSQL raises SQLSTATE 25P01 (no_active_sql_transaction). Often this appears as a warning for a stray COMMIT/ROLLBACK.
- A transaction-control command ran with no open transaction.
- Common with a stray COMMIT/ROLLBACK in autocommit mode.
- There is nothing to commit or roll back.
What the server log shows
WARNING: there is no transaction in progress
Why PostgreSQL raises this — what the manual says
the COMMIT reference (Description):
“COMMIT commits the current transaction.”
Transaction-control statements operate on an active transaction. With none open (autocommit), there is nothing to act on, so PostgreSQL reports 25P01 (a warning for stray COMMIT/ROLLBACK; an error for statements that strictly require a transaction).
Common causes
- A stray
COMMIT/ROLLBACKwith no matchingBEGIN. - Double-committing a transaction.
- Autocommit mode where each statement already commits.
How to fix it
- Pair transaction control with an explicit
BEGIN. - Remove redundant COMMIT/ROLLBACK calls.
- Track transaction state in the application to avoid stray controls.
Related & next steps
Reference: PostgreSQL 18 — COMMIT.
Thanks — noted. This helps keep the database accurate.