@@ -230,6 +230,7 @@ static ExecutorFinish_hook_type PreviousExecutorFinishHook;
230
230
static ProcessUtility_hook_type PreviousProcessUtilityHook ;
231
231
static shmem_startup_hook_type PreviousShmemStartupHook ;
232
232
233
+ static nodemask_t lastKnownMatrix [MAX_NODES ];
233
234
234
235
static void MtmExecutorFinish (QueryDesc * queryDesc );
235
236
static void MtmProcessUtility (Node * parsetree , const char * queryString ,
@@ -1552,7 +1553,8 @@ static bool
1552
1553
MtmBuildConnectivityMatrix (nodemask_t * matrix , bool nowait )
1553
1554
{
1554
1555
int i , j , n = Mtm -> nAllNodes ;
1555
- fprintf (stderr , "Connectivity matrix:\n" );
1556
+ bool changed = false;
1557
+
1556
1558
for (i = 0 ; i < n ; i ++ ) {
1557
1559
if (i + 1 != MtmNodeId ) {
1558
1560
void * data = RaftableGet (psprintf ("node-mask-%d" , i + 1 ), NULL , NULL , nowait );
@@ -1563,12 +1565,27 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
1563
1565
} else {
1564
1566
matrix [i ] = Mtm -> connectivityMask ;
1565
1567
}
1566
- for (j = 0 ; j < n ; j ++ ) {
1567
- putc (BIT_CHECK (matrix [i ], j ) ? 'X' : '+' , stderr );
1568
+
1569
+ if (lastKnownMatrix [i ] != matrix [i ])
1570
+ {
1571
+ changed = true;
1572
+ lastKnownMatrix [i ] = matrix [i ];
1568
1573
}
1569
- putc ('\n' , stderr );
1570
1574
}
1571
- fputs ("-----------------------\n" , stderr );
1575
+
1576
+ /* Print matrix if changed */
1577
+ if (changed )
1578
+ {
1579
+ fprintf (stderr , "Connectivity matrix:\n" );
1580
+ for (i = 0 ; i < n ; i ++ )
1581
+ {
1582
+ for (j = 0 ; j < n ; j ++ )
1583
+ putc (BIT_CHECK (matrix [i ], j ) ? 'X' : '+' , stderr );
1584
+ putc ('\n' , stderr );
1585
+ }
1586
+ fputs ("-----------------------\n" , stderr );
1587
+ }
1588
+
1572
1589
/* make matrix symetric: required for Bron–Kerbosch algorithm */
1573
1590
for (i = 0 ; i < n ; i ++ ) {
1574
1591
for (j = 0 ; j < i ; j ++ ) {
@@ -1577,8 +1594,9 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
1577
1594
}
1578
1595
matrix [i ] &= ~((nodemask_t )1 << i );
1579
1596
}
1597
+
1580
1598
return true;
1581
- }
1599
+ }
1582
1600
1583
1601
1584
1602
/**
@@ -1599,6 +1617,11 @@ bool MtmRefreshClusterStatus(bool nowait, int testNodeId)
1599
1617
}
1600
1618
1601
1619
clique = MtmFindMaxClique (matrix , Mtm -> nAllNodes , & clique_size );
1620
+
1621
+ if ( clique == (~Mtm -> disabledNodeMask & (((nodemask_t )1 << Mtm -> nAllNodes )- 1 )) )
1622
+ /* Nothing is changed */
1623
+ return false;
1624
+
1602
1625
if (clique_size >= Mtm -> nAllNodes /2 + 1 ) { /* have quorum */
1603
1626
fprintf (stderr , "Old mask: " );
1604
1627
for (i = 0 ; i < Mtm -> nAllNodes ; i ++ ) {
@@ -1729,7 +1752,7 @@ void MtmOnNodeDisconnect(int nodeId)
1729
1752
}
1730
1753
}
1731
1754
MtmUnlock ();
1732
- } else {
1755
+ } else {
1733
1756
MtmRefreshClusterStatus (false, 0 );
1734
1757
}
1735
1758
}
0 commit comments