From 39b3b32814fa4a35caf57cf2284b415e12e887b9 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 13 Apr 2017 11:26:32 +0900 Subject: [PATCH] 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. --- repmgr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/repmgr.c b/repmgr.c index 7826e497..b627f861 100644 --- a/repmgr.c +++ b/repmgr.c @@ -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); }