Skip to content

Commit

Permalink
commitment: Fix off-by-one affecting even-sized clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
ongardie committed Mar 21, 2016
1 parent 259e54d commit 163a55f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *commitment) recalculate() {
matched = append(matched, idx)
}
sort.Sort(uint64Slice(matched))
quorumMatchIndex = matched[len(c.matchIndexes)/2]
quorumMatchIndex = matched[(len(matched)-1)/2]
}
if quorumMatchIndex > c.commitIndex && quorumMatchIndex >= c.startIndex {
c.commitIndex = quorumMatchIndex
Expand Down
2 changes: 1 addition & 1 deletion commitment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func voters(n int) []string {
if n > 7 {
panic("only up to 7 servers implemented")
}
return []string{"s1", "s2", "s3", "s4", "s5", "s6", "s7"}[:n+1]
return []string{"s1", "s2", "s3", "s4", "s5", "s6", "s7"}[:n]
}

// Tests setVoters() keeps matchIndexes where possible.
Expand Down

0 comments on commit 163a55f

Please sign in to comment.