repmgr: improve detection of pg_rewind on remote server

If `pg_bindir` is not explicitly provided, the remote `ls` command
will be `ls pg_rewind`, which will very likely not find pg_rewind.
In this case execute `which pg_rewind` to confirm it's in the default
path.

Addresses GitHub #267.
This commit is contained in:
Ian Barwick
2017-04-13 11:26:32 +09:00
parent 846e0f73b2
commit 39b3b32814

View File

@@ -5067,7 +5067,11 @@ do_standby_switchover(void)
initPQExpBuffer(&remote_command_str);
appendPQExpBuffer(&remote_command_str, "ls ");
if (strcmp(remote_pg_rewind, "pg_rewind") == 0)
appendPQExpBuffer(&remote_command_str, "which ");
else
appendPQExpBuffer(&remote_command_str, "ls ");
appendShellString(&remote_command_str, remote_pg_rewind);
appendPQExpBuffer(&remote_command_str, " >/dev/null 2>&1 && echo 1 || echo 0");
@@ -5084,7 +5088,11 @@ do_standby_switchover(void)
if (*command_output.data == '0')
{
log_err(_("unable to find pg_rewind on the remote server\n"));
log_err(_("expected location is: %s\n"), remote_pg_rewind);
if (strcmp(remote_pg_rewind, "pg_rewind") == 0)
log_hint(_("set pg_bindir in repmgr.conf or provide with -b/--pg_bindir\n"));
else
log_detail(_("expected location is: %s\n"), remote_pg_rewind);
exit(ERR_BAD_CONFIG);
}