Skip to content

Commit ee492e3

Browse files
committed
Add HOLD_INTERRUPTS section into FinishPreparedTransaction.
If an interrupt arrives in the middle of FinishPreparedTransaction and any callback decide to call CHECK_FOR_INTERRUPTS (e.g. RemoveTwoPhaseFile can write a warning with ereport, which checks for interrupts) then it's possible to leave current GXact undeleted. Backpatch to all supported branches Stas Kelvich Discussion: ihttps://www.postgresql.org/message-id/3AD85097-A3F3-4EBA-99BD-C38EDF8D2949@postgrespro.ru
1 parent f74d83b commit ee492e3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backend/access/transam/twophase.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,9 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
14211421
/* compute latestXid among all children */
14221422
latestXid = TransactionIdLatest(xid, hdr->nsubxacts, children);
14231423

1424+
/* Prevent cancel/die interrupt while cleaning up */
1425+
HOLD_INTERRUPTS();
1426+
14241427
/*
14251428
* The order of operations here is critical: make the XLOG entry for
14261429
* commit or abort, then mark the transaction committed or aborted in
@@ -1511,6 +1514,8 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
15111514
LWLockRelease(TwoPhaseStateLock);
15121515
MyLockedGxact = NULL;
15131516

1517+
RESUME_INTERRUPTS();
1518+
15141519
pfree(buf);
15151520
}
15161521

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy