repmgr: enable "primary unregister --force" to unregister an active primary

The primary must have no registered standby nodes.

Also document usage when unregistering a primary node which is actually
running as a standby.
This commit is contained in:
Ian Barwick
2020-09-23 15:05:49 +09:00
parent cb86180f4f
commit 26b5664741
4 changed files with 24 additions and 2 deletions

View File

@@ -2,6 +2,8 @@
general: add support for PostgreSQL 13 (Ian) general: add support for PostgreSQL 13 (Ian)
general: remove support for PostgreSQL 9.3 (Ian) general: remove support for PostgreSQL 9.3 (Ian)
config: add support for file inclusion directives (Ian) config: add support for file inclusion directives (Ian)
repmgr: "primary unregister --force" will unregister an active primary
with no registered standby nodes (Ian)
repmgr: add option --verify-backup to "standby clone" (Ian) repmgr: add option --verify-backup to "standby clone" (Ian)
repmgr: add option --db-connection to "node check" (Ian) repmgr: add option --db-connection to "node check" (Ian)
repmgr: report database connection error if the --optformat option was repmgr: report database connection error if the --optformat option was

View File

@@ -60,6 +60,15 @@
displayed correctly. displayed correctly.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
<link linkend="repmgr-primary-unregister">repmgr primary unregister</link>:
the <option>--force</option> can be provided to unregister an active primary node, provided
it has no registered standby nodes.
</para>
</listitem>
<listitem> <listitem>
<para> <para>
<link linkend="repmgr-standby-clone">repmgr standby clone</link>: new option <link linkend="repmgr-standby-clone">repmgr standby clone</link>: new option

View File

@@ -60,6 +60,17 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--force</option></term>
<listitem>
<para>
Forcibly unregister the node if it is registered as an active primary,
as long as it has no registered standbys; or if it is registered as
a primary but running as a standby.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@@ -454,9 +454,9 @@ do_primary_unregister(void)
/* /*
* This appears to be the cluster primary - cowardly refuse to * This appears to be the cluster primary - cowardly refuse to
* delete the record * delete the record, unless --force is supplied.
*/ */
if (primary_node_info.node_id == target_node_info_ptr->node_id) if (primary_node_info.node_id == target_node_info_ptr->node_id && !runtime_options.force)
{ {
log_error(_("node \"%s\" (ID: %i) is the current primary node, unable to unregister"), log_error(_("node \"%s\" (ID: %i) is the current primary node, unable to unregister"),
target_node_info_ptr->node_name, target_node_info_ptr->node_name,