mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
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:
12
repmgr.c
12
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user