divijvaidya commented on code in PR #14457: URL: https://github.com/apache/kafka/pull/14457#discussion_r1338310531
########## core/src/main/scala/kafka/server/AbstractFetcherThread.scala: ########## @@ -364,10 +364,11 @@ abstract class AbstractFetcherThread(name: String, // ReplicaDirAlterThread may have removed topicPartition from the partitionStates after processing the partition data if ((validBytes > 0 || currentFetchState.lag.isEmpty) && partitionStates.contains(topicPartition)) { + val lastFetchedEpoch = + if (validBytes > 0) logAppendInfo.lastLeaderEpoch.asScala else currentFetchState.lastFetchedEpoch Review Comment: validBytes would be 0 only in the case when no records returned by the fetch request. In this case, `logAppendInfo.lastLeaderEpoch` will be an empty optional. We should update the logic here to say use `currentFetchState.lastFetchedEpoch` if `logAppendInfo.lastLeaderEpoch` is empty. This would decouple the logic of using `lastLeaderEpoch` from the validity of bytes. -- 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