SQLSTATE 25P01Severity lowLab verified

Incident brief

No active SQL transaction

A command that only makes sense inside an open transaction block was issued with none active. PostgreSQL rejected it instead of silently ignoring it.

What lands in your log

ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks

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

In 10 seconds

What triggers it
Issue ROLLBACK AND CHAIN with no transaction block open.
Fix
Only issue AND CHAIN variants inside an already-open transaction block (after BEGIN).
Proof
Reproduced on PostgreSQL 16.14 → ROLLBACK AND CHAIN with no transaction block open was rejected with SQLSTATE 25P01. The session was unaffected afterward.

Fix

What to do right now

Application-level steps for this error.

  • Only issue AND CHAIN variants inside an already-open transaction block (after BEGIN).
  • Plain COMMIT/ROLLBACK outside a transaction block are not an error at all, just a warning, see the premium test.
  • Don't 'fix' this by unconditionally prefixing a defensive BEGIN, see the counterexample for what that can silently discard.
Fix SQL
BEGIN;
-- ... statements ...
ROLLBACK AND CHAIN;

Connected

Everything this error touches

Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.

Open in the interactive map →

Verification

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

Went further?

Pro unlocks the second lab proof

Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.

FollowSubstackLinkedInnew errors · lab notes · hiring loops