@@ -973,7 +973,13 @@ static int64 MtmGetSlotLag(int nodeId)
973
973
*/
974
974
bool MtmIsRecoveredNode (int nodeId )
975
975
{
976
- if (BIT_CHECK (Mtm -> disabledNodeMask , nodeId - 1 )) {
976
+ return BIT_CHECK (Mtm -> disabledNodeMask , nodeId - 1 ));
977
+ }
978
+
979
+
980
+ void MtmRecoveryPorgress (XLogRecPtr lsn )
981
+ {
982
+
977
983
Assert (MyWalSnd != NULL ); /* This function is called by WAL-sender, so it should not be NULL */
978
984
if (!BIT_CHECK (Mtm -> nodeLockerMask , nodeId - 1 )
979
985
&& MyWalSnd -> sentPtr + MtmMinRecoveryLag > GetXLogInsertRecPtr ())
@@ -1135,7 +1141,7 @@ bool MtmRefreshClusterStatus(bool nowait)
1135
1141
}
1136
1142
} else {
1137
1143
elog (WARNING , "Clique %lx has no quorum" , clique );
1138
- Mtm -> status = MTM_IN_MINORITY ;
1144
+ MtmSwitchClusterMode ( MTM_IN_MINORITY ) ;
1139
1145
}
1140
1146
return true;
1141
1147
}
@@ -1145,12 +1151,12 @@ void MtmCheckQuorum(void)
1145
1151
if (Mtm -> nNodes < MtmNodes /2 + 1 ) {
1146
1152
if (Mtm -> status == MTM_ONLINE ) { /* out of quorum */
1147
1153
elog (WARNING , "Node is in minority: disabled mask %lx" , Mtm -> disabledNodeMask );
1148
- Mtm -> status = MTM_IN_MINORITY ;
1154
+ MtmSwitchClusterMode ( MTM_IN_MINORITY ) ;
1149
1155
}
1150
1156
} else {
1151
1157
if (Mtm -> status == MTM_IN_MINORITY ) {
1152
1158
elog (WARNING , "Node is in majority: dissbled mask %lx" , Mtm -> disabledNodeMask );
1153
- Mtm -> status = MTM_ONLINE ;
1159
+ MtmSwitchClusterMode ( MTM_ONLINE ) ;
1154
1160
}
1155
1161
}
1156
1162
}
@@ -1696,6 +1702,19 @@ void MtmDropNode(int nodeId, bool dropSlot)
1696
1702
}
1697
1703
}
1698
1704
1705
+ static void
1706
+ MtmReplicationStartupHook (struct PGLogicalStartupHookArgs * args )
1707
+ {
1708
+ MtmLock (LW_EXCLUSIVE );
1709
+ if (BIT_CHECK (Mtm -> disabledNodeMask , MtmReplicationNodeId - 1 )) {
1710
+ elog (WARNING , "Recovery of node %d is completed: start normal replication" , MtmReplicationNodeId );
1711
+ BIT_CLEAR (Mtm -> disabledNodeMask , MtmReplicationNodeId - 1 );
1712
+ Mtm -> nNodes += 1 ;
1713
+ MtmCheckQuorum ();
1714
+ }
1715
+ MtmUnlock ();
1716
+ }
1717
+
1699
1718
static void
1700
1719
MtmReplicationShutdownHook (struct PGLogicalShutdownHookArgs * args )
1701
1720
{
@@ -1715,6 +1734,7 @@ MtmReplicationTxnFilterHook(struct PGLogicalTxnFilterArgs* args)
1715
1734
1716
1735
void MtmSetupReplicationHooks (struct PGLogicalHooks * hooks )
1717
1736
{
1737
+ hooks -> startup_hook = MtmReplicationStartupHook ;
1718
1738
hooks -> shutdown_hook = MtmReplicationShutdownHook ;
1719
1739
hooks -> txn_filter_hook = MtmReplicationTxnFilterHook ;
1720
1740
}
0 commit comments