@@ -673,7 +673,7 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
673673
674674 if (Mtm -> disabledNodeMask != 0 ) {
675675 MtmRefreshClusterStatus (true);
676- if (Mtm -> status != MTM_ONLINE ) {
676+ if (! IsBackgroundWorker && Mtm -> status != MTM_ONLINE ) {
677677 elog (ERROR , "Abort current transaction because this cluster node is not online" );
678678 }
679679 }
@@ -683,7 +683,9 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
683683 /*
684684 * Check if there is global multimaster lock preventing new transaction from commit to make a chance to wal-senders to catch-up
685685 */
686- MtmCheckClusterLock ();
686+ if (!x -> isReplicated ) {
687+ MtmCheckClusterLock ();
688+ }
687689
688690 ts = hash_search (MtmXid2State , & x -> xid , HASH_ENTER , NULL );
689691 ts -> status = TRANSACTION_STATUS_IN_PROGRESS ;
@@ -995,21 +997,23 @@ bool MtmRecoveryCaughtUp(int nodeId, XLogRecPtr slotLSN)
995997 if (MtmIsRecoveredNode (nodeId )) {
996998 XLogRecPtr walLSN = GetXLogInsertRecPtr ();
997999 MtmLock (LW_EXCLUSIVE );
1000+ #if 0
9981001 if (slotLSN == walLSN ) {
9991002 if (BIT_CHECK (Mtm -> nodeLockerMask , nodeId - 1 )) {
10001003 elog (WARNING ,"Node %d is caught-up" , nodeId );
1001- BIT_CLEAR (Mtm -> disabledNodeMask , nodeId - 1 );
10021004 BIT_CLEAR (Mtm -> walSenderLockerMask , MyWalSnd - WalSndCtl -> walsnds );
10031005 BIT_CLEAR (Mtm -> nodeLockerMask , nodeId - 1 );
10041006 Mtm -> nLockers -= 1 ;
10051007 } else {
10061008 elog (WARNING ,"Node %d is caugth-up without locking cluster" , nodeId );
10071009 /* We are lucky: caugth-up without locking cluster! */
1008- Mtm -> nNodes += 1 ;
1009- BIT_CLEAR (Mtm -> disabledNodeMask , nodeId - 1 );
10101010 }
1011+ BIT_CLEAR (Mtm -> disabledNodeMask , nodeId - 1 );
1012+ Mtm -> nNodes += 1 ;
10111013 caughtUp = true;
1012- } else if (!BIT_CHECK (Mtm -> nodeLockerMask , nodeId - 1 )
1014+ } else
1015+ #endif
1016+ if (!BIT_CHECK (Mtm -> nodeLockerMask , nodeId - 1 )
10131017 && slotLSN + MtmMinRecoveryLag > walLSN )
10141018 {
10151019 /*
@@ -2250,7 +2254,12 @@ MtmExecutorFinish(QueryDesc *queryDesc)
22502254
22512255void MtmExecute (void * work , int size )
22522256{
2253- BgwPoolExecute (& Mtm -> pool , work , size );
2257+ if (Mtm -> status == MTM_RECOVERY ) {
2258+ /* During recovery apply changes sequentially to preserve commit order */
2259+ MtmExecutor (0 , work , size );
2260+ } else {
2261+ BgwPoolExecute (& Mtm -> pool , work , size );
2262+ }
22542263}
22552264
22562265static BgwPool *
0 commit comments