neo4j/neo4j — pull request #1388 by digitalstain (2013-10-30 13:31:33+00:00)
Title: Fixes potential race with duplicate votes from a particular instance

If an election times out, is cancelled and retried, it is possible for
an instance to respond twice *after* the cancellation if its message
is delayed for some reason. This can lead to both votes being counted,
the required vote count reached earlier and eventually the election
concluding with a wrong result.
This commit fixes this by keeping the votes in a map so the latest
overrides the previous and keeps the count correct.
Another way to go about the same result would be to have a
monotonically increasing election id issued by the elector. While
more correct, it's more complicated so this solution is evaluated
first.