You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "CalvinConfluent (via GitHub)" <gi...@apache.org> on 2023/07/19 23:39:09 UTC

[GitHub] [kafka] CalvinConfluent commented on a diff in pull request #14053: [KAFKA-15221] Fix the race between fetch requests from a rebooted follower.

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-unsubscribe@kafka.apache.org

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