@@ -702,10 +702,12 @@ MtmCreateTransState(MtmCurrentTrans* x)
702702 if (TransactionIdIsValid (x -> gtid .xid )) {
703703 Assert (x -> gtid .node != MtmNodeId );
704704 ts -> gtid = x -> gtid ;
705+ strcpy (ts -> gid , x -> gid );
705706 } else {
706707 /* I am coordinator of transaction */
707708 ts -> gtid .xid = x -> xid ;
708709 ts -> gtid .node = MtmNodeId ;
710+ ts -> gid [0 ] = '\0' ;
709711 }
710712 }
711713 return ts ;
@@ -1062,6 +1064,7 @@ void MtmWakeUpBackend(MtmTransState* ts)
10621064void MtmAbortTransaction (MtmTransState * ts )
10631065{
10641066 if (ts -> status != TRANSACTION_STATUS_ABORTED ) {
1067+ MTM_LOG1 ("Rollback active transaction %d:%d" , ts -> gtid .node , ts -> gtid .xid );
10651068 ts -> status = TRANSACTION_STATUS_ABORTED ;
10661069 MtmAdjustSubtransactions (ts );
10671070 Mtm -> nActiveTransactions -= 1 ;
@@ -1337,7 +1340,7 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
13371340 */
13381341bool MtmRefreshClusterStatus (bool nowait )
13391342{
1340- nodemask_t mask , clique ;
1343+ nodemask_t mask , clique , disabled ;
13411344 nodemask_t matrix [MAX_NODES ];
13421345 MtmTransState * ts ;
13431346 int clique_size ;
@@ -1363,7 +1366,9 @@ bool MtmRefreshClusterStatus(bool nowait)
13631366
13641367 MTM_LOG1 ("Find clique %lx, disabledNodeMask %lx" , (long ) clique , (long ) Mtm -> disabledNodeMask );
13651368 MtmLock (LW_EXCLUSIVE );
1366- mask = ~clique & (((nodemask_t )1 << Mtm -> nAllNodes )- 1 ) & ~Mtm -> disabledNodeMask ; /* new disabled nodes mask */
1369+ disabled = ~clique & (((nodemask_t )1 << Mtm -> nAllNodes )- 1 ) & ~Mtm -> disabledNodeMask ; /* new disabled nodes mask */
1370+
1371+ mask = disabled ;
13671372 for (i = 0 ; mask != 0 ; i ++ , mask >>= 1 ) {
13681373 if (mask & 1 ) {
13691374 MtmDisableNode (i + 1 );
@@ -1378,12 +1383,17 @@ bool MtmRefreshClusterStatus(bool nowait)
13781383 MtmCheckQuorum ();
13791384 /* Interrupt voting for active transaction and abort them */
13801385 for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1381- if (!ts -> votingCompleted && MtmIsCoordinator (ts )) {
1386+ if (MtmIsCoordinator (ts )) {
1387+ if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1388+ MtmAbortTransaction (ts );
1389+ MtmWakeUpBackend (ts );
1390+ }
1391+ } else if (BIT_CHECK (disabled , ts -> gtid .node - 1 )) { // coordinator of transaction is on disabled node
13821392 if (ts -> status != TRANSACTION_STATUS_ABORTED ) {
13831393 MTM_LOG1 ("1) Rollback active transaction %d:%d:%d" , ts -> gtid .node , ts -> gtid .xid , ts -> xid );
13841394 MtmAbortTransaction (ts );
1385- }
1386- MtmWakeUpBackend ( ts );
1395+ FinishPreparedTransaction ( ts -> gid , false);
1396+ }
13871397 }
13881398 }
13891399 MtmUnlock ();
@@ -1444,12 +1454,17 @@ void MtmOnNodeDisconnect(int nodeId)
14441454 MtmCheckQuorum ();
14451455 /* Interrupt voting for active transaction and abort them */
14461456 for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1447- if (!ts -> votingCompleted && MtmIsCoordinator (ts )) {
1457+ if (MtmIsCoordinator (ts )) {
1458+ if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1459+ MtmAbortTransaction (ts );
1460+ MtmWakeUpBackend (ts );
1461+ }
1462+ } else if (ts -> gtid .node == nodeId ) { //coordinator of transaction is on disabled node
14481463 if (ts -> status != TRANSACTION_STATUS_ABORTED ) {
14491464 MTM_LOG1 ("2) Rollback active transaction %d:%d" , ts -> gtid .node , ts -> gtid .xid );
14501465 MtmAbortTransaction (ts );
1451- }
1452- MtmWakeUpBackend ( ts );
1466+ FinishPreparedTransaction ( ts -> gid , false);
1467+ }
14531468 }
14541469 }
14551470 }
0 commit comments