Revert "repmgr: add option -B/--remote-pg_bindir for standby switchover"

This reverts commit c30447ac90.
This commit is contained in:
Ian Barwick
2016-07-04 11:30:36 +09:00
parent 013b4b4b8a
commit 8cd79fd7dd
2 changed files with 15 additions and 54 deletions

View File

@@ -99,7 +99,6 @@ static bool check_upstream_config(PGconn *conn, int server_version_num, bool exi
static bool update_node_record_set_master(PGconn *conn, int this_node_id); static bool update_node_record_set_master(PGconn *conn, int this_node_id);
static char *make_pg_path(char *file); static char *make_pg_path(char *file);
static char *make_path(char *path, char *file);
static void do_master_register(void); static void do_master_register(void);
static void do_standby_register(void); static void do_standby_register(void);
@@ -181,7 +180,6 @@ main(int argc, char **argv)
{"terse", required_argument, NULL, 't'}, {"terse", required_argument, NULL, 't'},
{"mode", required_argument, NULL, 'm'}, {"mode", required_argument, NULL, 'm'},
{"remote-config-file", required_argument, NULL, 'C'}, {"remote-config-file", required_argument, NULL, 'C'},
{"remote-pg_bindir", required_argument, NULL, 'B'},
/* deprecated from 3.2; replaced with -P/--pwprompt */ /* deprecated from 3.2; replaced with -P/--pwprompt */
{"initdb-no-pwprompt", no_argument, NULL, 1}, {"initdb-no-pwprompt", no_argument, NULL, 1},
{"check-upstream-config", no_argument, NULL, 2}, {"check-upstream-config", no_argument, NULL, 2},
@@ -384,13 +382,10 @@ main(int argc, char **argv)
termPQExpBuffer(&invalid_mode); termPQExpBuffer(&invalid_mode);
} }
} }
break; break;
case 'C': case 'C':
strncpy(runtime_options.remote_config_file, optarg, MAXLEN); strncpy(runtime_options.remote_config_file, optarg, MAXLEN);
break; break;
case 'B':
strncpy(runtime_options.remote_pg_bindir, optarg, MAXLEN);
break;
case 1: case 1:
runtime_options.initdb_no_pwprompt = true; runtime_options.initdb_no_pwprompt = true;
break; break;
@@ -2739,7 +2734,7 @@ do_standby_follow(void)
* *
* TODO: * TODO:
* - make connection test timeouts/intervals configurable (see below) * - make connection test timeouts/intervals configurable (see below)
* - add command line option --remote-pg_bindir or similar to * - add command line option --remote_pg_bindir or similar to
* optionally handle cases where the remote pg_bindir is different * optionally handle cases where the remote pg_bindir is different
*/ */
@@ -2756,8 +2751,7 @@ do_standby_switchover(void)
char remote_host[MAXLEN]; char remote_host[MAXLEN];
char remote_data_directory[MAXLEN]; char remote_data_directory[MAXLEN];
int remote_node_id; int remote_node_id;
char remote_node_replication_state[MAXLEN] = ""; char remote_node_replication_state[MAXLEN] = "";
char remote_pg_bindir[MAXLEN] = "";
char remote_archive_config_dir[MAXLEN]; char remote_archive_config_dir[MAXLEN];
char remote_pg_rewind[MAXLEN]; char remote_pg_rewind[MAXLEN];
int i, int i,
@@ -2772,20 +2766,6 @@ do_standby_switchover(void)
bool connection_success, bool connection_success,
shutdown_success; shutdown_success;
/*
* If --remote_pg_bindir supplied, use that to build the path on the
* remote host; if not default to whatever value is set in pg_bindir
*/
if (strlen(runtime_options.remote_pg_bindir))
{
strncpy(remote_pg_bindir, runtime_options.remote_pg_bindir, MAXLEN);
}
else
{
strncpy(remote_pg_bindir, pg_bindir, MAXLEN);
}
/* /*
* SANITY CHECKS * SANITY CHECKS
* *
@@ -2915,7 +2895,7 @@ do_standby_switchover(void)
use_pg_rewind = true; use_pg_rewind = true;
maxlen_snprintf(remote_pg_rewind, maxlen_snprintf(remote_pg_rewind,
"%s", "%s",
make_path(remote_pg_bindir, "pg_rewind")); make_pg_path("pg_rewind"));
} }
else else
{ {
@@ -2936,7 +2916,7 @@ do_standby_switchover(void)
{ {
maxlen_snprintf(remote_pg_rewind, maxlen_snprintf(remote_pg_rewind,
"%s", "%s",
make_path(remote_pg_bindir, "pg_rewind")); make_pg_path("pg_rewind"));
} }
} }
else else
@@ -3132,7 +3112,7 @@ do_standby_switchover(void)
maxlen_snprintf(command, maxlen_snprintf(command,
"%s standby archive-config -f %s --config-archive-dir=%s", "%s standby archive-config -f %s --config-archive-dir=%s",
make_path(remote_pg_bindir, "repmgr"), make_pg_path("repmgr"),
runtime_options.remote_config_file, runtime_options.remote_config_file,
remote_archive_config_dir); remote_archive_config_dir);
@@ -3171,7 +3151,7 @@ do_standby_switchover(void)
maxlen_snprintf(command, maxlen_snprintf(command,
"%s -D %s -m %s -W stop >/dev/null 2>&1 && echo 1 || echo 0", "%s -D %s -m %s -W stop >/dev/null 2>&1 && echo 1 || echo 0",
make_path(remote_pg_bindir, "pg_ctl"), make_pg_path("pg_ctl"),
remote_data_directory, remote_data_directory,
runtime_options.pg_ctl_mode); runtime_options.pg_ctl_mode);
@@ -3289,7 +3269,7 @@ do_standby_switchover(void)
/* Restore any previously archived config files */ /* Restore any previously archived config files */
maxlen_snprintf(command, maxlen_snprintf(command,
"%s standby restore-config -D %s --config-archive-dir=%s", "%s standby restore-config -D %s --config-archive-dir=%s",
make_path(remote_pg_bindir, "repmgr"), make_pg_path("repmgr"),
remote_data_directory, remote_data_directory,
remote_archive_config_dir); remote_archive_config_dir);
@@ -3347,7 +3327,7 @@ do_standby_switchover(void)
format_db_cli_params(options.conninfo, repmgr_db_cli_params); format_db_cli_params(options.conninfo, repmgr_db_cli_params);
maxlen_snprintf(command, maxlen_snprintf(command,
"%s -D %s -f %s %s --rsync-only --force --ignore-external-config-files standby clone", "%s -D %s -f %s %s --rsync-only --force --ignore-external-config-files standby clone",
make_path(remote_pg_bindir, "repmgr"), make_pg_path("repmgr"),
remote_data_directory, remote_data_directory,
runtime_options.remote_config_file, runtime_options.remote_config_file,
repmgr_db_cli_params repmgr_db_cli_params
@@ -3373,7 +3353,7 @@ do_standby_switchover(void)
format_db_cli_params(options.conninfo, repmgr_db_cli_params); format_db_cli_params(options.conninfo, repmgr_db_cli_params);
maxlen_snprintf(command, maxlen_snprintf(command,
"%s -D %s -f %s %s standby follow", "%s -D %s -f %s %s standby follow",
make_path(remote_pg_bindir, "repmgr"), make_pg_path("repmgr"),
remote_data_directory, remote_data_directory,
runtime_options.remote_config_file, runtime_options.remote_config_file,
repmgr_db_cli_params repmgr_db_cli_params
@@ -3397,15 +3377,13 @@ do_standby_switchover(void)
for(i = 0; i < options.reconnect_attempts; i++) for(i = 0; i < options.reconnect_attempts; i++)
{ {
/* Check whether new standby available */ /* Check whether primary is available */
remote_conn = test_db_connection(remote_conninfo, false); /* don't fail on error */ remote_conn = test_db_connection(remote_conninfo, false); /* don't fail on error */
if (PQstatus(remote_conn) == CONNECTION_OK) if (PQstatus(remote_conn) == CONNECTION_OK)
{ {
log_debug("connected to new standby (old master)\n"); log_debug("connected to new standby (old master)\n");
/* make sure it's actually a standby */
if (is_standby(remote_conn) == 0) if (is_standby(remote_conn) == 0)
{ {
log_err(_("new standby (old master) is not a standby\n")); log_err(_("new standby (old master) is not a standby\n"));
@@ -4245,8 +4223,6 @@ do_help(void)
printf(_(" -m, --mode (standby switchover) shutdown mode (\"fast\" - default, \"smart\" or \"immediate\")\n")); printf(_(" -m, --mode (standby switchover) shutdown mode (\"fast\" - default, \"smart\" or \"immediate\")\n"));
printf(_(" -C, --remote-config-file (standby switchover) path to the configuration file on\n" \ printf(_(" -C, --remote-config-file (standby switchover) path to the configuration file on\n" \
" the current master\n")); " the current master\n"));
printf(_(" -B, --remote-pg_bindir (standby switchover) path to PostgreSQL binaries on\n" \
" the current master\n"));
printf(_(" --pg_rewind[=VALUE] (standby switchover) 9.3/9.4 only - use pg_rewind if available,\n" \ printf(_(" --pg_rewind[=VALUE] (standby switchover) 9.3/9.4 only - use pg_rewind if available,\n" \
" optionally providing a path to the binary\n")); " optionally providing a path to the binary\n"));
printf(_(" -k, --keep-history=VALUE (cluster cleanup) retain indicated number of days of history (default: 0)\n")); printf(_(" -k, --keep-history=VALUE (cluster cleanup) retain indicated number of days of history (default: 0)\n"));
@@ -4789,14 +4765,6 @@ check_parameters_for_action(const int action)
} }
} }
if (action != STANDBY_SWITCHOVER)
{
if (strlen(runtime_options.remote_pg_bindir))
{
error_list_append(&cli_warnings, _("--remote-pg_bindir an only be used when executing STANDBY_SWITCHOVER"));
}
}
return; return;
} }
@@ -5550,18 +5518,12 @@ do_check_upstream_config(void)
static char * static char *
make_pg_path(char *file) make_pg_path(char *file)
{ {
return make_path(pg_bindir, file); maxlen_snprintf(path_buf, "%s%s", pg_bindir, file);
}
static char *
make_path(char *path, char *file)
{
maxlen_snprintf(path_buf, "%s%s", path, file);
return path_buf; return path_buf;
} }
static void static void
exit_with_errors(void) exit_with_errors(void)
{ {

View File

@@ -78,9 +78,8 @@ typedef struct
*/ */
char loglevel[MAXLEN]; char loglevel[MAXLEN];
/* parameters used by STANDBY SWITCHOVER */ /* parameter used by STANDBY SWITCHOVER */
char remote_config_file[MAXLEN]; char remote_config_file[MAXLEN];
char remote_pg_bindir[MAXLEN];
char pg_rewind[MAXPGPATH]; char pg_rewind[MAXPGPATH];
char pg_ctl_mode[MAXLEN]; char pg_ctl_mode[MAXLEN];
/* parameter used by STANDBY {ARCHIVE_CONFIG | RESTORE_CONFIG} */ /* parameter used by STANDBY {ARCHIVE_CONFIG | RESTORE_CONFIG} */
@@ -97,7 +96,7 @@ typedef struct
bool initdb_no_pwprompt; bool initdb_no_pwprompt;
} t_runtime_options; } t_runtime_options;
#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, false, false, false, false, "", "", "", "", "", "fast", "", 0, "", "", "", false } #define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, false, false, false, false, "", "", "", "", "fast", "", 0, "", "", "", false }
struct BackupLabel struct BackupLabel
{ {