25P02 In Failed SQL Transaction
You may encounter an error message like following.
ERROR: current transaction is aborted, commands ignored until end of transaction block
In Redrock Postgres, usually, if a SQL statement causes an error during execution, then all effects of the statement are rolled back. This operation is a statement-level rollback.
When we execute the ALTER CONSTRAINT
constraint_name
INITIALLY IMMEDIATE
command to set the constraint of the delay check to IMMEDIATE
, the constraint is immediately checked, and it is necessary to verify whether the operations performed by the transaction satisfies the constraint check. In this case, if an error occurs in the check, the error generated by the SQL statement cannot be recovered and the transaction will enter the aborted state.
If we are in an aborted transaction, Postgres rejects all commands except ROLLBACK
/ABORT
.
Usually this is caused by applications not handling errors in transactions correctly, and keeping a transaction open instead of rolling it back. This may have other unintended circumstances, so it’s highly recommended to fix your application code to respond correctly to failures in transactions.