[ 
https://issues.apache.org/jira/browse/KAFKA-1503?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14039394#comment-14039394
 ] 

Guozhang Wang commented on KAFKA-1503:
--------------------------------------

Hello Jianwen,

Controller does always pick the first alive broker in the ISR list to be the 
leader, but since our partition assignment logic is round robin, such that if 
you have three partitions, three brokers, and a replication factor of three, 
then you should see the ISR lists are

partition1:   ISR {broker-1, broker-2, broker-3}
partition1:   ISR {broker-2, broker-3, broker-1}
partition1:   ISR {broker-3, broker-1, broker-2}

So the leader should still be distributed evenly.

> all partitions are using same broker as their leader after broker is down
> -------------------------------------------------------------------------
>
>                 Key: KAFKA-1503
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1503
>             Project: Kafka
>          Issue Type: Bug
>          Components: controller
>    Affects Versions: 0.8.0, 0.8.1.1
>         Environment: 0.8.1.1 
>            Reporter: Jianwen Wang
>            Assignee: Neha Narkhede
>
> The current leader selection always pick the first live broker in ISR when 
> the current leader broker is down. Since the list of liveBrokerInIsr is not 
> evenly distributed. As time goes on, all the partitions will use only one 
> broker as its leader. 
> I figured out a fix which is to use the first live broker in replica list 
> which is also in ISR list. Since the liveAssignedReplicas is evenly 
> distributed across brokers, all the partitions will be evenly distributed in 
> the live brokers in ISR.
> The fix is:
> kafka-0.8.1.1-src/core/src/main/scala/kafka/controller/PartitionLeaderSelector.scala
> 71    71
>            case false =>
> 72     
> -            val newLeader = liveBrokersInIsr.head
>       72
> +            val liveReplicasInIsr = liveAssignedReplicas.filter(r => 
> liveBrokersInIsr.contains(r))
>       73
> +            val newLeader = liveReplicasInIsr.head



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to