PostgreSQL 17.12Lab-verified · 2026-11-30

PostgreSQL 3B001: savepoint does not exist

ROLLBACK TO SAVEPOINT or RELEASE named a savepoint that no longer exists in the transaction.

PostgreSQL 17.12
3B001: savepoint "sp1" does not exist

Jump to a cause

  1. 01ROLLBACK TO after RELEASE SAVEPOINT
  2. 02Rolled back to an earlier savepoint first
  3. 03Wrong savepoint name

Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-11-30 · container image postgres:17

3B001 means the savepoint name is not in the current transaction's savepoint stack. Savepoints are removed by RELEASE SAVEPOINT, and also by rolling back to an earlier savepoint. After the error the transaction is aborted, so finish it with ROLLBACK.

Below are three cases reproduced on PostgreSQL 17 with the fixes that were actually run.

01ROLLBACK TO after RELEASE SAVEPOINT

Inside BEGIN, SAVEPOINT sp1, an UPDATE, then RELEASE SAVEPOINT sp1. The following ROLLBACK TO SAVEPOINT sp1 failed with 3B001: RELEASE had already removed sp1.

With ROLLBACK TO SAVEPOINT sp1 before RELEASE SAVEPOINT sp1, both ran, COMMIT succeeded and qty stayed 10.

The failed transaction ended with ROLLBACK; a check afterwards showed the stock unchanged.

Setup
Setuprun as lab_a
CREATE TABLE stock (item text PRIMARY KEY, qty int);
INSERT INTO stock VALUES ('pen', 10);
OUTPUT
CREATE TABLE
INSERT 0 1
Reproducerun as lab_a
BEGIN;
SAVEPOINT sp1;
UPDATE stock SET qty = qty - 3 WHERE item = 'pen';
RELEASE SAVEPOINT sp1;
ROLLBACK TO SAVEPOINT sp1;
ROLLBACK;
✕ ERROR
BEGIN
SAVEPOINT
UPDATE 1
RELEASE
ERROR:  3B001: savepoint "sp1" does not exist
ROLLBACK
Checkrun as lab_a
SELECT item, qty FROM stock ORDER BY item;
OUTPUT
 item | qty
------+-----
 pen  |  10
(1 row)
After the fixrun as lab_a
BEGIN;
SAVEPOINT sp1;
UPDATE stock SET qty = qty - 3 WHERE item = 'pen';
ROLLBACK TO SAVEPOINT sp1;
RELEASE SAVEPOINT sp1;
COMMIT;
SELECT item, qty FROM stock;
✓ SUCCESS
BEGIN
SAVEPOINT
UPDATE 1
ROLLBACK
RELEASE
COMMIT
 item | qty
------+-----
 pen  |  10
(1 row)

02Rolled back to an earlier savepoint first

Savepoints step1 and step2 were set in that order. ROLLBACK TO SAVEPOINT step1 ran first, which also removed step2 (set after step1). The next ROLLBACK TO SAVEPOINT step2 failed with 3B001.

Rolling back in reverse order (step2, then step1) worked: both updates were undone and pen 10, ink 5 were unchanged after COMMIT.

The failed transaction ended with ROLLBACK; a check afterwards showed the stock unchanged.

Setup
Setuprun as lab_a
CREATE TABLE stock (item text PRIMARY KEY, qty int);
INSERT INTO stock VALUES ('pen', 10), ('ink', 5);
OUTPUT
CREATE TABLE
INSERT 0 2
Reproducerun as lab_a
BEGIN;
SAVEPOINT step1;
UPDATE stock SET qty = qty - 1 WHERE item = 'pen';
SAVEPOINT step2;
UPDATE stock SET qty = qty - 1 WHERE item = 'ink';
ROLLBACK TO SAVEPOINT step1;
ROLLBACK TO SAVEPOINT step2;
ROLLBACK;
✕ ERROR
BEGIN
SAVEPOINT
UPDATE 1
SAVEPOINT
UPDATE 1
ROLLBACK
ERROR:  3B001: savepoint "step2" does not exist
ROLLBACK
Checkrun as lab_a
SELECT item, qty FROM stock ORDER BY item;
OUTPUT
 item | qty
------+-----
 ink  |   5
 pen  |  10
(2 rows)
After the fixrun as lab_a
BEGIN;
SAVEPOINT step1;
UPDATE stock SET qty = qty - 1 WHERE item = 'pen';
SAVEPOINT step2;
UPDATE stock SET qty = qty - 1 WHERE item = 'ink';
ROLLBACK TO SAVEPOINT step2;
ROLLBACK TO SAVEPOINT step1;
COMMIT;
SELECT item, qty FROM stock ORDER BY item;
✓ SUCCESS
BEGIN
SAVEPOINT
UPDATE 1
SAVEPOINT
UPDATE 1
ROLLBACK
ROLLBACK
COMMIT
 item | qty
------+-----
 ink  |   5
 pen  |  10
(2 rows)

03Wrong savepoint name

SAVEPOINT before_update was set, but ROLLBACK TO SAVEPOINT before_updat was called. The message names the missing savepoint, "before_updat". With the correct name the rollback and COMMIT succeeded and qty stayed 10.

The failed transaction ended with ROLLBACK; a check afterwards showed the stock unchanged.

Setup
Setuprun as lab_a
CREATE TABLE stock (item text PRIMARY KEY, qty int);
INSERT INTO stock VALUES ('pen', 10);
OUTPUT
CREATE TABLE
INSERT 0 1
Reproducerun as lab_a
BEGIN;
SAVEPOINT before_update;
UPDATE stock SET qty = qty - 3 WHERE item = 'pen';
ROLLBACK TO SAVEPOINT before_updat;
ROLLBACK;
✕ ERROR
BEGIN
SAVEPOINT
UPDATE 1
ERROR:  3B001: savepoint "before_updat" does not exist
ROLLBACK
Checkrun as lab_a
SELECT item, qty FROM stock ORDER BY item;
OUTPUT
 item | qty
------+-----
 pen  |  10
(1 row)
After the fixrun as lab_a
BEGIN;
SAVEPOINT before_update;
UPDATE stock SET qty = qty - 3 WHERE item = 'pen';
ROLLBACK TO SAVEPOINT before_update;
COMMIT;
SELECT item, qty FROM stock;
✓ SUCCESS
BEGIN
SAVEPOINT
UPDATE 1
ROLLBACK
COMMIT
 item | qty
------+-----
 pen  |  10
(1 row)

FAQ

What does savepoint does not exist mean in PostgreSQL?

The name is not among the active savepoints of the current transaction. It was released, removed by rolling back to an earlier savepoint, or never created under that name.

Does RELEASE SAVEPOINT commit the changes?

No. It only removes the savepoint; the changes stay part of the transaction. But you can no longer roll back to it, as the 3B001 here shows.

What should I do after a 3B001 error inside a transaction?

The transaction is aborted. Run ROLLBACK (or roll back to a savepoint that still exists) before running other statements.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary roles created for the test, each owning a schema of the same name; postgres is the superuser. PostgreSQL 17.12