diff options
author | Pavan Deolasee | 2016-04-01 06:26:57 +0000 |
---|---|---|
committer | Pavan Deolasee | 2016-10-18 10:05:04 +0000 |
commit | 966c1fa1cbfeb71346494c33ad20746d6b0830ed (patch) | |
tree | ee42c35c76e9b649a74660bc6ea60f336160d3e4 | |
parent | 1124f5e21ad87cc166cf474ef01622830f3b978c (diff) |
Extend the array for various slave variables to match the size of the master
array.
This fixes the problem when a slave for only one master datanode or coordinator
is added, as demonstrated by the tap tests
-rw-r--r-- | contrib/pgxc_ctl/coord_cmd.c | 22 | ||||
-rw-r--r-- | contrib/pgxc_ctl/datanode_cmd.c | 26 |
2 files changed, 27 insertions, 21 deletions
diff --git a/contrib/pgxc_ctl/coord_cmd.c b/contrib/pgxc_ctl/coord_cmd.c index c3c67520ad..de4d622f6e 100644 --- a/contrib/pgxc_ctl/coord_cmd.c +++ b/contrib/pgxc_ctl/coord_cmd.c @@ -1248,6 +1248,7 @@ int add_coordinatorSlave(char *name, char *host, int port, int pooler_port, char char port_s[MAXTOKEN+1]; char pooler_s[MAXTOKEN+1]; int kk; + int size; /* Check if the name is valid coordinator */ if ((idx = coordIdx(name)) < 0) @@ -1338,23 +1339,24 @@ int add_coordinatorSlave(char *name, char *host, int port, int pooler_port, char sval(VAR_pgxcOwner), getIpAddress(host)); pclose(f); /* Reconfigure pgxc_ctl configuration with the new slave */ + size = arraySizeName(VAR_coordNames); /* Need an API to expand the array to desired size */ - if ((extendVar(VAR_coordSlaveServers, idx + 1, "none") != 0) || - (extendVar(VAR_coordSlaveDirs, idx + 1, "none") != 0) || - (extendVar(VAR_coordSlavePorts, idx + 1, "none") != 0) || - (extendVar(VAR_coordSlavePoolerPorts, idx + 1, "none") != 0) || - (extendVar(VAR_coordArchLogDirs, idx + 1, "none") != 0)) + if ((extendVar(VAR_coordSlaveServers, size, "none") != 0) || + (extendVar(VAR_coordSlaveDirs, size, "none") != 0) || + (extendVar(VAR_coordSlavePorts, size, "none") != 0) || + (extendVar(VAR_coordSlavePoolerPorts, size, "none") != 0) || + (extendVar(VAR_coordArchLogDirs, size, "none") != 0)) { elog(PANIC, "PANIC: Internal error, inconsistent coordinator information\n"); return 1; } if (!isVarYes(VAR_coordSlave)) assign_sval(VAR_coordSlave, "y"); - assign_arrayEl(VAR_coordSlaveServers, idx, host, NULL); - assign_arrayEl(VAR_coordSlavePorts, idx, port_s, NULL); - assign_arrayEl(VAR_coordSlavePoolerPorts, idx, pooler_s, NULL); - assign_arrayEl(VAR_coordSlaveDirs, idx, dir, NULL); - assign_arrayEl(VAR_coordArchLogDirs, idx, archDir, NULL); + replace_arrayEl(VAR_coordSlaveServers, idx, host, NULL); + replace_arrayEl(VAR_coordSlavePorts, idx, port_s, NULL); + replace_arrayEl(VAR_coordSlavePoolerPorts, idx, pooler_s, NULL); + replace_arrayEl(VAR_coordSlaveDirs, idx, dir, NULL); + replace_arrayEl(VAR_coordArchLogDirs, idx, archDir, NULL); /* Update the configuration file and backup it */ if ((f = fopen(pgxc_ctl_config_path, "a")) == NULL) { diff --git a/contrib/pgxc_ctl/datanode_cmd.c b/contrib/pgxc_ctl/datanode_cmd.c index c9d4731ba2..3d639ff79c 100644 --- a/contrib/pgxc_ctl/datanode_cmd.c +++ b/contrib/pgxc_ctl/datanode_cmd.c @@ -1299,6 +1299,7 @@ int add_datanodeSlave(char *name, char *host, int port, int pooler, char *dir, char pooler_s[MAXTOKEN+1]; int kk; bool wal; + int size; if (walDir && (strcasecmp(walDir, "none") != 0)) wal = true; @@ -1396,12 +1397,15 @@ int add_datanodeSlave(char *name, char *host, int port, int pooler, char *dir, "# End of addition ===============================\n", sval(VAR_pgxcOwner), getIpAddress(host)); pclose(f); + + size = arraySizeName(VAR_datanodeNames); /* Need an API to expand the array to desired size */ - if ((extendVar(VAR_datanodeSlaveServers, idx + 1, "none") != 0) || - (extendVar(VAR_datanodeSlavePorts, idx + 1, "none") != 0) || - (extendVar(VAR_datanodeSlavePoolerPorts, idx + 1, "none") != 0) || - (extendVar(VAR_datanodeSlaveDirs, idx + 1, "none") != 0) || - (extendVar(VAR_datanodeArchLogDirs, idx + 1, "none") != 0)) + if ((extendVar(VAR_datanodeSlaveServers, size, "none") != 0) || + (extendVar(VAR_datanodeSlavePorts, size, "none") != 0) || + (extendVar(VAR_datanodeSlavePoolerPorts, size, "none") != 0) || + (extendVar(VAR_datanodeSlaveDirs, size, "none") != 0) || + (extendVar(VAR_datanodeSlaveWALDirs, size, "none") != 0) || + (extendVar(VAR_datanodeArchLogDirs, size, "none") != 0)) { elog(PANIC, "PANIC: Internal error, inconsistent datanode information\n"); return 1; @@ -1413,12 +1417,12 @@ int add_datanodeSlave(char *name, char *host, int port, int pooler, char *dir, if (!isVarYes(VAR_datanodeSlave)) assign_sval(VAR_datanodeSlave, "y"); - assign_arrayEl(VAR_datanodeSlaveServers, idx, host, NULL); - assign_arrayEl(VAR_datanodeSlavePorts, idx, port_s, NULL); - assign_arrayEl(VAR_datanodeSlavePoolerPorts, idx, pooler_s, NULL); - assign_arrayEl(VAR_datanodeSlaveDirs, idx, dir, NULL); - assign_arrayEl(VAR_datanodeSlaveWALDirs, idx, walDir, NULL); - assign_arrayEl(VAR_datanodeArchLogDirs, idx, archDir, NULL); + replace_arrayEl(VAR_datanodeSlaveServers, idx, host, NULL); + replace_arrayEl(VAR_datanodeSlavePorts, idx, port_s, NULL); + replace_arrayEl(VAR_datanodeSlavePoolerPorts, idx, pooler_s, NULL); + replace_arrayEl(VAR_datanodeSlaveDirs, idx, dir, NULL); + replace_arrayEl(VAR_datanodeSlaveWALDirs, idx, walDir, NULL); + replace_arrayEl(VAR_datanodeArchLogDirs, idx, archDir, NULL); /* Update the configuration file and backup it */ if ((f = fopen(pgxc_ctl_config_path, "a")) == NULL) { |