standby register: fail if --upstream-node-id is the local node ID

This commit is contained in:
Ian Barwick
2019-03-27 14:22:55 +09:00
parent e9ece34aeb
commit 73ad689390
3 changed files with 30 additions and 10 deletions

View File

@@ -15,6 +15,8 @@
repmgr: add sanity check for correct extension version (Ian) repmgr: add sanity check for correct extension version (Ian)
repmgr: ensure "witness register --dry-run" does not attempt to read node repmgr: ensure "witness register --dry-run" does not attempt to read node
tables if repmgr extension not installed; GitHub #513 (Ian) tables if repmgr extension not installed; GitHub #513 (Ian)
repmgr: ensure "standby register" fails when --upstream-node-id is the
same as the local node ID (Ian)
repmgrd: check binary and extension major versions match; GitHub #515 (Ian) repmgrd: check binary and extension major versions match; GitHub #515 (Ian)
repmgrd: on a cascaded standby, don't fail over if "failover=manual"; repmgrd: on a cascaded standby, don't fail over if "failover=manual";
GitHub #531 (Ian) GitHub #531 (Ian)

View File

@@ -216,7 +216,7 @@ REPMGRD_OPTS="--daemonize=false"</programlisting>
<listitem> <listitem>
<para> <para>
&repmgr;: when executing <command><link linkend="repmgr-witness-register">repmgr witness register</link></command>, &repmgr;: when executing <command><link linkend="repmgr-witness-register">repmgr witness register</link></command>,
chech the node to connected is actually the primary (i.e. not the witness server). GitHub #528. check the node to connected is actually the primary (i.e. not the witness server). GitHub #528.
</para> </para>
</listitem> </listitem>
@@ -265,6 +265,13 @@ REPMGRD_OPTS="--daemonize=false"</programlisting>
</para> </para>
</listitem> </listitem>
<listitem>
<para>
ensure <command><link linkend="repmgr-standby-register">repmgr standby register</link></command>
fails when <option>--upstream-node-id</option> is the same as the local node ID.
</para>
</listitem>
<listitem> <listitem>
<para> <para>
<command><link linkend="repmgr-node-check">repmgr node check</link></command> <command><link linkend="repmgr-node-check">repmgr node check</link></command>

View File

@@ -1435,6 +1435,17 @@ do_standby_register(void)
RecordStatus upstream_record_status = RECORD_NOT_FOUND; RecordStatus upstream_record_status = RECORD_NOT_FOUND;
t_node_info upstream_node_record = T_NODE_INFO_INITIALIZER; t_node_info upstream_node_record = T_NODE_INFO_INITIALIZER;
if (runtime_options.upstream_node_id == config_file_options.node_id)
{
log_error(_("provided node ID for --upstream-node-id (%i) is the same as the configured local node ID (%i)"),
runtime_options.upstream_node_id,
config_file_options.node_id);
PQfinish(primary_conn);
if (PQstatus(conn) == CONNECTION_OK)
PQfinish(conn);
exit(ERR_BAD_CONFIG);
}
upstream_record_status = get_node_record(primary_conn, upstream_record_status = get_node_record(primary_conn,
runtime_options.upstream_node_id, runtime_options.upstream_node_id,
&upstream_node_record); &upstream_node_record);