kezhuw commented on code in PR #2069: URL: https://github.com/apache/zookeeper/pull/2069#discussion_r1342101080
########## zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Leader.java: ########## @@ -915,22 +934,30 @@ private long getDesignatedLeader(Proposal reconfigProposal, long zxid) { * @return True if committed, otherwise false. **/ public synchronized boolean tryToCommit(Proposal p, long zxid, SocketAddress followerAddr) { + // in order to be committed, a proposal must be accepted by a quorum. + // + // getting a quorum from all necessary configurations. + if (!p.hasAllQuorums()) { + return false; + } + // make sure that ops are committed in order. With reconfigurations it is now possible // that different operations wait for different sets of acks, and we still want to enforce // that they are committed in order. Currently we only permit one outstanding reconfiguration // such that the reconfiguration and subsequent outstanding ops proposed while the reconfig is // pending all wait for a quorum of old and new config, so it's not possible to get enough acks // for an operation without getting enough acks for preceding ops. But in the future if multiple // concurrent reconfigs are allowed, this can happen. - if (outstandingProposals.containsKey(zxid - 1)) { - return false; - } - - // in order to be committed, a proposal must be accepted by a quorum. - // - // getting a quorum from all necessary configurations. - if (!p.hasAllQuorums()) { - return false; + Proposal previous = outstandingProposals.get(zxid - 1); Review Comment: It is changed for: 1. Make sure `p` has majority acked. 2. Commit also preceding quorum read to guard against downgrading. Previously, we return directly if there is preceding proposal, but now we are committing it if preceding proposal is a quorum read. So the order becomes matter. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org