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 <[email protected]>
Discussion: 
https://postgr.es/m/CAJTYsWXDRwo-RVRaQgwxVcXgURVFeX8BKnijQrPiPcSCkDDX9A%40mail.gmail.com
Author: Ayush Tiwari <[email protected]>
Author: Xuneng Zhou <[email protected]>
Reviewed-by: Alexander Korotkov <[email protected]>

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(-)

Reply via email to