From 73ad68939082b3d530f88bf57fe6c5896dafacd3 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 27 Mar 2019 14:22:55 +0900 Subject: [PATCH] standby register: fail if --upstream-node-id is the local node ID --- HISTORY | 2 ++ doc/appendix-release-notes.sgml | 27 +++++++++++++++++---------- repmgr-action-standby.c | 11 +++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/HISTORY b/HISTORY index a216af30..deaaf0d2 100644 --- a/HISTORY +++ b/HISTORY @@ -15,6 +15,8 @@ repmgr: add sanity check for correct extension version (Ian) repmgr: ensure "witness register --dry-run" does not attempt to read node 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: on a cascaded standby, don't fail over if "failover=manual"; GitHub #531 (Ian) diff --git a/doc/appendix-release-notes.sgml b/doc/appendix-release-notes.sgml index bc4e2287..f51fddce 100644 --- a/doc/appendix-release-notes.sgml +++ b/doc/appendix-release-notes.sgml @@ -216,7 +216,7 @@ REPMGRD_OPTS="--daemonize=false" &repmgr;: when executing repmgr witness register, - 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. @@ -254,25 +254,32 @@ REPMGRD_OPTS="--daemonize=false" repmgr cluster show: - fix display of node IDs with multiple digits. + fix display of node IDs with multiple digits. - + ensure repmgr primary unregister - behaves correctly when executed on a witness server. GitHub #548. + behaves correctly when executed on a witness server. GitHub #548. - + + + + + ensure repmgr standby register + fails when is the same as the local node ID. + + repmgr node check - will only consider physical replication slots, as the purpose - of slot checks is to warn about potential issues with - streaming replication standbys which are no longer attached. - - + will only consider physical replication slots, as the purpose + of slot checks is to warn about potential issues with + streaming replication standbys which are no longer attached. + + diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index e396b855..a4dd063a 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -1435,6 +1435,17 @@ do_standby_register(void) RecordStatus upstream_record_status = RECORD_NOT_FOUND; 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, runtime_options.upstream_node_id, &upstream_node_record);