repmgr: add --dry-run option to "standby promote"

Implements GitHub #522.
This commit is contained in:
Ian Barwick
2019-01-10 12:36:33 +09:00
parent e191a32eac
commit b3c2831bd3
5 changed files with 37 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
4.3 2019-??
repmgr: add --version-number command line option (Ian)
repmgr: add --terse option to "cluster show"; GitHub #521 (Ian)
repmgr: add --dry-run option to "standby promote"; GitHub #522 (Ian)
repmgrd: check binary and extension major versions match; GitHub #515 (Ian)
4.2.1 2018-??-??

View File

@@ -35,6 +35,12 @@
</para>
</listitem>
<listitem>
<para>
Add <option>--dry-run</option> to <command><link linkend="repmgr-standby-promote">repmgr standby promote</link></command> (GitHub #522).
</para>
</listitem>
<listitem>
<para>
<command>repmgr --version-number</command> outputs the &quot;raw&quot;

View File

@@ -35,6 +35,20 @@
</refsect1>
<refsect1>
<title>Options</title>
<variablelist>
<varlistentry>
<term><option>--dry-run</option></term>
<listitem>
<para>
Check if this node can be promoted, but don't carry out the promotion
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Example</title>
<para>

View File

@@ -1982,13 +1982,17 @@ do_standby_promote(void)
exit(ERR_DB_CONN);
}
}
else if (runtime_options.dry_run == true)
{
log_info(_("node is a standby"));
}
/* check that there's no existing primary */
current_primary_conn = get_primary_connection_quiet(conn, &existing_primary_id, NULL);
if (PQstatus(current_primary_conn) == CONNECTION_OK)
{
log_error(_("this cluster already has an active primary server"));
log_error(_("this replication cluster already has an active primary server"));
if (existing_primary_id != UNKNOWN_NODE_ID)
{
@@ -2005,9 +2009,19 @@ do_standby_promote(void)
PQfinish(conn);
exit(ERR_PROMOTION_FAIL);
}
else if (runtime_options.dry_run == true)
{
log_info(_("no active primary server found in this replication cluster"));
}
PQfinish(current_primary_conn);
if (runtime_options.dry_run == true)
{
log_info(_("prerequisites for executing STANDBY PROMOTE are met"));
exit(SUCCESS);
}
_do_standby_promote_internal(conn, server_version_num);
}

View File

@@ -1823,6 +1823,7 @@ check_cli_parameters(const int action)
case STANDBY_REGISTER:
case STANDBY_FOLLOW:
case STANDBY_SWITCHOVER:
case STANDBY_PROMOTE:
case WITNESS_REGISTER:
case WITNESS_UNREGISTER:
case NODE_REJOIN: