@@ -1377,41 +1377,38 @@ bool MtmRefreshClusterStatus(bool nowait)
1377
1377
MTM_LOG1 ("Find clique %lx, disabledNodeMask %lx" , (long ) clique , (long ) Mtm -> disabledNodeMask );
1378
1378
MtmLock (LW_EXCLUSIVE );
1379
1379
disabled = ~clique & (((nodemask_t )1 << Mtm -> nAllNodes )- 1 ) & ~Mtm -> disabledNodeMask ; /* new disabled nodes mask */
1380
+ enabled = clique & Mtm -> disabledNodeMask ; /* new enabled nodes mask */
1380
1381
1381
- mask = disabled ;
1382
- for (i = 0 ; mask != 0 ; i ++ , mask >>= 1 ) {
1382
+ for (i = 0 , mask = disabled ; mask != 0 ; i ++ , mask >>= 1 ) {
1383
1383
if (mask & 1 ) {
1384
1384
MtmDisableNode (i + 1 );
1385
1385
}
1386
1386
}
1387
1387
1388
- enabled = clique & Mtm -> disabledNodeMask ; /* new enabled nodes mask */
1389
-
1390
- mask = enabled ;
1391
- for (i = 0 ; mask != 0 ; i ++ , mask >>= 1 ) {
1388
+ for (i = 0 , mask = enabled ; mask != 0 ; i ++ , mask >>= 1 ) {
1392
1389
if (mask & 1 ) {
1393
1390
MtmEnableNode (i + 1 );
1394
1391
}
1395
1392
}
1396
1393
if (disabled |enabled ) {
1397
1394
MtmCheckQuorum ();
1398
- /* Interrupt voting for active transaction and abort them */
1399
- for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1400
- MTM_LOG3 ("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d" ,
1401
- ts -> gid , ts -> gtid .node , ts -> xid , ts -> status , ts -> gtid .xid );
1402
- if (MtmIsCoordinator (ts )) {
1403
- if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1395
+ }
1396
+ /* Interrupt voting for active transaction and abort them */
1397
+ for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1398
+ MTM_LOG3 ("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d" ,
1399
+ ts -> gid , ts -> gtid .node , ts -> xid , ts -> status , ts -> gtid .xid );
1400
+ if (MtmIsCoordinator (ts )) {
1401
+ if (!ts -> votingCompleted && (disabled |enabled ) != 0 && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1402
+ MtmAbortTransaction (ts );
1403
+ MtmWakeUpBackend (ts );
1404
+ }
1405
+ } else if (TransactionIdIsValid (ts -> gtid .xid ) && BIT_CHECK (disabled , ts -> gtid .node - 1 )) { // coordinator of transaction is on disabled node
1406
+ if (ts -> gid [0 ]) {
1407
+ if (ts -> status == TRANSACTION_STATUS_UNKNOWN || ts -> status == TRANSACTION_STATUS_IN_PROGRESS ) {
1408
+ MTM_LOG1 ("%d: Abort trasaction %s because its coordinator is at disabled node %d" , MyProcPid , ts -> gid , ts -> gtid .node );
1404
1409
MtmAbortTransaction (ts );
1405
- MtmWakeUpBackend (ts );
1406
- }
1407
- } else if (TransactionIdIsValid (ts -> gtid .xid ) && BIT_CHECK (disabled , ts -> gtid .node - 1 )) { // coordinator of transaction is on disabled node
1408
- if (ts -> gid [0 ]) {
1409
- if (ts -> status == TRANSACTION_STATUS_UNKNOWN || ts -> status == TRANSACTION_STATUS_IN_PROGRESS ) {
1410
- MTM_LOG1 ("%d: Abort trasaction %s because its coordinator is at disabled node %d" , MyProcPid , ts -> gid , ts -> gtid .node );
1411
- MtmAbortTransaction (ts );
1412
- MtmTx .status = TRANSACTION_STATUS_ABORTED ; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1413
- FinishPreparedTransaction (ts -> gid , false);
1414
- }
1410
+ MtmTx .status = TRANSACTION_STATUS_ABORTED ; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1411
+ FinishPreparedTransaction (ts -> gid , false);
1415
1412
}
1416
1413
}
1417
1414
}
@@ -1490,7 +1487,7 @@ void MtmOnNodeDisconnect(int nodeId)
1490
1487
}
1491
1488
MtmUnlock ();
1492
1489
} else {
1493
- MtmRefreshClusterStatus (true); /* false); -- TODO: raftable can handg in nowait=true */
1490
+ MtmRefreshClusterStatus (false);
1494
1491
}
1495
1492
}
1496
1493
@@ -2683,7 +2680,7 @@ Datum mtm_dump_lock_graph(PG_FUNCTION_ARGS)
2683
2680
for (i = 0 ; i < Mtm -> nAllNodes ; i ++ )
2684
2681
{
2685
2682
size_t size ;
2686
- char * data = RaftableGet (psprintf ("lock-graph-%d" , i + 1 ), & size , NULL , true );
2683
+ char * data = RaftableGet (psprintf ("lock-graph-%d" , i + 1 ), & size , NULL , false );
2687
2684
if (data ) {
2688
2685
GlobalTransactionId * gtid = (GlobalTransactionId * )data ;
2689
2686
GlobalTransactionId * last = (GlobalTransactionId * )(data + size );
@@ -3305,7 +3302,7 @@ MtmDetectGlobalDeadLock(PGPROC* proc)
3305
3302
for (i = 0 ; i < Mtm -> nAllNodes ; i ++ ) {
3306
3303
if (i + 1 != MtmNodeId && !BIT_CHECK (Mtm -> disabledNodeMask , i )) {
3307
3304
size_t size ;
3308
- void * data = RaftableGet (psprintf ("lock-graph-%d" , i + 1 ), & size , NULL , true );
3305
+ void * data = RaftableGet (psprintf ("lock-graph-%d" , i + 1 ), & size , NULL , false );
3309
3306
if (data == NULL ) {
3310
3307
return true; /* If using Raftable is disabled */
3311
3308
} else {
0 commit comments