mumrah opened a new pull request, #15744:
URL: https://github.com/apache/kafka/pull/15744

   This patch fixes two issues with IncrementalAlterConfigs and the ZK 
migration. First, it changes the handling of IncrementalAlterConfigs to check 
if the controller is ZK vs KRaft and only forward for KRaft. Second, it adds a 
check in KafkaZkClient#setOrCreateEntityConfigs to ensure a ZK broker is not 
directly modifying configs in ZK if there is a KRaft controller. This closes 
the race condition between KRaft taking over as the active controller and the 
ZK brokers learning about this.
   
   ----
   
   During the ZK migration, there is a time when the ZK brokers are running 
with migrations enabled, but KRaft has yet to take over as the controller.  
Prior to KRaft taking over as the controller, the ZK brokers in migration mode 
were unconditionally forwarding IncrementalAlterConfigs (IAC) to the ZK 
controller. This works for some config types, but breaks when setting BROKER 
and BROKER_LOGGER configs for a specific broker. The behavior in KafkaApis for 
IAC was to always forward if the forwarding manager was defined. Since ZK 
brokers in migration mode have forwarding enabled, the forwarding would happen, 
and the special logic for BROKER and BROKER_LOGGER would be missed, causing the 
request to fail.
   
   With this fix, the IAC handler will check if the controller is KRaft or ZK 
and only forward for KRaft.
   
   ---- 
   
   As part of KIP-500, we moved most (but not all) ZK mutations to the ZK 
controller. One of the things we did not move fully to the controller was 
entity configs. This is because there was some special logic that needed to run 
on the broker for certain config updates. If a broker-specific config was set, 
AdminClient would route the request to the proper broker. In KRaft, we have a 
different mechanism for handling broker-specific config updates.
   
   Leaving this ZK update on the broker side would be okay if we were guarding 
writes on the controller epoch, but it turns out 
KafkaZkClient#setOrCreateEntityConfigs does unprotected "last writer wins" 
updates to ZK. This means a ZK broker could update the contents of ZK _after_ 
the metadata had been migrated to KRaft. No good! To fix this, this patch adds 
a check on the controller epoch to KafkaZkClient#setOrCreateEntityConfigs but 
also adds logic to fail the update if the controller is a KRaft controller.
   
   The new logic in setOrCreateEntityConfigs adds STALE_CONTROLLER_EPOCH as a 
new exception that can be thrown while updating configs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to