@@ -701,10 +701,12 @@ MtmCreateTransState(MtmCurrentTrans* x)
701
701
if (TransactionIdIsValid (x -> gtid .xid )) {
702
702
Assert (x -> gtid .node != MtmNodeId );
703
703
ts -> gtid = x -> gtid ;
704
+ strcpy (ts -> gid , x -> gid );
704
705
} else {
705
706
/* I am coordinator of transaction */
706
707
ts -> gtid .xid = x -> xid ;
707
708
ts -> gtid .node = MtmNodeId ;
709
+ ts -> gid [0 ] = '\0' ;
708
710
}
709
711
}
710
712
return ts ;
@@ -1061,6 +1063,7 @@ void MtmWakeUpBackend(MtmTransState* ts)
1061
1063
void MtmAbortTransaction (MtmTransState * ts )
1062
1064
{
1063
1065
if (ts -> status != TRANSACTION_STATUS_ABORTED ) {
1066
+ MTM_LOG1 ("Rollback active transaction %d:%d" , ts -> gtid .node , ts -> gtid .xid );
1064
1067
ts -> status = TRANSACTION_STATUS_ABORTED ;
1065
1068
MtmAdjustSubtransactions (ts );
1066
1069
Mtm -> nActiveTransactions -= 1 ;
@@ -1336,7 +1339,7 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
1336
1339
*/
1337
1340
bool MtmRefreshClusterStatus (bool nowait )
1338
1341
{
1339
- nodemask_t mask , clique ;
1342
+ nodemask_t mask , clique , disabled ;
1340
1343
nodemask_t matrix [MAX_NODES ];
1341
1344
MtmTransState * ts ;
1342
1345
int clique_size ;
@@ -1362,7 +1365,9 @@ bool MtmRefreshClusterStatus(bool nowait)
1362
1365
1363
1366
MTM_LOG1 ("Find clique %lx, disabledNodeMask %lx" , (long ) clique , (long ) Mtm -> disabledNodeMask );
1364
1367
MtmLock (LW_EXCLUSIVE );
1365
- mask = ~clique & (((nodemask_t )1 << Mtm -> nAllNodes )- 1 ) & ~Mtm -> disabledNodeMask ; /* new disabled nodes mask */
1368
+ disabled = ~clique & (((nodemask_t )1 << Mtm -> nAllNodes )- 1 ) & ~Mtm -> disabledNodeMask ; /* new disabled nodes mask */
1369
+
1370
+ mask = disabled ;
1366
1371
for (i = 0 ; mask != 0 ; i ++ , mask >>= 1 ) {
1367
1372
if (mask & 1 ) {
1368
1373
MtmDisableNode (i + 1 );
@@ -1377,12 +1382,16 @@ bool MtmRefreshClusterStatus(bool nowait)
1377
1382
MtmCheckQuorum ();
1378
1383
/* Interrupt voting for active transaction and abort them */
1379
1384
for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1380
- if (!ts -> votingCompleted && MtmIsCoordinator (ts )) {
1385
+ if (MtmIsCoordinator (ts )) {
1386
+ if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1387
+ MtmAbortTransaction (ts );
1388
+ MtmWakeUpBackend (ts );
1389
+ }
1390
+ } else if (BIT_CHECK (disabled , ts -> gtid .node - 1 )) { // coordinator of transaction is on disabled node
1381
1391
if (ts -> status != TRANSACTION_STATUS_ABORTED ) {
1382
- MTM_LOG1 ("1) Rollback active transaction %d:%d:%d" , ts -> gtid .node , ts -> gtid .xid , ts -> xid );
1383
1392
MtmAbortTransaction (ts );
1384
- }
1385
- MtmWakeUpBackend ( ts );
1393
+ FinishPreparedTransaction ( ts -> gid , false);
1394
+ }
1386
1395
}
1387
1396
}
1388
1397
MtmUnlock ();
@@ -1443,12 +1452,16 @@ void MtmOnNodeDisconnect(int nodeId)
1443
1452
MtmCheckQuorum ();
1444
1453
/* Interrupt voting for active transaction and abort them */
1445
1454
for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1446
- if (!ts -> votingCompleted && MtmIsCoordinator (ts )) {
1455
+ if (MtmIsCoordinator (ts )) {
1456
+ if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1457
+ MtmAbortTransaction (ts );
1458
+ MtmWakeUpBackend (ts );
1459
+ }
1460
+ } else if (ts -> gtid .node == nodeId ) { //coordinator of transaction is on disabled node
1447
1461
if (ts -> status != TRANSACTION_STATUS_ABORTED ) {
1448
- MTM_LOG1 ("2) Rollback active transaction %d:%d" , ts -> gtid .node , ts -> gtid .xid );
1449
1462
MtmAbortTransaction (ts );
1450
- }
1451
- MtmWakeUpBackend ( ts );
1463
+ FinishPreparedTransaction ( ts -> gid , false);
1464
+ }
1452
1465
}
1453
1466
}
1454
1467
}
0 commit comments