From 8f7a32a9a2cf5595a2b2a8968b5809ad9532afb3 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 17 Nov 2020 16:32:33 +0900 Subject: [PATCH] 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. --- doc/appendix-release-notes.xml | 24 +++++++++++++++++++++++- sysutils.c | 6 ++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml index 3eaabf5e..6dd4ee7f 100644 --- a/doc/appendix-release-notes.xml +++ b/doc/appendix-release-notes.xml @@ -15,10 +15,32 @@ See also: + + Release 5.2.1 + ??? ?? ???, 2020 + + + &repmgr; 5.2.1 is a minor release. + + + Bug fixes + + + + + &repmgrd;: prevent termination when local node not available and + is set. GitHub #675. + + + + + + + - Release 5.2.0 + Release 5.2.0 Thu 22 October, 2020 diff --git a/sysutils.c b/sysutils.c index 9ba78ebc..86051517 100644 --- a/sysutils.c +++ b/sysutils.c @@ -363,6 +363,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"));