From a5b4a04ad079d834d77c82fd29c7a7a4d04288dc Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Sat, 7 Aug 2021 20:27:14 +0500 Subject: [PATCH v13 5/6] Reorder steps of 2PC preparation Currently we remove xid from PGPROC being referenced by locks. We can do so only when locks are transfered to 2PC PGPROC. --- src/backend/access/transam/xact.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 387f80419a..bebd08f598 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -2495,13 +2495,6 @@ PrepareTransaction(void) /* Reset XactLastRecEnd until the next transaction writes something */ XactLastRecEnd = 0; - /* - * Let others know about no transaction in progress by me. This has to be - * done *after* the prepared transaction has been marked valid, else - * someone may think it is unlocked and recyclable. - */ - ProcArrayClearTransaction(MyProc); - /* * In normal commit-processing, this is all non-critical post-transaction * cleanup. When the transaction is prepared, however, it's important @@ -2535,6 +2528,15 @@ PrepareTransaction(void) PostPrepare_MultiXact(xid); PostPrepare_Locks(xid); + + /* + * Let others know about no transaction in progress by me. This has to be + * done *after* the prepared transaction has been marked valid and locks + * transfered to new PGPROC, else someone may think it is unlocked and + * recyclable. + */ + ProcArrayClearTransaction(MyProc); + PostPrepare_PredicateLocks(xid); ResourceOwnerRelease(TopTransactionResourceOwner, -- 2.24.3 (Apple Git-128)