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

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to