25001: active_sql_transaction
PostgreSQLWhat does it mean?
A command that can only run outside a transaction, or at its start, was called while a transaction was active. Some commands do not run inside a transaction block.
Why does it happen?
Settings such as SET TRANSACTION ISOLATION LEVEL must be issued before the first query in the block ('SET TRANSACTION ISOLATION LEVEL must be called before any query'). Similarly, some commands are rejected inside an open BEGIN/transaction. It usually comes from the application disabling autocommit and silently starting a transaction.
How to fix it
Issue transaction-level settings at the very start of the transaction, before any query runs: BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; ... Check whether the client library opens an implicit transaction (autocommit setting). For commands that cannot run inside a transaction block, first close the current transaction with COMMIT/ROLLBACK.