Skip to content

Commit a44ae25

Browse files
committed
more price handling of recovery mode
1 parent 254d802 commit a44ae25

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

contrib/mmts/multimaster.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,12 +1882,23 @@ static void
18821882
MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
18831883
{
18841884
ListCell *param;
1885+
bool recoveryCompleted = false;
18851886
MtmIsRecoverySession = false;
18861887
foreach(param, args->in_params)
18871888
{
18881889
DefElem *elem = lfirst(param);
18891890
if (strcmp("mtm_replication_mode", elem->defname) == 0) {
1890-
MtmIsRecoverySession = elem->arg != NULL && strVal(elem->arg) != NULL && strcmp(strVal(elem->arg), "recovery") == 0;
1891+
if (elem->arg != NULL && strVal(elem->arg) != NULL) {
1892+
if (strcmp(strVal(elem->arg), "recovery") == 0) {
1893+
MtmIsRecoverySession = true;
1894+
} else if (strcmp(strVal(elem->arg), "recovered") == 0) {
1895+
recoveryCompleted = true;
1896+
} else if (strcmp(strVal(elem->arg), "normal") != 0) {
1897+
elog(ERROR, "Illegal recovery mode %s", strVal(elem->arg));
1898+
}
1899+
} else {
1900+
elog(ERROR, "Replication mode is not specified");
1901+
}
18911902
break;
18921903
}
18931904
}
@@ -1900,10 +1911,14 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
19001911
MtmCheckQuorum();
19011912
}
19021913
} else if (BIT_CHECK(Mtm->disabledNodeMask, MtmReplicationNodeId-1)) {
1903-
elog(WARNING, "Node %d consider that recovery of node %d is completed: start normal replication", MtmNodeId, MtmReplicationNodeId);
1904-
BIT_CLEAR(Mtm->disabledNodeMask, MtmReplicationNodeId-1);
1905-
Mtm->nNodes += 1;
1906-
MtmCheckQuorum();
1914+
if (recoveryCompleted) {
1915+
elog(WARNING, "Node %d consider that recovery of node %d is completed: start normal replication", MtmNodeId, MtmReplicationNodeId);
1916+
BIT_CLEAR(Mtm->disabledNodeMask, MtmReplicationNodeId-1);
1917+
Mtm->nNodes += 1;
1918+
MtmCheckQuorum();
1919+
} else {
1920+
elog(ERROR, "Disabled node %d tries to reconnect without recovery", MtmReplicationNodeId);
1921+
}
19071922
} else {
19081923
elog(NOTICE, "Node %d start logical replication to node %d in normal mode", MtmNodeId, MtmReplicationNodeId);
19091924
}

contrib/mmts/pglogical_receiver.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ feTimestampDifference(int64 start_time, int64 stop_time,
196196
}
197197
}
198198

199+
static char const* const MtmReplicationModeName[] =
200+
{
201+
"recovered", /* SLOT_CREATE_NEW: recovery of node is completed so drop old slot and restart replication from the current position in WAL */
202+
"recovery", /* SLOT_OPEN_EXISTED: perform recorvery of the node by applying all data from theslot from specified point */
203+
"normal" /* SLOT_OPEN_ALWAYS: normal mode: use existeed slot or create new one and start receiving data from it from the specified position */
204+
};
205+
199206
static void
200207
pglogical_receiver_main(Datum main_arg)
201208
{
@@ -298,7 +305,7 @@ pglogical_receiver_main(Datum main_arg)
298305
(uint32) originStartPos,
299306
MULTIMASTER_MAX_PROTO_VERSION,
300307
MULTIMASTER_MIN_PROTO_VERSION,
301-
mode == SLOT_OPEN_EXISTED ? "recovery" : "normal"
308+
MtmReplicationModeName[mode]
302309
);
303310
res = PQexec(conn, query->data);
304311
if (PQresultStatus(res) != PGRES_COPY_BOTH)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy