From 941ed343f8f1e7c4c5de8bd1027ba7b1b80c8c77 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 10 Jul 2017 15:20:43 +0900 Subject: [PATCH] repmgrd: additional location check If only one promotion candidate is available, check it is in the same location as the primary. --- repmgrd.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/repmgrd.c b/repmgrd.c index 28074ccf..e214f6ac 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -1204,7 +1204,7 @@ do_primary_failover(void) return false; } - // should never reach here + /* should never reach here */ return false; } @@ -1889,8 +1889,20 @@ do_election(void) if (standby_nodes.node_count == 0) { - log_debug("no other nodes - we win by default"); - return ELECTION_WON; + if (strncmp(upstream_node_info.location, local_node_info.location, MAXLEN) == 0) + { + log_debug("no other nodes - we win by default"); + return ELECTION_WON; + } + else + { + log_debug("no other nodes, but primary and standby locations differ"); + + monitoring_state = MS_DEGRADED; + INSTR_TIME_SET_CURRENT(degraded_monitoring_start); + + return ELECTION_NOT_CANDIDATE; + } } for (cell = standby_nodes.head; cell; cell = cell->next)