mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
When the output of a remote command isn't required, ensure it's consumed anyway
This fixes a regression introduced with commit 85f68e9f77
Also clean up some code made redundant by same.
This commit is contained in:
20
repmgr.c
20
repmgr.c
@@ -3453,16 +3453,12 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
log_debug("Executing:\n%s\n", command);
|
log_debug("Executing:\n%s\n", command);
|
||||||
|
|
||||||
initPQExpBuffer(&command_output);
|
|
||||||
|
|
||||||
(void)remote_command(
|
(void)remote_command(
|
||||||
remote_host,
|
remote_host,
|
||||||
runtime_options.remote_user,
|
runtime_options.remote_user,
|
||||||
command,
|
command,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
termPQExpBuffer(&command_output);
|
|
||||||
|
|
||||||
/* verify that new standby is connected and replicating */
|
/* verify that new standby is connected and replicating */
|
||||||
|
|
||||||
connection_success = false;
|
connection_success = false;
|
||||||
@@ -5734,6 +5730,22 @@ remote_command(const char *host, const char *user, const char *command, PQExpBuf
|
|||||||
appendPQExpBuffer(outputbuf, "%s", output);
|
appendPQExpBuffer(outputbuf, "%s", output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* When executed remotely, repmgr commands which execute pg_ctl (particularly
|
||||||
|
* `repmgr standby follow`) will see the pg_ctl command appear to fail with a
|
||||||
|
* non-zero return code when the output from the executed pg_ctl command
|
||||||
|
* has nowhere to go, even though the command actually succeeds. We'll consume an
|
||||||
|
* arbitrary amount of output and throw it away to work around this.
|
||||||
|
*/
|
||||||
|
int i = 0;
|
||||||
|
while (fgets(output, MAXLEN, fp) != NULL && i < 10)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pclose(fp);
|
pclose(fp);
|
||||||
|
|
||||||
if (outputbuf != NULL)
|
if (outputbuf != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user