Skip to content

Commit 6bd659f

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 7021145 commit 6bd659f

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
@@ -1391,6 +1391,9 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
13911391
/* compute latestXid among all children */
13921392
latestXid = TransactionIdLatest(xid, hdr->nsubxacts, children);
13931393

1394+
/* Prevent cancel/die interrupt while cleaning up */
1395+
HOLD_INTERRUPTS();
1396+
13941397
/*
13951398
* The order of operations here is critical: make the XLOG entry for
13961399
* commit or abort, then mark the transaction committed or aborted in
@@ -1478,6 +1481,8 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
14781481
RemoveGXact(gxact);
14791482
MyLockedGxact = NULL;
14801483

1484+
RESUME_INTERRUPTS();
1485+
14811486
pfree(buf);
14821487
}
14831488

0 commit comments

Comments
 (0)