@@ -232,6 +232,7 @@ static ExecutorFinish_hook_type PreviousExecutorFinishHook;
232
232
static ProcessUtility_hook_type PreviousProcessUtilityHook ;
233
233
static shmem_startup_hook_type PreviousShmemStartupHook ;
234
234
235
+ static nodemask_t lastKnownMatrix [MAX_NODES ];
235
236
236
237
static void MtmExecutorFinish (QueryDesc * queryDesc );
237
238
static void MtmProcessUtility (Node * parsetree , const char * queryString ,
@@ -1368,8 +1369,8 @@ static void MtmEnableNode(int nodeId)
1368
1369
void MtmRecoveryCompleted (void )
1369
1370
{
1370
1371
int i ;
1371
- MTM_LOG1 ("Recovery of node %d is completed, disabled mask=%lx , connectivity mask=%lx , live nodes=%d" ,
1372
- MtmNodeId , Mtm -> disabledNodeMask , Mtm -> connectivityMask , Mtm -> nLiveNodes );
1372
+ MTM_LOG1 ("Recovery of node %d is completed, disabled mask=%llx , connectivity mask=%llx , live nodes=%d" ,
1373
+ MtmNodeId , ( long long ) Mtm -> disabledNodeMask , ( long long ) Mtm -> connectivityMask , Mtm -> nLiveNodes );
1373
1374
MtmLock (LW_EXCLUSIVE );
1374
1375
Mtm -> recoverySlot = 0 ;
1375
1376
BIT_CLEAR (Mtm -> disabledNodeMask , MtmNodeId - 1 );
@@ -1563,7 +1564,8 @@ static bool
1563
1564
MtmBuildConnectivityMatrix (nodemask_t * matrix , bool nowait )
1564
1565
{
1565
1566
int i , j , n = Mtm -> nAllNodes ;
1566
- fprintf (stderr , "Connectivity matrix:\n" );
1567
+ bool changed = false;
1568
+
1567
1569
for (i = 0 ; i < n ; i ++ ) {
1568
1570
if (i + 1 != MtmNodeId ) {
1569
1571
void * data = RaftableGet (psprintf ("node-mask-%d" , i + 1 ), NULL , NULL , nowait );
@@ -1574,12 +1576,27 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
1574
1576
} else {
1575
1577
matrix [i ] = Mtm -> connectivityMask ;
1576
1578
}
1577
- for (j = 0 ; j < n ; j ++ ) {
1578
- putc (BIT_CHECK (matrix [i ], j ) ? 'X' : '+' , stderr );
1579
+
1580
+ if (lastKnownMatrix [i ] != matrix [i ])
1581
+ {
1582
+ changed = true;
1583
+ lastKnownMatrix [i ] = matrix [i ];
1579
1584
}
1580
- putc ('\n' , stderr );
1581
1585
}
1582
- fputs ("-----------------------\n" , stderr );
1586
+
1587
+ /* Print matrix if changed */
1588
+ if (changed )
1589
+ {
1590
+ fprintf (stderr , "Connectivity matrix:\n" );
1591
+ for (i = 0 ; i < n ; i ++ )
1592
+ {
1593
+ for (j = 0 ; j < n ; j ++ )
1594
+ putc (BIT_CHECK (matrix [i ], j ) ? 'X' : '+' , stderr );
1595
+ putc ('\n' , stderr );
1596
+ }
1597
+ fputs ("-----------------------\n" , stderr );
1598
+ }
1599
+
1583
1600
/* make matrix symetric: required for Bron–Kerbosch algorithm */
1584
1601
for (i = 0 ; i < n ; i ++ ) {
1585
1602
for (j = 0 ; j < i ; j ++ ) {
@@ -1588,8 +1605,9 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
1588
1605
}
1589
1606
matrix [i ] &= ~((nodemask_t )1 << i );
1590
1607
}
1608
+
1591
1609
return true;
1592
- }
1610
+ }
1593
1611
1594
1612
1595
1613
/**
@@ -1610,6 +1628,11 @@ bool MtmRefreshClusterStatus(bool nowait, int testNodeId)
1610
1628
}
1611
1629
1612
1630
clique = MtmFindMaxClique (matrix , Mtm -> nAllNodes , & clique_size );
1631
+
1632
+ if ( clique == (~Mtm -> disabledNodeMask & (((nodemask_t )1 << Mtm -> nAllNodes )- 1 )) )
1633
+ /* Nothing is changed */
1634
+ return false;
1635
+
1613
1636
if (clique_size >= Mtm -> nAllNodes /2 + 1 ) { /* have quorum */
1614
1637
fprintf (stderr , "Old mask: " );
1615
1638
for (i = 0 ; i < Mtm -> nAllNodes ; i ++ ) {
@@ -1648,7 +1671,7 @@ bool MtmRefreshClusterStatus(bool nowait, int testNodeId)
1648
1671
/* Interrupt voting for active transaction and abort them */
1649
1672
for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1650
1673
MTM_LOG3 ("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d" ,
1651
- ts -> gid , ts -> gtid .nхode , ts -> xid , ts -> status , ts -> gtid .xid );
1674
+ ts -> gid , ts -> gtid .node , ts -> xid , ts -> status , ts -> gtid .xid );
1652
1675
if (MtmIsCoordinator (ts )) {
1653
1676
if (!ts -> votingCompleted && disabled != 0 && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1654
1677
MtmAbortTransaction (ts );
@@ -1705,7 +1728,7 @@ void MtmOnNodeDisconnect(int nodeId)
1705
1728
MtmLock (LW_EXCLUSIVE );
1706
1729
BIT_SET (Mtm -> connectivityMask , nodeId - 1 );
1707
1730
BIT_SET (Mtm -> reconnectMask , nodeId - 1 );
1708
- MTM_LOG1 ("Disconnect node %d connectivity mask %lx " , nodeId , Mtm -> connectivityMask );
1731
+ MTM_LOG1 ("Disconnect node %d connectivity mask %llx " , nodeId , ( long long ) Mtm -> connectivityMask );
1709
1732
MtmUnlock ();
1710
1733
1711
1734
if (!RaftableSet (psprintf ("node-mask-%d" , MtmNodeId ), & Mtm -> connectivityMask , sizeof Mtm -> connectivityMask , false))
@@ -1755,7 +1778,7 @@ void MtmOnNodeConnect(int nodeId)
1755
1778
BIT_CLEAR (Mtm -> reconnectMask , nodeId - 1 );
1756
1779
MtmUnlock ();
1757
1780
1758
- MTM_LOG1 ("Reconnect node %d, connectivityMask=%lx " , nodeId , Mtm -> connectivityMask );
1781
+ MTM_LOG1 ("Reconnect node %d, connectivityMask=%llx " , nodeId , ( long long ) Mtm -> connectivityMask );
1759
1782
RaftableSet (psprintf ("node-mask-%d" , MtmNodeId ), & Mtm -> connectivityMask , sizeof Mtm -> connectivityMask , false);
1760
1783
}
1761
1784
@@ -3579,7 +3602,12 @@ static void MtmGucSet(VariableSetStmt *stmt, const char *queryStr)
3579
3602
hash_search (MtmGucHash , key , HASH_REMOVE , NULL );
3580
3603
}
3581
3604
break ;
3605
+
3582
3606
case VAR_RESET_ALL :
3607
+ {
3608
+ hash_destroy (MtmGucHash );
3609
+ MtmGucHashInit ();
3610
+ }
3583
3611
break ;
3584
3612
3585
3613
case VAR_SET_MULTI :
@@ -3591,7 +3619,11 @@ static void MtmGucSet(VariableSetStmt *stmt, const char *queryStr)
3591
3619
3592
3620
static void MtmGucDiscard (DiscardStmt * stmt )
3593
3621
{
3594
-
3622
+ if (stmt -> target == DISCARD_ALL )
3623
+ {
3624
+ hash_destroy (MtmGucHash );
3625
+ MtmGucHashInit ();
3626
+ }
3595
3627
}
3596
3628
3597
3629
static void MtmGucClear (void )
@@ -3616,7 +3648,18 @@ static char * MtmGucSerialize(void)
3616
3648
appendStringInfoString (serialized_gucs , "SET " );
3617
3649
appendStringInfoString (serialized_gucs , hentry -> key );
3618
3650
appendStringInfoString (serialized_gucs , " TO " );
3619
- appendStringInfoString (serialized_gucs , hentry -> value );
3651
+
3652
+ /* quite a crutch */
3653
+ if (strcmp (hentry -> key , "work_mem" ) == 0 )
3654
+ {
3655
+ appendStringInfoString (serialized_gucs , "'" );
3656
+ appendStringInfoString (serialized_gucs , hentry -> value );
3657
+ appendStringInfoString (serialized_gucs , "'" );
3658
+ }
3659
+ else
3660
+ {
3661
+ appendStringInfoString (serialized_gucs , hentry -> value );
3662
+ }
3620
3663
appendStringInfoString (serialized_gucs , "; " );
3621
3664
}
3622
3665
}
@@ -3838,6 +3881,7 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
3838
3881
{
3839
3882
MTM_LOG1 ("Xact accessed temp table, stopping replication" );
3840
3883
MtmTx .isDistributed = false; /* Skip */
3884
+ MtmTx .snapshot = INVALID_CSN ;
3841
3885
}
3842
3886
3843
3887
}
0 commit comments