@@ -1351,7 +1351,7 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
13511351 */
13521352bool MtmRefreshClusterStatus (bool nowait )
13531353{
1354- nodemask_t mask , clique , disabled ;
1354+ nodemask_t mask , clique , disabled , enabled ;
13551355 nodemask_t matrix [MAX_NODES ];
13561356 MtmTransState * ts ;
13571357 int clique_size ;
@@ -1385,29 +1385,34 @@ bool MtmRefreshClusterStatus(bool nowait)
13851385 MtmDisableNode (i + 1 );
13861386 }
13871387 }
1388- mask = clique & Mtm -> disabledNodeMask ; /* new enabled nodes mask */
1388+
1389+ enabled = clique & Mtm -> disabledNodeMask ; /* new enabled nodes mask */
1390+
1391+ mask = enabled ;
13891392 for (i = 0 ; mask != 0 ; i ++ , mask >>= 1 ) {
13901393 if (mask & 1 ) {
13911394 MtmEnableNode (i + 1 );
13921395 }
13931396 }
1394- MtmCheckQuorum ();
1395- /* Interrupt voting for active transaction and abort them */
1396- for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1397- MTM_LOG3 ("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d" ,
1398- ts -> gid , ts -> gtid .node , ts -> xid , ts -> status , ts -> gtid .xid );
1399- if (MtmIsCoordinator (ts )) {
1400- if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1401- MtmAbortTransaction (ts );
1402- MtmWakeUpBackend (ts );
1403- }
1404- } else if (TransactionIdIsValid (ts -> gtid .xid ) && BIT_CHECK (disabled , ts -> gtid .node - 1 )) { // coordinator of transaction is on disabled node
1405- if (ts -> gid [0 ]) {
1406- if (ts -> status == TRANSACTION_STATUS_UNKNOWN || ts -> status == TRANSACTION_STATUS_IN_PROGRESS ) {
1407- MTM_LOG1 ("%d: Abort trasaction %s because its coordinator is at disabled node %d" , MyProcPid , ts -> gid , ts -> gtid .node );
1397+ if (disabled |enabled ) {
1398+ MtmCheckQuorum ();
1399+ /* Interrupt voting for active transaction and abort them */
1400+ for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1401+ MTM_LOG3 ("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d" ,
1402+ ts -> gid , ts -> gtid .node , ts -> xid , ts -> status , ts -> gtid .xid );
1403+ if (MtmIsCoordinator (ts )) {
1404+ if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
14081405 MtmAbortTransaction (ts );
1409- MtmTx .status = TRANSACTION_STATUS_ABORTED ; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1410- FinishPreparedTransaction (ts -> gid , false);
1406+ MtmWakeUpBackend (ts );
1407+ }
1408+ } else if (TransactionIdIsValid (ts -> gtid .xid ) && BIT_CHECK (disabled , ts -> gtid .node - 1 )) { // coordinator of transaction is on disabled node
1409+ if (ts -> gid [0 ]) {
1410+ if (ts -> status == TRANSACTION_STATUS_UNKNOWN || ts -> status == TRANSACTION_STATUS_IN_PROGRESS ) {
1411+ MTM_LOG1 ("%d: Abort trasaction %s because its coordinator is at disabled node %d" , MyProcPid , ts -> gid , ts -> gtid .node );
1412+ MtmAbortTransaction (ts );
1413+ MtmTx .status = TRANSACTION_STATUS_ABORTED ; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1414+ FinishPreparedTransaction (ts -> gid , false);
1415+ }
14111416 }
14121417 }
14131418 }
@@ -3288,6 +3293,7 @@ MtmDetectGlobalDeadLock(PGPROC* proc)
32883293 ByteBuffer buf ;
32893294 PGXACT * pgxact = & ProcGlobal -> allPgXact [proc -> pgprocno ];
32903295 bool hasDeadlock = false;
3296+
32913297 if (TransactionIdIsValid (pgxact -> xid )) {
32923298 MtmGraph graph ;
32933299 GlobalTransactionId gtid ;
0 commit comments