@@ -972,7 +972,13 @@ static int64 MtmGetSlotLag(int nodeId)
972972 */
973973bool MtmIsRecoveredNode (int nodeId )
974974{
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+
976982Assert (MyWalSnd != NULL );/* This function is called by WAL-sender, so it should not be NULL */
977983if (!BIT_CHECK (Mtm -> nodeLockerMask ,nodeId - 1 )
978984&& MyWalSnd -> sentPtr + MtmMinRecoveryLag > GetXLogInsertRecPtr ())
@@ -1134,7 +1140,7 @@ bool MtmRefreshClusterStatus(bool nowait)
11341140}
11351141}else {
11361142elog (WARNING ,"Clique %lx has no quorum" ,clique );
1137- Mtm -> status = MTM_IN_MINORITY ;
1143+ MtmSwitchClusterMode ( MTM_IN_MINORITY ) ;
11381144}
11391145return true;
11401146}
@@ -1144,12 +1150,12 @@ void MtmCheckQuorum(void)
11441150if (Mtm -> nNodes < MtmNodes /2 + 1 ) {
11451151if (Mtm -> status == MTM_ONLINE ) {/* out of quorum */
11461152elog (WARNING ,"Node is in minority: disabled mask %lx" ,Mtm -> disabledNodeMask );
1147- Mtm -> status = MTM_IN_MINORITY ;
1153+ MtmSwitchClusterMode ( MTM_IN_MINORITY ) ;
11481154}
11491155}else {
11501156if (Mtm -> status == MTM_IN_MINORITY ) {
11511157elog (WARNING ,"Node is in majority: dissbled mask %lx" ,Mtm -> disabledNodeMask );
1152- Mtm -> status = MTM_ONLINE ;
1158+ MtmSwitchClusterMode ( MTM_ONLINE ) ;
11531159}
11541160}
11551161}
@@ -1695,6 +1701,19 @@ void MtmDropNode(int nodeId, bool dropSlot)
16951701}
16961702}
16971703
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+
16981717static void
16991718MtmReplicationShutdownHook (struct PGLogicalShutdownHookArgs * args )
17001719{
@@ -1714,6 +1733,7 @@ MtmReplicationTxnFilterHook(struct PGLogicalTxnFilterArgs* args)
17141733
17151734void MtmSetupReplicationHooks (struct PGLogicalHooks * hooks )
17161735{
1736+ hooks -> startup_hook = MtmReplicationStartupHook ;
17171737hooks -> shutdown_hook = MtmReplicationShutdownHook ;
17181738hooks -> txn_filter_hook = MtmReplicationTxnFilterHook ;
17191739}