If `registerControllerAndIncrementControllerEpoch()` has successfully written 
the broker id to controller znode but then an IllegalStateException is thrown 
(e.g. in the case `controllerId == curControllerId` and `epoch != 
newControllerEpoch` described in the other comment), an IllegalStateException 
will be thrown which is caught in `elect()` and `triggerControllerMove()` will 
be executed. However, since the `activeControllerId` has not been updated, 
`isActive()` is evaluated to false and `triggerControllerMove()` will do 
nothing.

Maybe we should first do `activeControllerId = 
zkClient.getControllerId.getOrElse(-1)`  in `triggerControllerMove()`.

Also, to be consistent with most other usage of `isActive()`, can we do 
something like the code below instead of using if/else?

```
    if (!isActive) {
      warn("Controller has already moved when trying to trigger controller 
movement")
      return
    }

```


[ Full content available at: https://github.com/apache/kafka/pull/5101 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to