Skip to content

Commit c5776fb

Browse files
committed
Support adding new node
1 parent bbf83b2 commit c5776fb

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

contrib/mmts/multimaster--1.0.sql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ CREATE FUNCTION mtm.drop_node(node integer, drop_slot bool default false) RETURN
1313
AS 'MODULE_PATHNAME','mtm_drop_node'
1414
LANGUAGE C;
1515

16-
-- -- XXX: cstring as an argument breaks sanity check
17-
-- CREATE FUNCTION mtm.add_node(conn_str cstring) RETURNS void
18-
-- AS 'MODULE_PATHNAME','mtm_add_node'
19-
-- LANGUAGE C;
16+
CREATE FUNCTION mtm.add_node(conn_str cstring) RETURNS void
17+
AS 'MODULE_PATHNAME','mtm_add_node'
18+
LANGUAGE C;
2019

2120
-- Create replication slot for the node which was previously dropped together with it's slot
2221
CREATE FUNCTION mtm.recover_node(node integer) RETURNS void

contrib/mmts/multimaster.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ static void MtmCheckControlFile(void)
19331933
if (f == NULL) {
19341934
elog(FATAL, "Failed to create mmts_control file: %m");
19351935
}
1936-
Mtm->donorNodeId = -1;
1936+
Mtm->donorNodeId = MtmNodeId;
19371937
fprintf(f, "%s:%d\n", MtmClusterName, Mtm->donorNodeId);
19381938
fclose(f);
19391939
}
@@ -2707,7 +2707,7 @@ MtmReplicationMode MtmGetReplicationMode(int nodeId, sig_atomic_t volatile* shut
27072707
MtmLock(LW_EXCLUSIVE);
27082708
if (Mtm->status == MTM_RECOVERY) {
27092709
recovery = true;
2710-
if ((Mtm->recoverySlot == 0 && (Mtm->donorNodeId < 0 || Mtm->donorNodeId == nodeId))
2710+
if ((Mtm->recoverySlot == 0 && (Mtm->donorNodeId == MtmNodeId || Mtm->donorNodeId == nodeId))
27112711
|| Mtm->recoverySlot == nodeId)
27122712
{
27132713
/* Choose for recovery first available slot or slot of donor node (if any) */
@@ -2820,7 +2820,7 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
28202820
}
28212821
} else if (strcmp("mtm_restart_pos", elem->defname) == 0) {
28222822
if (elem->arg != NULL && strVal(elem->arg) != NULL) {
2823-
recoveryStartPos = intVal(elem->arg);
2823+
sscanf(strVal(elem->arg), "%lx", &recoveryStartPos);
28242824
} else {
28252825
elog(ERROR, "Restart position is not specified");
28262826
}

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