junrao commented on a change in pull request #8524:
URL: https://github.com/apache/kafka/pull/8524#discussion_r414042238
##########
File path: core/src/main/scala/kafka/controller/KafkaController.scala
##########
@@ -1068,7 +1068,12 @@ class KafkaController(val config: KafkaConfig,
val candidatePartitions = topicsNotInPreferredReplica.keys.filter(tp
=> controllerContext.isReplicaOnline(leaderBroker, tp) &&
controllerContext.partitionsBeingReassigned.isEmpty &&
!topicDeletionManager.isTopicQueuedUpForDeletion(tp.topic) &&
- controllerContext.allTopics.contains(tp.topic))
+ controllerContext.allTopics.contains(tp.topic) &&
+
PartitionLeaderElectionAlgorithms.preferredReplicaPartitionLeaderElection(
+ controllerContext.partitionReplicaAssignment(tp),
+ controllerContext.partitionLeadershipInfo(tp).leaderAndIsr.isr,
+ controllerContext.liveBrokerIds.toSet).nonEmpty
Review comment:
In Election.leaderForPreferredReplica(), liveReplicas is computed as the
following. So, we probably want to be consistent here.
`val liveReplicas = assignment.filter(replica =>
controllerContext.isReplicaOnline(replica, partition))`
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]