My bad. I missed the fact that the controller znode was created using `KafkaZkClient.checkedEphemeralCreate()` which has the logic similar to what you are doing here.
It seems that the most important logic in the `KafkaZkClient.checkedEphemeralCreate` is to translate `Code.NODEEXISTS` to `Code.OK` for the znode creation operation if `getDataResponse.stat.getEphemeralOwner == zooKeeperClient.sessionId`. This logic was added in https://github.com/apache/kafka/pull/3765 by Onur. My understanding is that, in case of connection issue between broker and zookeeper, it is possible for controller znode to be successfully created and yet the return code is `Code.NODEEXISTS`. `KafkaZkClient.checkedEphemeralCreate` will handle this scenario properly. It will be good for @onurkaraman to clarify whether this understanding is correct so that we can decide whether we should keep this logic. Here is another question. With the current patch, if the controller znode creation has failed due to znode exists exception and then broker find that `getDataResponse.stat.getEphemeralOwner == zooKeeperClient.sessionId`, it seems `registerControllerAndIncrementControllerEpoch()` can return `(newControllerEpoch, stat.getVersion)` if `epoch == newControllerEpoch`. But is controller epoch incremented in this case? If not, then it seems something is wrong? [ Full content available at: https://github.com/apache/kafka/pull/5101 ] This message was relayed via gitbox.apache.org for [email protected]
