junrao commented on a change in pull request #11255:
URL: https://github.com/apache/kafka/pull/11255#discussion_r698652526



##########
File path: core/src/main/scala/kafka/controller/KafkaController.scala
##########
@@ -628,9 +628,9 @@ class KafkaController(val config: KafkaConfig,
       topicDeletionManager.failReplicaDeletion(newOfflineReplicasForDeletion)
     }
 
-    // If replica failure did not require leader re-election, inform brokers 
of the offline brokers
+    // If no partitions are affected, inform brokers of the offline brokers
     // Note that during leader re-election, brokers update their metadata
-    if (partitionsWithOfflineLeader.isEmpty) {
+    if (newOfflineReplicas.isEmpty || 
(newOfflineReplicasNotForDeletion.isEmpty && 
partitionsWithOfflineLeader.isEmpty)) {

Review comment:
       On second thought, I think this change still doesn't cover all the 
cases. The main issue is that in 
partitionStateMachine.triggerOnlinePartitionStateChange(), we only send 
updateMetadataRequest for partitions with successful leader change. If no 
partition has successful leader change, no updateMetadataRequest will be sent. 
The reason could be that newOfflineReplicas is empty, but it could also be that 
the leader can't be elected for other reasons (e.g. no replica is live). 
   
   In PartitionStateMachine.doElectLeaderForPartitions(), we have 3 categories 
of partitions, finishedUpdates, failedElections and updatesToRetry. Perhaps we 
could return finishedUpdates all the way to 
partitionStateMachine.triggerOnlinePartitionStateChange() and force a send of 
updateMetadataRequest if finishedUpdates is empty.
    

##########
File path: core/src/main/scala/kafka/controller/KafkaController.scala
##########
@@ -628,9 +628,9 @@ class KafkaController(val config: KafkaConfig,
       topicDeletionManager.failReplicaDeletion(newOfflineReplicasForDeletion)
     }
 
-    // If replica failure did not require leader re-election, inform brokers 
of the offline brokers
+    // If no partitions are affected, inform brokers of the offline brokers
     // Note that during leader re-election, brokers update their metadata
-    if (partitionsWithOfflineLeader.isEmpty) {
+    if (newOfflineReplicas.isEmpty || 
(newOfflineReplicasNotForDeletion.isEmpty && 
partitionsWithOfflineLeader.isEmpty)) {

Review comment:
       I think we only need to check the return result of 
`partitionStateMachine.triggerOnlinePartitionStateChange()`. 
`partitionStateMachine.handleStateChanges(partitionsWithOfflineLeader.toSeq, 
OfflinePartition)` doesn't generate any  updateMetadataRequest.




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