anmolnar commented on code in PR #2164:
URL: https://github.com/apache/zookeeper/pull/2164#discussion_r1772292639


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/LearnerHandler.java:
##########
@@ -525,15 +525,16 @@ public void run() {
             long newEpoch = learnerMaster.getEpochToPropose(this.getSid(), 
lastAcceptedEpoch);
             long newLeaderZxid = ZxidUtils.makeZxid(newEpoch, 0);
 
-            if (this.getVersion() < 0x10000) {
-                // we are going to have to extrapolate the epoch information
-                long epoch = ZxidUtils.getEpochFromZxid(zxid);
-                ss = new StateSummary(epoch, zxid);
-                // fake the message
-                learnerMaster.waitForEpochAck(this.getSid(), ss);
+            /**
+             * When the Leader switches to a new mode
+             * lower version Observers or Followers are not allowed to join 
the cluster, thus the zxid bit length has changed.
+             */
+            if (this.getVersion() < 0x11000) {
+                LOG.error("sid:{} version too old", this.sid);
+                return;
             } else {
                 byte[] ver = new byte[4];
-                ByteBuffer.wrap(ver).putInt(0x10000);
+                ByteBuffer.wrap(ver).putInt(0x11000);

Review Comment:
   The patch doesn't alter anything in the protocol, but you still have to 
increase protocol version number in order to reject old followers. Odd, but 
seams reasonable.



##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeer.java:
##########
@@ -1209,6 +1209,25 @@ private void loadDataBase() {
 
             // load the epochs
             long lastProcessedZxid = zkDb.getDataTree().lastProcessedZxid;
+            /**
+             * It is only after joining the cluster that we know whether the 
current use is 32-bit or 40-bit.
+             * Here, a new file is created locally to store the current number 
of epoch bits. This file will be created locally after upgrading the version to 
ensure a smooth joining of the cluster upon startup.
+             */
+            try {
+                currentEpochPosition = 
readLongFromFile(CURRENT_EPOCH_POSITION_FILENAME);

Review Comment:
   Why do you need to store this information in a file?
   Leader will set it automatically, learners will use the new version based on 
leader's version.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to