kezhuw commented on code in PR #2254: URL: https://github.com/apache/zookeeper/pull/2254#discussion_r2122629733
########## zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Learner.java: ########## @@ -630,11 +634,21 @@ protected void syncWithLeader(long newLeaderZxid) throws Exception { pif.hdr = logEntry.getHeader(); pif.rec = logEntry.getTxn(); pif.digest = logEntry.getDigest(); - if (pif.hdr.getZxid() != lastQueued + 1) { - LOG.warn( - "Got zxid 0x{} expected 0x{}", + if (lastQueued == 0) { + LOG.info("DIFF sync got first proposal 0x{}", Long.toHexString(pif.hdr.getZxid())); + } else if (pif.hdr.getZxid() != lastQueued + 1) { + if (ZxidUtils.getEpochFromZxid(pif.hdr.getZxid()) <= ZxidUtils.getEpochFromZxid(lastQueued)) { + String msg = String.format("DIFF sync got proposal 0x%s which is not next of last proposal 0x%s", + Long.toHexString(pif.hdr.getZxid()), + Long.toHexString(lastQueued)); + LOG.error(msg); + throw new Exception(msg); + } + // We can't tell whether it is a data loss. Given that new epoch is rare, + // log at warn should not be too verbose. + LOG.warn("DIFF sync got new epoch proposal 0x{}, last proposal 0x{}", Review Comment: Add expected zxid in newly introduced method `enforceContinuousProposal`. -- 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