"standby switchover": fix check for remote repmgr binary

Also add a useful hint about setting "pg_bindir".
This commit is contained in:
Ian Barwick
2017-09-07 10:26:46 +09:00
parent ee7a5b6e66
commit 79531ae9da

View File

@@ -453,7 +453,7 @@ do_standby_clone(void)
log_hint(_("consider using the -c/--fast-checkpoint option")); log_hint(_("consider using the -c/--fast-checkpoint option"));
} }
log_info(_("all pre-requisites for \"standby clone\" are met")); log_info(_("all prerequisites for \"standby clone\" are met"));
PQfinish(source_conn); PQfinish(source_conn);
exit(SUCCESS); exit(SUCCESS);
@@ -1017,7 +1017,7 @@ do_standby_register(void)
if (runtime_options.dry_run == true) if (runtime_options.dry_run == true)
{ {
log_info(_("all pre-requisites for \"standby register\" are met")); log_info(_("all prerequisites for \"standby register\" are met"));
PQfinish(primary_conn); PQfinish(primary_conn);
if (PQstatus(conn) == CONNECTION_OK) if (PQstatus(conn) == CONNECTION_OK)
@@ -2077,7 +2077,7 @@ do_standby_switchover(void)
initPQExpBuffer(&msg); initPQExpBuffer(&msg);
appendPQExpBuffer(&msg, appendPQExpBuffer(&msg,
_("pre-requisites for using pg_rewind are met")); _("prerequisites for using pg_rewind are met"));
if (runtime_options.dry_run == true) if (runtime_options.dry_run == true)
{ {
@@ -2134,7 +2134,7 @@ do_standby_switchover(void)
initPQExpBuffer(&remote_command_str); initPQExpBuffer(&remote_command_str);
make_remote_repmgr_path(&remote_command_str, &remote_node_record); make_remote_repmgr_path(&remote_command_str, &remote_node_record);
appendPQExpBuffer(&remote_command_str, "--version"); appendPQExpBuffer(&remote_command_str, "--version 2>/dev/null && echo \"1\" || echo \"0\"");
initPQExpBuffer(&command_output); initPQExpBuffer(&command_output);
command_success = remote_command( command_success = remote_command(
remote_host, remote_host,
@@ -2144,15 +2144,41 @@ do_standby_switchover(void)
termPQExpBuffer(&remote_command_str); termPQExpBuffer(&remote_command_str);
if (command_success == false) if (command_success == false || command_output.data[0] == '0')
{ {
PQExpBufferData hint;
log_error(_("unable to execute \"%s\" on \"%s\""), log_error(_("unable to execute \"%s\" on \"%s\""),
progname(), remote_host); progname(), remote_host);
if (strlen(command_output.data)) if (strlen(command_output.data) > 2)
log_detail("%s", command_output.data); log_detail("%s", command_output.data);
termPQExpBuffer(&command_output); termPQExpBuffer(&command_output);
initPQExpBuffer(&hint);
appendPQExpBuffer(
&hint,
_("check \"pg_bindir\" is set to the correct path in \"repmgr.conf\"; current value: "));
if (strlen(config_file_options.pg_bindir))
{
appendPQExpBuffer(
&hint,
"\"%s\"", config_file_options.pg_bindir);
}
else
{
appendPQExpBuffer(
&hint,
"(not set)");
}
log_hint("%s", hint.data);
termPQExpBuffer(&hint);
PQfinish(remote_conn); PQfinish(remote_conn);
PQfinish(local_conn); PQfinish(local_conn);