From 79531ae9da54e12ce4133fd5bce26fcbaf097465 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 7 Sep 2017 10:26:46 +0900 Subject: [PATCH] "standby switchover": fix check for remote repmgr binary Also add a useful hint about setting "pg_bindir". --- repmgr-action-standby.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 9aba6351..d43c57d2 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -453,7 +453,7 @@ do_standby_clone(void) 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); exit(SUCCESS); @@ -1017,7 +1017,7 @@ do_standby_register(void) 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); if (PQstatus(conn) == CONNECTION_OK) @@ -2077,7 +2077,7 @@ do_standby_switchover(void) initPQExpBuffer(&msg); appendPQExpBuffer(&msg, - _("pre-requisites for using pg_rewind are met")); + _("prerequisites for using pg_rewind are met")); if (runtime_options.dry_run == true) { @@ -2134,7 +2134,7 @@ do_standby_switchover(void) initPQExpBuffer(&remote_command_str); 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); command_success = remote_command( remote_host, @@ -2144,15 +2144,41 @@ do_standby_switchover(void) 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\""), progname(), remote_host); - if (strlen(command_output.data)) + if (strlen(command_output.data) > 2) log_detail("%s", command_output.data); 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(local_conn);