Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f78894b

Browse files
knizhnikkelvich
authored andcommitted
Recovery in progress
1 parent 1d135e6 commit f78894b

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

arbiter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static void MtmOpenConnections()
376376
}
377377
if (Mtm->nNodes < MtmNodes/2+1) { /* no quorum */
378378
elog(WARNING, "Node is out of quorum: only %d nodes from %d are accssible", Mtm->nNodes, MtmNodes);
379-
Mtm->status = MTM_IN_MINORITY;
379+
MtmSwitchClusterMode(MTM_IN_MINORITY);
380380
} else if (Mtm->status == MTM_INITIALIZATION) {
381381
MtmSwitchClusterMode(MTM_CONNECTED);
382382
}

multimaster.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,13 @@ static int64 MtmGetSlotLag(int nodeId)
972972
*/
973973
bool 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+
976982
Assert(MyWalSnd != NULL); /* This function is called by WAL-sender, so it should not be NULL */
977983
if (!BIT_CHECK(Mtm->nodeLockerMask, nodeId-1)
978984
&& MyWalSnd->sentPtr + MtmMinRecoveryLag > GetXLogInsertRecPtr())
@@ -1134,7 +1140,7 @@ bool MtmRefreshClusterStatus(bool nowait)
11341140
}
11351141
} else {
11361142
elog(WARNING, "Clique %lx has no quorum", clique);
1137-
Mtm->status = MTM_IN_MINORITY;
1143+
MtmSwitchClusterMode(MTM_IN_MINORITY);
11381144
}
11391145
return true;
11401146
}
@@ -1144,12 +1150,12 @@ void MtmCheckQuorum(void)
11441150
if (Mtm->nNodes < MtmNodes/2+1) {
11451151
if (Mtm->status == MTM_ONLINE) { /* out of quorum */
11461152
elog(WARNING, "Node is in minority: disabled mask %lx", Mtm->disabledNodeMask);
1147-
Mtm->status = MTM_IN_MINORITY;
1153+
MtmSwitchClusterMode(MTM_IN_MINORITY);
11481154
}
11491155
} else {
11501156
if (Mtm->status == MTM_IN_MINORITY) {
11511157
elog(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+
16981717
static void
16991718
MtmReplicationShutdownHook(struct PGLogicalShutdownHookArgs* args)
17001719
{
@@ -1714,6 +1733,7 @@ MtmReplicationTxnFilterHook(struct PGLogicalTxnFilterArgs* args)
17141733

17151734
void MtmSetupReplicationHooks(struct PGLogicalHooks* hooks)
17161735
{
1736+
hooks->startup_hook = MtmReplicationStartupHook;
17171737
hooks->shutdown_hook = MtmReplicationShutdownHook;
17181738
hooks->txn_filter_hook = MtmReplicationTxnFilterHook;
17191739
}

0 commit comments

Comments
 (0)