divijvaidya commented on code in PR #12224:
URL: https://github.com/apache/kafka/pull/12224#discussion_r903622295


##########
metadata/src/test/java/org/apache/kafka/metalog/LocalLogManager.java:
##########
@@ -226,16 +227,19 @@ synchronized long tryAppend(int nodeId, int epoch, 
List<ApiMessageAndVersion> ba
         }
 
         synchronized long tryAppend(int nodeId, int epoch, LocalBatch batch) {
-            if (epoch != leader.epoch()) {
-                log.trace("tryAppend(nodeId={}, epoch={}): the provided epoch 
does not " +
-                    "match the current leader epoch of {}.", nodeId, epoch, 
leader.epoch());
-                return Long.MAX_VALUE;
-            }
             if (!leader.isLeader(nodeId)) {
-                log.trace("tryAppend(nodeId={}, epoch={}): the given node id 
does not " +
-                    "match the current leader id of {}.", nodeId, epoch, 
leader.leaderId());
-                return Long.MAX_VALUE;
+                log.debug("tryAppend(nodeId={}, epoch={}): the given node id 
does not " +
+                        "match the current leader id of {}.", nodeId, epoch, 
leader.leaderId());
+                throw new NotLeaderException("Append failed because the 
replication is not the current leader");
+            }
+
+            if (epoch < leader.epoch()) {
+                throw new NotLeaderException("Append failed because the epoch 
doesn't match");

Review Comment:
   Thanks for catching. I have fixed it as per your suggestion in the latest 
commit.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to