[ 
https://issues.apache.org/jira/browse/KAFKA-20089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18053724#comment-18053724
 ] 

Chia-Ping Tsai commented on KAFKA-20089:
----------------------------------------

Given that the javadoc for `partitionFor` states it `will be empty when the 
given topic is not found', it seems safer to preserve the current logic and 
simply clarify the documentation

Aligning the behavior to return `LEADER_NOT_AVAILABLE` would be a significant 
change, even for KRaft. Furthermore, it could trap consumer in a retry loop 
until timeout, which is same with `Producer#partitionFor`.

We are stuck with the trade-off between the consistency and compatibility :)

> AutoTopicCreationManager should return LEADER_NOT_AVAILABLE for in-flight 
> topic creation in KRaft
> -------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-20089
>                 URL: https://issues.apache.org/jira/browse/KAFKA-20089
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Chia-Ping Tsai
>            Assignee: Chia-Ping Tsai
>            Priority: Major
>
> from: https://lists.apache.org/thread/5vxgjl7rv4ys6h1z641wqkvh3obtqxvn
> When {{auto.create.topics.enable}} is true, calling 
> {{consumer.partitionsFor("non-existent-topic")}} behaves differently between 
> ZK and KRaft modes.
> *ZK Mode:* The client retries and eventually receives the partition info.
> *KRaft Mode:* The client receives an empty result (or failure) immediately, 
> as it does not retry.
> The root cause is that broker returns {{LEADER_NOT_AVAILABLE}} once creating 
> the topic on zk. By contrast, broker returns 
> {{{}UNKNOWN_TOPIC_OR_PARTITION{}}}, which results in no retry, to client.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to