SQLSTATE 25001Severity lowLab verified

Incident brief

Active SQL transaction

VACUUM (and a few other commands) refuse to run while a transaction block is still open. PostgreSQL rejected the command instead of running it partway.

Reproduced on PostgreSQL 16.14Verified 2026-07-16 (Docker lab, PostgreSQL 16.14)Reviewed by Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What
Active SQL transaction
What triggers it
BEGIN a transaction.
The fix
Run VACUUM on its own, outside any BEGIN/COMMIT block (plain autocommit mode).
Proof
Reproduced on PostgreSQL 16.14 → Running VACUUM inside an open transaction was rejected with SQLSTATE 25001. The session was unaffected afterward.

The fix

What to do right now

The immediate, application-level response to this error.

  • Run VACUUM on its own, outside any BEGIN/COMMIT block (plain autocommit mode).
  • The same restriction applies to other commands too, such as CREATE DATABASE — see the premium test.
  • Wrapping VACUUM in a PL/pgSQL DO block does not get around the restriction — see the counterexample.
Fix — SQL
VACUUM;

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 16.14
Last verified
2026-07-16 (Docker lab, PostgreSQL 16.14)
Reviewed by
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed