From 5f33d9d715d0ea043652721589a542492d743773 Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Sun, 16 Sep 2012 02:38:28 -0500 Subject: [PATCH] Fix node decision logic when priorities are involved. Currently if two nodes with different prorities are equally good to be promoted the second one (with a lower priority, considering them in descending order) will win. Per report from Brailean Dumitru --- repmgrd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repmgrd.c b/repmgrd.c index e5187a3f..24d612a9 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -708,13 +708,13 @@ do_failover(void) find_best = true; } - /* we use the macros provided by xlogdefs.h to compare XLogPtr */ + /* we use the macros provided by xlogdefs.h to compare XLogRecPtr */ /* * Nodes are retrieved ordered by priority, so if the current - * best candidate is lower or equal to the next node's wal location + * best candidate is lower than the next node's wal location * then assign next node as the new best candidate. */ - if (XLByteLE(best_candidate.xlog_location, nodes[i].xlog_location)) + if (XLByteLT(best_candidate.xlog_location, nodes[i].xlog_location)) { best_candidate.nodeId = nodes[i].nodeId; best_candidate.xlog_location.xlogid = nodes[i].xlog_location.xlogid;