SQLSTATE 3B001 ERROR Class 3B: Savepoint Exception

invalid_savepoint_specification savepoint “…” does not exist — 3B001

PostgreSQL error "savepoint "…" does not exist" (SQLSTATE 3B001): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A ROLLBACK TO SAVEPOINT or RELEASE SAVEPOINT named a savepoint that does not exist in the current transaction. PostgreSQL raises SQLSTATE 3B001 (invalid_savepoint_specification).

  • The named savepoint was never established or was already released.
  • Common after a typo or releasing a savepoint earlier.
  • Savepoints are scoped to the current transaction.

What the server log shows

ERROR:  savepoint "sp1" does not exist

Why PostgreSQL raises this — what the manual says

the ROLLBACK TO SAVEPOINT reference (Notes):

“Specifying a savepoint name that has not been established is an error.”

Savepoints live within the current transaction. Referencing a name that was never set (or already released/rolled past) cannot be resolved, so PostgreSQL reports 3B001.

Common causes

  • A typo in the savepoint name.
  • The savepoint was already released.
  • Referencing a savepoint from a different transaction.

How to fix it

  1. Establish the savepoint with SAVEPOINT sp1; before referencing it.
  2. Match the savepoint name exactly.
  3. Track active savepoints in application logic to avoid releasing too early.

Related & next steps

Reference: PostgreSQL 18 — ROLLBACK TO SAVEPOINT.

Was this helpful?