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/24 23:30:53 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_r1272852459


##########
core/src/main/scala/kafka/cluster/Replica.scala:
##########
@@ -98,31 +101,39 @@ class Replica(val brokerId: Int, val topicPartition: TopicPartition) extends Log
    * fetch request is always smaller than the leader's LEO, which can happen if small produce requests are received at
    * high frequency.
    */
-  def updateFetchState(
+  def maybeUpdateFetchState(
     followerFetchOffsetMetadata: LogOffsetMetadata,
     followerStartOffset: Long,
     followerFetchTimeMs: Long,
     leaderEndOffset: Long,
     brokerEpoch: Long
-  ): Unit = {
+  ): Boolean = {
+    var updateSuccess = true
     replicaState.updateAndGet { currentReplicaState =>
-      val lastCaughtUpTime = if (followerFetchOffsetMetadata.messageOffset >= leaderEndOffset) {
-        math.max(currentReplicaState.lastCaughtUpTimeMs, followerFetchTimeMs)
-      } else if (followerFetchOffsetMetadata.messageOffset >= currentReplicaState.lastFetchLeaderLogEndOffset) {
-        math.max(currentReplicaState.lastCaughtUpTimeMs, currentReplicaState.lastFetchTimeMs)
+      // Fence the update if it provides a stale broker epoch.
+      if (brokerEpoch != -1 && brokerEpoch < currentReplicaState.brokerEpoch.getOrElse(-1L)) {
+        updateSuccess = false

Review Comment:
   Do we need a KIP for the extra exception?



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