[ 
https://issues.apache.org/jira/browse/KAFKA-21693?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

PoAn Yang resolved KAFKA-21693.
-------------------------------
    Resolution: Fixed

> KRaft migration driver gets stuck in BECOME_CONTROLLER when it reads back its 
> own /controller registration
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-21693
>                 URL: https://issues.apache.org/jira/browse/KAFKA-21693
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 3.9.2
>            Reporter: PoAn Yang
>            Assignee: PoAn Yang
>            Priority: Major
>             Fix For: 3.9.3
>
>
> During a ZK to KRaft migration, the active KRaft controller claims ZK 
> controllership in {{{}BecomeZkControllerEvent{}}}. 
> {{KafkaZkClient.tryRegisterKRaftControllerAsActiveController}} bumps 
> {{/controller_epoch}} and writes the controller ID and KRaft epoch into 
> {{/controller}} in one multi-op. Right after the claim, the same event writes 
> {{{}/migration{}}}. If the claim or that {{/migration}} write fails, the 
> migration driver stays in {{BECOME_CONTROLLER}} and retries the claim on the 
> next poll with the same KRaft epoch.
> In two cases the failed attempt has already written the registration to 
> ZooKeeper:
>  # ZooKeeper applies the multi-op, but the response is lost. 
> {{KafkaZkClient.retryRequestsUntilConnected}} resends it after 
> {{{}CONNECTIONLOSS{}}}, gets {{{}BADVERSION{}}}, and the claim returns 
> {{{}FailedRegistrationResult{}}}.
>  # The claim succeeds, but the {{/migration}} write fails, for example 
> because the ZooKeeper session expired.
> The retried claim reads back its own registration, and the {{kraftEpochInZk 
> >= kraftControllerEpoch}} check throws {{{}ControllerMovedException{}}}. The 
> driver passes the exception to the non-fatal fault handler and tries again on 
> the next poll. The poll interval backs off to 60 seconds, so the active 
> controller logs this error about once a minute until the KRaft leader changes:
> {noformat}
> ERROR Encountered zk migration fault: Unhandled error in 
> BecomeZkControllerEvent
> org.apache.kafka.common.errors.ControllerMovedException: Cannot register 
> KRaft controller 3001 with epoch 2 as the current controller register in ZK 
> has the same or newer epoch 2.
> {noformat}
> h2. Impact
> While the driver is stuck, it neither writes to ZooKeeper nor sends RPCs to 
> the ZK-mode brokers.
>  * At the start of the migration, the claim has already replaced the ZK 
> controller's {{/controller}} znode. The old ZK controller resigns, and no 
> ZK-mode broker takes over because {{/controller}} still exists. The ZK-mode 
> brokers have no controller until the KRaft leader changes.
>  * After a KRaft leader change during dual-write, the new KRaft controller 
> keeps committing metadata, but none of it reaches ZooKeeper or the ZK-mode 
> brokers. This is the same divergence that KAFKA-21062 describes.
> h2. Workaround
> Restart the active controller. The next KRaft leader has a higher epoch, so 
> its claim passes the check.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to