junrao commented on a change in pull request #11255: URL: https://github.com/apache/kafka/pull/11255#discussion_r696210968
########## File path: core/src/main/scala/kafka/controller/KafkaController.scala ########## @@ -630,7 +630,7 @@ class KafkaController(val config: KafkaConfig, // If replica failure did not require leader re-election, inform brokers of the offline brokers // Note that during leader re-election, brokers update their metadata - if (partitionsWithOfflineLeader.isEmpty) { + if (newOfflineReplicas.isEmpty) { Review comment: Good point. Basically, if there is at least one partition that has gone through each `partitionStateMachine.triggerOnlinePartitionStateChange()` or ` replicaStateMachine.handleStateChanges()`, there is no need to send UpdateMetadataRequest since we broadcast metadata to every broker in each call. If partitionsWithOfflineLeader is empty but partitionsWithOfflineLeader is not empty, there is no need to send UpdateMetadataRequest. So, the check probably should be sth like ` if (newOfflineReplicas.isEmpty || (partitionsWithOfflineLeader.isEmpty && partitionsWithOfflineLeader.isEmpty))` -- 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