@@ -139,6 +139,8 @@ HTAB* MtmXid2State;
139
139
static HTAB * MtmGid2State ;
140
140
static HTAB * MtmLocalTables ;
141
141
142
+ static bool MtmIsRecoverySession ;
143
+
142
144
static MtmCurrentTrans MtmTx ;
143
145
144
146
static TransactionManager MtmTM = {
@@ -1022,7 +1024,15 @@ static int64 MtmGetSlotLag(int nodeId)
1022
1024
*/
1023
1025
bool MtmIsRecoveredNode (int nodeId )
1024
1026
{
1025
- return BIT_CHECK (Mtm -> disabledNodeMask , nodeId - 1 );
1027
+ if (BIT_CHECK (Mtm -> disabledNodeMask , nodeId - 1 )) {
1028
+ if (!MtmIsRecoverySession ) {
1029
+ elog (ERROR , "Node %d is marked as disabled but is not in recovery mode" , nodeId );
1030
+ }
1031
+ return true;
1032
+ } else {
1033
+ MtmIsRecoverySession = false; /* recovery is completed */
1034
+ return false;
1035
+ }
1026
1036
}
1027
1037
1028
1038
@@ -1871,17 +1881,17 @@ static void
1871
1881
MtmReplicationStartupHook (struct PGLogicalStartupHookArgs * args )
1872
1882
{
1873
1883
ListCell * param ;
1874
- bool isRecoverySession = false;
1884
+ MtmIsRecoverySession = false;
1875
1885
foreach (param , args -> in_params )
1876
1886
{
1877
1887
DefElem * elem = lfirst (param );
1878
1888
if (strcmp ("mtm_replication_mode" , elem -> defname ) == 0 ) {
1879
- isRecoverySession = elem -> arg != NULL && strVal (elem -> arg ) != NULL && strcmp (strVal (elem -> arg ), "recovery" ) == 0 ;
1889
+ MtmIsRecoverySession = elem -> arg != NULL && strVal (elem -> arg ) != NULL && strcmp (strVal (elem -> arg ), "recovery" ) == 0 ;
1880
1890
break ;
1881
1891
}
1882
1892
}
1883
1893
MtmLock (LW_EXCLUSIVE );
1884
- if (isRecoverySession ) {
1894
+ if (MtmIsRecoverySession ) {
1885
1895
elog (WARNING , "%d: Node %d start recovery of node %d" , MyProcPid , MtmNodeId , MtmReplicationNodeId );
1886
1896
if (!BIT_CHECK (Mtm -> disabledNodeMask , MtmReplicationNodeId - 1 )) {
1887
1897
BIT_SET (Mtm -> disabledNodeMask , MtmReplicationNodeId - 1 );
0 commit comments