diff --git a/repmgr.c b/repmgr.c index a6aee368..b3b69cdc 100644 --- a/repmgr.c +++ b/repmgr.c @@ -3526,16 +3526,12 @@ do_standby_switchover(void) log_debug("Executing:\n%s\n", command); - initPQExpBuffer(&command_output); - (void)remote_command( remote_host, runtime_options.remote_user, command, NULL); - termPQExpBuffer(&command_output); - /* verify that new standby is connected and replicating */ connection_success = false; @@ -5999,6 +5995,22 @@ remote_command(const char *host, const char *user, const char *command, PQExpBuf 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); if (outputbuf != NULL)