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

@@ -15,10 +15,32 @@
See also: <xref linkend="upgrading-repmgr"/>
</para>
<sect1 id="release-5.2.1">
<title id="release-current">Release 5.2.1</title>
<para><emphasis>??? ?? ???, 2020</emphasis></para>
<para>
&repmgr; 5.2.1 is a minor release.
</para>
<sect2>
<title>Bug fixes</title>
<para>
<itemizedlist>
<listitem>
<para>
&repmgrd;: prevent termination when local node not available and
<option>standby_disconnect_on_failover</option> is set. GitHub #675.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>
</sect1>
<!-- remember to update the release date in ../repmgr_version.h.in -->
<sect1 id="release-5.2.0">
<title id="release-current">Release 5.2.0</title>
<title>Release 5.2.0</title>
<para><emphasis>Thu 22 October, 2020</emphasis></para>
<para>

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"));