From 7f865fdaf3eb68997794f87c39f610246e43b79a Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 9 Nov 2017 12:39:26 +0900 Subject: [PATCH] repmgrd: fix priority/node_id tie-break check --- repmgrd-physical.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/repmgrd-physical.c b/repmgrd-physical.c index b5b1e4d7..d1496aa1 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -1943,12 +1943,23 @@ do_election(void) candidate_node->priority); candidate_node = cell->node_info; } - else if (cell->node_info->node_id < candidate_node->node_id) + else if (cell->node_info->priority == candidate_node->priority) { - log_verbose(LOG_DEBUG, "node %i has lower node_id than current t candidate %i", - cell->node_info->node_id, - candidate_node->node_id); - candidate_node = cell->node_info; + if (cell->node_info->node_id < candidate_node->node_id) + { + log_verbose(LOG_DEBUG, "node %i has same priority but lower node_id than current candidate %i", + cell->node_info->node_id, + candidate_node->node_id); + candidate_node = cell->node_info; + } + } + else + { + log_verbose(LOG_DEBUG, "node %i has lower priority (%i) than current candidate %i (%i)", + cell->node_info->node_id, + cell->node_info->priority, + candidate_node->node_id, + candidate_node->priority); } } /*