kezhuw commented on code in PR #2254:
URL: https://github.com/apache/zookeeper/pull/2254#discussion_r2122631097


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Learner.java:
##########
@@ -696,18 +710,27 @@ protected void syncWithLeader(long newLeaderZxid) throws 
Exception {
                         packet.rec = logEntry.getTxn();
                         packet.hdr = logEntry.getHeader();
                         packet.digest = logEntry.getDigest();
-                        // Log warning message if txn comes out-of-order
-                        if (packet.hdr.getZxid() != lastQueued + 1) {
-                            LOG.warn(
-                                "Got zxid 0x{} expected 0x{}",
-                                Long.toHexString(packet.hdr.getZxid()),
-                                Long.toHexString(lastQueued + 1));
+                        if (lastQueued == 0) {
+                            LOG.info("DIFF sync got first proposal 0x{}", 
Long.toHexString(packet.hdr.getZxid()));
+                        } else if (packet.hdr.getZxid() != lastQueued + 1) {
+                            if 
(ZxidUtils.getEpochFromZxid(packet.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(packet.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{}",
+                                    Long.toHexString(packet.hdr.getZxid()),
+                                    Long.toHexString(lastQueued));

Review Comment:
   Move them to `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

Reply via email to