Github user hanm commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/703#discussion_r237368267
--- Diff:
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Vote.java ---
@@ -125,11 +125,47 @@ public boolean equals(Object o) {
return false;
}
Vote other = (Vote) o;
- return (id == other.id
+
+ if ((state == ServerState.LOOKING) ||
+ (other.state == ServerState.LOOKING)) {
+ return (id == other.id
&& zxid == other.zxid
&& electionEpoch == other.electionEpoch
&& peerEpoch == other.peerEpoch);
-
+ } else {
+ /*
+ * There are two things going on in the logic below:
+ *
+ * 1. skip comparing the zxid and electionEpoch for votes for
servers
+ * out of election.
+ *
+ * Need to skip those because they can be inconsistent due
to
+ * scenarios described in QuorumPeer.updateElectionVote.
+ *
+ * And given that only one ensemble can be running at a
single point
+ * in time and that each epoch is used only once, using
only id and
+ * epoch to compare the votes is sufficient.
+ *
--- End diff --
maybe move the reference of {@see
https://issues.apache.org/jira/browse/ZOOKEEPER-1805} from bottom to here, save
some brain cycles for pattern matching between comments and issues.
---