Skip to content

Commit

Permalink
Fix node decision logic when priorities are involved. Currently if
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jcasanov committed Sep 16, 2012
1 parent 877f4cf commit 5f33d9d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions repmgrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5f33d9d

Please sign in to comment.