Improve handling of PostgreSQL output during "standby switchover"

Adapted from suggestion by GitHub user "ikusimakusi":

  https://github.com/2ndQuadrant/repmgr/pull/268
This commit is contained in:
Ian Barwick
2017-08-31 22:36:34 +09:00
parent b92d0cc696
commit 01edae1b20
2 changed files with 5 additions and 15 deletions

View File

@@ -8423,17 +8423,12 @@ remote_command(const char *host, const char *user, const char *command, PQExpBuf
}
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)
while (fgets(output, MAXLEN, fp) != NULL)
{
i++;
if (!feof(fp))
{
break;
}
}
}