GitHub user ijuma opened a pull request: https://github.com/apache/kafka/pull/2935
MINOR: onControllerResignation should be invoked if triggerControllerMove is called This fixes a transient test failure due to a NPE in ControllerFailoverTest.testMetadataUpdate: ```text Caused by: java.lang.NullPointerException at kafka.controller.ControllerBrokerRequestBatch.addUpdateMetadataRequestForBrokers(ControllerChannelManager.scala:338) at kafka.controller.KafkaController.sendUpdateMetadataRequest(KafkaController.scala:975) at kafka.controller.ControllerFailoverTest.testMetadataUpdate(ControllerFailoverTest.scala:141) ``` The underlying issue is that setting `activeControllerId.set(-1)` in `triggerControllerMove` causes `Reelect` not to invoke `onControllerResignation`. Among other things, this causes an IllegalStateException to be thrown when `KafkaScheduler.startup` is invoked for the second time without the corresponding `shutdown`. I also updated the test so that we can trigger this issue deterministically instead of transiently. Finally, I included a few clean-ups: 1. No longer update the broker state in `onControllerFailover`. This is no longer needed since we removed the `RunningAsController` state (KAFKA-3761). 2. Trivial clean-ups in KafkaController 3. Removed unused parameter in `ZkUtils.getPartitionLeaderAndIsrForTopics` You can merge this pull request into a Git repository by running: $ git pull https://github.com/ijuma/kafka on-controller-resignation-if-trigger-controller-move Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/2935.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 #2935 ---- commit c01d29b3a95e7ddffb91550397a5505d9711d5c8 Author: Ismael Juma <ism...@juma.me.uk> Date: 2017-04-28T12:30:03Z MINOR: onControllerResignation should be invoked if triggerControllerMove is called commit f28de697f7d109893537652e8b8216c4d06677a7 Author: Ismael Juma <ism...@juma.me.uk> Date: 2017-04-28T12:30:47Z Remove remnant broker state update in `onControllerFailover` commit 898b88b59cffbfdb7df864d0b070ed7a4960601e Author: Ismael Juma <ism...@juma.me.uk> Date: 2017-04-28T12:31:15Z A few trivial clean-ups in KafkaController commit 241b9890ab47b4670e61f3f9d3b51c6aa92a8a94 Author: Ismael Juma <ism...@juma.me.uk> Date: 2017-04-28T12:31:38Z Remove unused parameter in `getPartitionLeaderAndIsrForTopics` ---- --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---