neo4j/neo4j — pull request #2314 by digitalstain (2014-04-25 12:27:00+00:00)
Title: [DO NOT MERGE - WORK IN PROGRESS] Fixes issue with role election in cluster

Introduces tests and fixes for some edge cases that role election
may come up against
Votes received that are actually delayed responses from a previous
election could lead to wrong results. This is now guarded against
by having versions marking elections and vote requests/responses
Election results could be reordered if one would fail to be
broadcasted. Now this is guarded against by an election epoch, allowing
election results to be ignored.
Instance and vote count could become wrong if an instance voted
and then was marked as failed before the election finished. That could
lead to cases where the role holder was not asked for a vote. Now,
ElectionContext registers as a HeartbeatListener and will invalidate
votes of instances that have failed.
This is added with backwards compatibility, so elections initiated by
previous version instances will still go through and receive proper
responses.