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