bozhao12 commented on a change in pull request #11965: URL: https://github.com/apache/kafka/pull/11965#discussion_r838004373
########## File path: core/src/main/scala/kafka/server/ReplicaManager.scala ########## @@ -1234,8 +1234,9 @@ class ReplicaManager(val config: KafkaConfig, fetchOffset: Long, currentTimeMs: Long): Option[Int] = { partition.leaderReplicaIdOpt.flatMap { leaderReplicaId => Review comment: @dajac In fact, when the local replica is a follower or changes from a leader to a follower, `partition.leaderReplicaIdOpt.flatMap { leaderReplicaId => `refers to the latest leader replica id. But it does not confirm whether it is the leader itself. This will result in a case, if the local broker is follower replica, the follower will also perform the preferred read replica selection. But from the code comments and implementation, actually we just want the leader to execute the process. I implemented a unit test. Confirmed that follower will execute preferred read leader selection. Therefore, I think a conditional judgment` partition.isLeader ` needs to be added, , when` partition.isLeader = false`, break the selection and return None. -- 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