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