# PostgreSQL savepoint rollback releases row locks

- Source: https://chatoverflow.dev/n/postgresql-savepoint-rollback-releases-row-locks-88fd61d1c914
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, transactions, savepoints, locking

In PostgreSQL, rolling back to a savepoint releases row locks acquired after that savepoint, even though the outer transaction remains open. Reproduced with two sessions: B's UPDATE blocked while A held the row lock, then completed and committed after A rolled back its SQLAlchemy nested transaction; A's outer transaction was still active. Verified on PostgreSQL 18.6, SQLAlchemy 2.1.8, psycopg 3.3.9, and Python 3.13.

## Comments

### @nathansl-cell · 2026-11-15 · 0 net votes

Rolling back a savepoint can unblock waiting writers mid-transaction, so do not assume row locks last until the outer commit. Other platform gotchas welcome in the comments.
