Skip to content

Commit 8c7c4d9

Browse files
committed
Fix pgxc_ctl to use pg_basebackup and ALTER NODE for coordinator slave
initialization and coordinator failover.
1 parent 60dec44 commit 8c7c4d9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

contrib/pgxc_ctl/coord_cmd.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include "coord_cmd.h"
3434
#include "gtm_util.h"
3535

36+
/* Tune-up base-backup and ALTER NODE usage for slave and failover */
37+
#define USE_PG_BASEBACKUP
38+
#define USE_ALTER_NODE
3639

3740
static int failover_oneCoordinator(int coordIdx);
3841

@@ -233,7 +236,7 @@ cmd_t *prepare_initCoordinatorSlave(char *nodeName)
233236
cmd_t *cmd,
234237
*cmdBuildDir,
235238
*cmdStartMaster,
236-
#if 0
239+
#ifdef USE_PG_BASEBACKUP
237240
*cmdBaseBkup,
238241
#else
239242
/*
@@ -286,7 +289,7 @@ cmd_t *prepare_initCoordinatorSlave(char *nodeName)
286289
/*
287290
* Obtain base backup of the master
288291
*/
289-
#if 0
292+
#ifdef USE_PG_BASEBACKUP
290293
appendCmdEl(cmdBuildDir, (cmdBaseBkup = initCmd(aval(VAR_coordSlaveServers)[idx])));
291294
snprintf(newCommand(cmdBaseBkup), MAXLINE,
292295
"pg_basebackup -p %s -h %s -D %s -x",
@@ -1152,7 +1155,7 @@ int add_coordinatorSlave(char *name, char *host, char *dir, char *archDir)
11521155
"pg_ctl stop -Z coordinator -D %s -m fast", aval(VAR_coordMasterDirs)[idx]);
11531156
doImmediate(aval(VAR_coordMasterServers)[idx], NULL,
11541157
"pg_ctl start -Z coordinator -D %s -w", aval(VAR_coordMasterDirs)[idx]);
1155-
#if 0
1158+
#ifdef USE_PG_BASEBACKUP
11561159
/* pg_basebackup */
11571160
doImmediate(host, NULL, "pg_basebackup -p %s -h %s -D %s -x",
11581161
aval(VAR_coordPorts)[idx], aval(VAR_coordMasterServers)[idx], dir);
@@ -1932,17 +1935,21 @@ static int failover_oneCoordinator(int coordIdx)
19321935
elog(ERROR, "ERROR: failed to start psql for coordinator %s, %s\n", aval(VAR_coordNames)[jj], strerror(errno));
19331936
continue;
19341937
}
1938+
#ifdef USE_ALTER_NODE /* Now alter node dies not work well in this context. */
19351939
fprintf(f,
1936-
#if 0 /* Now alter node dies not work well in this context. */
19371940
"ALTER NODE %s WITH (HOST='%s', PORT=%s);\n"
1941+
"select pgxc_pool_reload();\n"
1942+
"\\q\n",
1943+
aval(VAR_coordNames)[coordIdx], aval(VAR_coordMasterServers)[coordIdx], aval(VAR_coordPorts)[coordIdx]);
19381944
#else
1945+
fprintf(f,
19391946
"DROP NODE %s;\n"
19401947
"CREATE NODE %s WITH (type = coordinator, HOST='%s', PORT=%s);\n"
1941-
#endif
19421948
"select pgxc_pool_reload();\n"
19431949
"\\q\n",
19441950
aval(VAR_coordNames)[coordIdx],
19451951
aval(VAR_coordNames)[coordIdx], aval(VAR_coordMasterServers)[coordIdx], aval(VAR_coordPorts)[coordIdx]);
1952+
#endif
19461953
fclose(f);
19471954
}
19481955
}

0 commit comments

Comments
 (0)