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

ASF GitHub Bot commented on KAFKA-3096:
---------------------------------------

GitHub user ijuma opened a pull request:

    https://github.com/apache/kafka/pull/765

    KAFKA-3096; Leader is not set to -1 when it is shutdown if followers are 
down

    * Update leader to -1 before throwing `NoReplicaOnlineException` in 
`OfflinePartitionLeaderSelector` as suggested by Guozhang. This fixes the test, 
which is great, but it seems a bit out of place. Would it be better to change 
the code somewhere else?
    
    * Fix bug in `waitUntilLeaderIsElectedOrChanged` and simplify result type. 
The bug was for the following case:
    
    ```scala
    leader.isDefined && oldLeaderOpt.isEmpty && newLeaderOpt.isDefined && 
newLeaderOpt.get != leader.get
    ```
    
    We would consider it a successful election even though we should not. I 
also changed the result type as we never return `None` (we throw an exception 
instead). Fixing this bug is what uncovered the leader issue being solved in 
this PR.
    
    Also included:
    * Various mechanical clean-ups found while trying to understand the code 
(as usual, this is in separate commits, so I can submit them separately if 
desired).
    * Make logging more regular in `PartitionLeaderSelector.scala`

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ijuma/kafka 
kafka-3096-leader-should-be-set-to--1

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/765.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #765
    
----
commit a8cbf88b37665c9669f0e9beae608794d82a810c
Author: Ismael Juma <[email protected]>
Date:   2016-01-08T16:48:47Z

    Fix bug in `waitUntilLeaderIsElectedOrChanged` and simplify result type
    
    The bug was for the following case:
    
    `leader.isDefined && oldLeaderOpt.isEmpty && newLeaderOpt.isDefined && 
newLeaderOpt.get != leader.get`
    
    We would consider it a successful election even though we should not.
    
    I also changed the result type is we never return `None` (we throw an 
exception instead).

commit f2266e42b1d3fc7058574f16b0c0d8de08b3a3f6
Author: Ismael Juma <[email protected]>
Date:   2016-01-13T15:23:19Z

    Update leader to -1 before throwing `NoReplicaOnlineException`
    
    Suggested by Guozhang.

commit 21568618d8ac82d3f801307b0145baa75240b0a4
Author: Ismael Juma <[email protected]>
Date:   2016-01-13T14:25:40Z

    Various mechanical clean-ups

commit 7b608c44f17536274606654f6faa2cc45d890c3c
Author: Ismael Juma <[email protected]>
Date:   2016-01-13T15:46:50Z

    Make logging more regular in `PartitionLeaderSelector.scala` and other 
minor clean-ups

----


> Leader is not set to -1 when it is shutdown if followers are down
> -----------------------------------------------------------------
>
>                 Key: KAFKA-3096
>                 URL: https://issues.apache.org/jira/browse/KAFKA-3096
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 0.9.0.0
>            Reporter: Ismael Juma
>            Assignee: Ismael Juma
>             Fix For: 0.9.1.0
>
>
> Assuming a cluster with 2 brokers with unclear leader election disabled:
> 1. Start brokers 0 and 1
> 2. Perform partition assignment
> 3. Broker 0 is elected leader
> 4. Produce message and wait until metadata is propagated
> 6. Shutdown follower
> 7. Produce message
> 8. Shutdown leader
> 9. Start follower
> 10. Wait for leader election
> Expected: leader is -1
> Actual: leader is 0
> We have a test for this, but a bug in `waitUntilLeaderIsElectedOrChanged` 
> means that `newLeaderOpt` is not being checked.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to