SQLSTATE 3B001Severity lowLab verified

Incident brief

ROLLBACK TO an undeclared savepoint

ROLLBACK TO SAVEPOINT (or RELEASE SAVEPOINT) fails if the named savepoint was never established in the current transaction, raising this savepoint exception.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
ROLLBACK TO an undeclared savepoint
What triggers it
Open a transaction and issue ROLLBACK TO SAVEPOINT <name> without having declared that savepoint.
The fix
Declare the savepoint (SAVEPOINT <name>) before rolling back to it.
Proof
Reproduced on PostgreSQL 18.4 → Inside a transaction the reproduction rolls back to a savepoint that was never declared, raising SQLSTATE 3B001.

The fix

What to do right now

The immediate, application-level response to this error.

  • Declare the savepoint (SAVEPOINT <name>) before rolling back to it.
  • Match every ROLLBACK TO or RELEASE to a savepoint actually established earlier in the transaction.
Fix — SQL
-- Establish the savepoint before rolling back to it.
BEGIN;
SAVEPOINT before_charge;
ROLLBACK TO SAVEPOINT before_charge;
COMMIT;

Related & next steps

Follow the thread

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

Verification

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