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