pgsql: Fix WAIT FOR LSN cleanup on subtransaction abort

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix WAIT FOR LSN cleanup on subtransaction abort
Date: 2026-05-06 10:56:50
Message-ID: E1wKZvu-000ZoK-0I@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix WAIT FOR LSN cleanup on subtransaction abort

WAIT FOR LSN registers the current backend in shared memory before entering an
interruptible wait loop. Top-level abort and backend exit already call
WaitLSNCleanup(), but subtransaction abort did not. If an interrupt, such as
statement_timeout, occurred while waiting inside a savepoint, rolling back to
the savepoint left the backend marked as present in the WAIT FOR LSN heap.

Clean up WAIT FOR LSN state from AbortSubTransaction() as well, and add
a TAP test covering reuse of WAIT FOR LSN after a savepoint rollback.

Reported-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAJTYsWXDRwo-RVRaQgwxVcXgURVFeX8BKnijQrPiPcSCkDDX9A%40mail.gmail.com
Author: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Author: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Reviewed-by: Alexander Korotkov <aekorotkov(at)gmail(dot)com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5cdec423193cb99b502816197395637120256f0d

Modified Files
--------------
src/backend/access/transam/xact.c | 5 ++++
src/backend/access/transam/xlogwait.c | 2 +-
src/test/recovery/t/049_wait_for_lsn.pl | 48 +++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-05-07 01:28:10 pgsql: Simplify code in objectaddress.c for some property graph objects
Previous Message Daniel Gustafsson 2026-05-06 10:39:47 pgsql: Fix regex searching for page verification failures in tests