Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d9b3bc5

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 eab8d63 commit d9b3bc5

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

1380+
/* Prevent cancel/die interrupt while cleaning up */
1381+
HOLD_INTERRUPTS();
1382+
13801383
/*
13811384
* The order of operations here is critical: make the XLOG entry for
13821385
* commit or abort, then mark the transaction committed or aborted in
@@ -1465,6 +1468,8 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
14651468
RemoveGXact(gxact);
14661469
MyLockedGxact = NULL;
14671470

1471+
RESUME_INTERRUPTS();
1472+
14681473
pfree(buf);
14691474
}
14701475

0 commit comments

Comments
 (0)