standby promote: enable "service_promote_command" in PostgreSQL 12

This enables the promote command generated internally by repmgr to
be overridden if desired, in the same way as for PostgreSQL 11 and
earlier.
This commit is contained in:
Ian Barwick
2020-03-06 13:20:44 +09:00
parent fb5ce720f3
commit 0bc0a28378
4 changed files with 30 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
5.1 2019-??-??
5.1 2020-??-??
repmgr: remove BDR 2.x support
repmgr: don't query upstream's data directory (Ian)
repmgr: rename --recovery-conf-only to --replication-conf-only (Ian)
@@ -14,6 +14,7 @@
repmgr: consolidate replication connection code (Ian)
repmgr: check permissions for "pg_promote()" and fall back to pg_ctl
if necessary (Ian)
repmgr: enable "service_promote_command" in PostgreSQL 12 (Ian)
5.0 2019-10-15
general: add PostgreSQL 12 support (Ian)

View File

@@ -97,6 +97,12 @@
</para>
</listitem>
<listitem>
<para>
<link linkend="repmgr-standby-promote"><command>repmgr standby promote</command></link>:
in PostgreSQL 12 and later, use <varname>service_promote_command</varname> if set.
</para>
</listitem>
<listitem>
<para>

View File

@@ -195,6 +195,23 @@
</simpara>
</listitem>
<listitem>
<indexterm>
<primary>service_promote_command</primary>
<secondary>with &quot;repmgr standby promote &quot;</secondary>
</indexterm>
<simpara>
<literal>service_promote_command</literal>:
a command which will be executed instead of <command>pg_ctl promote</command>
or (in PostgreSQL 12 and later) <function>pg_promote()</function>.
</simpara>
<simpara>
This is intended for systems which provide a package-level promote command,
such as Debian's <application>pg_ctlcluster</application>, to promote the
PostgreSQL from standby to primary.
</simpara>
</listitem>
</itemizedlist>
</para>

View File

@@ -2487,7 +2487,11 @@ _do_standby_promote_internal(PGconn *conn)
{
use_pg_promote = true;
if (can_execute_pg_promote(conn) == false)
if (config_file_options.service_promote_command[0] != '\0')
{
use_pg_promote = false;
}
else if (can_execute_pg_promote(conn) == false)
{
use_pg_promote = false;
log_info(_("user \"%s\" does not have permission to execute \"pg_promote()\", falling back to \"pg_ctl promote\""),