diff options
author | Pavan Deolasee | 2017-04-25 05:34:47 +0000 |
---|---|---|
committer | Pavan Deolasee | 2017-05-05 04:59:34 +0000 |
commit | 6c95e960d2a55bbf61bc4066c4ffc60abc2aab50 (patch) | |
tree | 15a4203c65e162494a10395f7e8a116c7cc2838b | |
parent | 9c3faf86680fe1c73a9f14454d5e5edb454de6c7 (diff) |
Ensure that GTM master is added first before allowing addition of other
components.
This fixes a pgxc_ctl crash reported by Tomas, but it also makes sense because
GTM details must be added to configuration files of other components while
adding them.
In passing also fix problems while calling "clean/stop all" on non existing GTM
master.
-rw-r--r-- | contrib/pgxc_ctl/do_command.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/contrib/pgxc_ctl/do_command.c b/contrib/pgxc_ctl/do_command.c index d33eca8ca9..916b024253 100644 --- a/contrib/pgxc_ctl/do_command.c +++ b/contrib/pgxc_ctl/do_command.c @@ -854,7 +854,8 @@ static void stop_all(char *immediate) stop_gtm_proxy_all(); if (isVarYes(VAR_gtmSlave)) stop_gtm_slave(); - stop_gtm_master(); + if (!is_none(sval(VAR_gtmMasterServer))) + stop_gtm_master(); } @@ -880,6 +881,12 @@ static void do_add_command(char *line) elog(ERROR, "ERROR: Specify options for add command.\n"); return; } + if (!TestToken("gtm") && is_none(sval(VAR_gtmMasterServer))) + { + elog(ERROR, "ERROR: GTM master must be added before adding any other component.\n"); + return; + } + if (TestToken("gtm")) { /* @@ -1166,13 +1173,14 @@ static void do_stop_command(char *line) elog(WARNING, "-m option is not available with gtm. Ignoring.\n"); if (!GetToken() || (TestToken("all"))) { - stop_gtm_master(); + if (!is_none(sval(VAR_gtmMasterServer))) + stop_gtm_master(); if (isVarYes(VAR_gtmSlave)) stop_gtm_slave(); } - else if (TestToken("master")) + else if (TestToken("master") && !is_none(sval(VAR_gtmMasterServer))) stop_gtm_master(); - else if (TestToken("slave")) + else if (TestToken("slave") && isVarYes(VAR_gtmSlave)) stop_gtm_slave(); else elog(ERROR, "ERROR: please specify master, slave or all for stop gtm command.\n"); @@ -1736,7 +1744,8 @@ static void do_clean_command(char *line) stop_all("immediate"); elog(INFO, "Cleaning all the directories and sockets.\n"); - clean_gtm_master(); + if (!is_none(sval(VAR_gtmMasterServer))) + clean_gtm_master(); if (isVarYes(VAR_gtmSlave)) clean_gtm_slave(); if (isVarYes(VAR_gtmProxy)) @@ -1754,15 +1763,17 @@ static void do_clean_command(char *line) if ((token == NULL) || TestToken("all")) { elog(INFO, "Stopping and cleaning GTM slave/master \n"); - stop_gtm_master(); + if (!is_none(sval(VAR_gtmMasterServer))) + stop_gtm_master(); if (isVarYes(VAR_gtmSlave)) stop_gtm_slave(); - clean_gtm_master(); + if (!is_none(sval(VAR_gtmMasterServer))) + clean_gtm_master(); if (isVarYes(VAR_gtmSlave)) clean_gtm_slave(); } - else if (TestToken("master")) + else if (TestToken("master") && !is_none(sval(VAR_gtmMasterServer))) { stop_gtm_master(); clean_gtm_master(); |