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


##########
core/src/main/scala/kafka/cluster/Replica.scala:
##########
@@ -98,14 +103,20 @@ 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 updateFetchStateOrThrow(
     followerFetchOffsetMetadata: LogOffsetMetadata,
     followerStartOffset: Long,
     followerFetchTimeMs: Long,
     leaderEndOffset: Long,
     brokerEpoch: Long
   ): Unit = {
     replicaState.updateAndGet { currentReplicaState =>
+      // Fence the update if it provides a stale broker epoch.
+      if (verifyBrokerEpoch && brokerEpoch != -1 && 
currentReplicaState.brokerEpoch.exists(_ > brokerEpoch)) {

Review Comment:
   Just putting this up for discussion. The source of truth for broker 
registrations is the metadata log. An alternative implementation might be to 
check the metadata cache. Then this would be an equality check and we would 
always ensure that eventually we get the right replica. The downside possibly 
is that it might delay convergence after broker restart I guess, but not sure 
if it is a real issue. 



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