repmgr: prevent termination in corner-case situation

If neither the local node nor the upstream are available, and
"standby_disconnect_on_failover" is set, attempting to fetch
the walreceiver PID will result in repmgrd terminating.

Add a check that the connection is valid before attempting to
fetch the walreceiver PID.

Addresses GitHub #675.
This commit is contained in:
Ian Barwick
2020-11-17 16:32:33 +09:00
parent a5a5b506f9
commit 2a8ac36aec
2 changed files with 29 additions and 1 deletions

View File

@@ -354,6 +354,12 @@ enable_wal_receiver(PGconn *conn, bool wait_startup)
/* make timeout configurable */
int i, timeout = 30;
if (PQstatus(conn) != CONNECTION_OK)
{
log_error(_("database connection not available"));
return UNKNOWN_PID;
}
if (is_superuser_connection(conn, NULL) == false)
{
log_error(_("superuser connection required"));