@@ -973,7 +973,13 @@ static int64 MtmGetSlotLag(int nodeId)
973973 */
974974bool MtmIsRecoveredNode (int nodeId )
975975{
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+
977983 Assert (MyWalSnd != NULL ); /* This function is called by WAL-sender, so it should not be NULL */
978984 if (!BIT_CHECK (Mtm -> nodeLockerMask , nodeId - 1 )
979985 && MyWalSnd -> sentPtr + MtmMinRecoveryLag > GetXLogInsertRecPtr ())
@@ -1135,7 +1141,7 @@ bool MtmRefreshClusterStatus(bool nowait)
11351141 }
11361142 } else {
11371143 elog (WARNING , "Clique %lx has no quorum" , clique );
1138- Mtm -> status = MTM_IN_MINORITY ;
1144+ MtmSwitchClusterMode ( MTM_IN_MINORITY ) ;
11391145 }
11401146 return true;
11411147}
@@ -1145,12 +1151,12 @@ void MtmCheckQuorum(void)
11451151 if (Mtm -> nNodes < MtmNodes /2 + 1 ) {
11461152 if (Mtm -> status == MTM_ONLINE ) { /* out of quorum */
11471153 elog (WARNING , "Node is in minority: disabled mask %lx" , Mtm -> disabledNodeMask );
1148- Mtm -> status = MTM_IN_MINORITY ;
1154+ MtmSwitchClusterMode ( MTM_IN_MINORITY ) ;
11491155 }
11501156 } else {
11511157 if (Mtm -> status == MTM_IN_MINORITY ) {
11521158 elog (WARNING , "Node is in majority: dissbled mask %lx" , Mtm -> disabledNodeMask );
1153- Mtm -> status = MTM_ONLINE ;
1159+ MtmSwitchClusterMode ( MTM_ONLINE ) ;
11541160 }
11551161 }
11561162}
@@ -1696,6 +1702,19 @@ void MtmDropNode(int nodeId, bool dropSlot)
16961702 }
16971703}
16981704
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+
16991718static void
17001719MtmReplicationShutdownHook (struct PGLogicalShutdownHookArgs * args )
17011720{
@@ -1715,6 +1734,7 @@ MtmReplicationTxnFilterHook(struct PGLogicalTxnFilterArgs* args)
17151734
17161735void MtmSetupReplicationHooks (struct PGLogicalHooks * hooks )
17171736{
1737+ hooks -> startup_hook = MtmReplicationStartupHook ;
17181738 hooks -> shutdown_hook = MtmReplicationShutdownHook ;
17191739 hooks -> txn_filter_hook = MtmReplicationTxnFilterHook ;
17201740}
0 commit comments