CalvinConfluent commented on code in PR #14053:
URL: https://github.com/apache/kafka/pull/14053#discussion_r1268783217


##########
core/src/main/scala/kafka/cluster/Partition.scala:
##########
@@ -1366,6 +1376,17 @@ class Partition(val topicPartition: TopicPartition,
           fetchParams.replicaId,
           fetchPartitionData
         )
+
+        // Fence the fetch request with stale broker epoch from a rebooted 
follower.
+        if (metadataCache.isInstanceOf[KRaftMetadataCache]) {
+          val brokerEpoch = fetchParams.replicaEpoch
+          val currentBrokerEpoch = 
replica.stateSnapshot.brokerEpoch.getOrElse(-1L)
+          if (brokerEpoch != -1 && brokerEpoch < currentBrokerEpoch) {
+            throw new StaleBrokerEpochException(s"Received fetch request for 
$topicPartition with stale broker " +
+              s"epoch=$brokerEpoch. The expected broker epoch= 
$currentBrokerEpoch.")
+          }
+        }

Review Comment:
   Make sense. Then just abort the fetch state update.



-- 
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