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