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