Bob Barrett created KAFKA-10197:
-----------------------------------
Summary: Elect preferred leader when completing a partition
reassignment
Key: KAFKA-10197
URL: https://issues.apache.org/jira/browse/KAFKA-10197
Project: Kafka
Issue Type: Improvement
Reporter: Bob Barrett
Currently, when completing a partition reassignment, we elect a leader from the
new replica assignment without requiring that the leader be the new preferred
leader. Instead, we just choose any in-sync replica:
{code:java}
private def leaderForReassign(partition: TopicPartition,
leaderAndIsr: LeaderAndIsr,
controllerContext: ControllerContext):
ElectionResult = {
val targetReplicas =
controllerContext.partitionFullReplicaAssignment(partition).targetReplicaAssignment.replicas
val liveReplicas = targetReplicas.filter(replica =>
controllerContext.isReplicaOnline(replica, partition))
val isr = leaderAndIsr.isr
val leaderOpt =
PartitionLeaderElectionAlgorithms.reassignPartitionLeaderElection(targetReplicas,
isr, liveReplicas.toSet)
val newLeaderAndIsrOpt = leaderOpt.map(leader =>
leaderAndIsr.newLeader(leader, isUnclean = false))
ElectionResult(partition, newLeaderAndIsrOpt, targetReplicas)
}
{code}
If auto preferred leader election is enabled, the preferred leader will
eventually be elected. However, it would make sense to choose the preferred
leader after the reassignment without waiting for the automatic trigger.
{{}}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)