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

ASF GitHub Bot commented on KAFKA-6833:
---------------------------------------

rayokota commented on pull request #6154: KAFKA-6833; Producer should await 
metadata for unknown partitions (#6…
URL: https://github.com/apache/kafka/pull/6154
 
 
   …073)
   
   This patch changes the behavior of KafkaProducer.waitOnMetadata to wait up 
to max.block.ms when the partition specified in the produce request is out of 
the range of partitions present in the metadata. This improves the user 
experience in the case when partitions are added to a topic and a client 
attempts to produce to one of the new partitions before the metadata has 
propagated to the brokers. Tested with unit tests.
   
   Reviewers: Arjun Satish <ar...@confluent.io>, Jason Gustafson 
<ja...@confluent.io>
   
   *More detailed description of your change,
   if necessary. The PR title and PR message become
   the squashed commit message, so use a separate
   comment to ping reviewers.*
   
   *Summary of testing strategy (including rationale)
   for the feature or bug fix. Unit and/or integration
   tests are expected for any behaviour change and
   system tests should be considered for larger changes.*
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> KafkaProducer throws "Invalid partition given with record" exception
> --------------------------------------------------------------------
>
>                 Key: KAFKA-6833
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6833
>             Project: Kafka
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Arjun Satish
>            Assignee: Bob Barrett
>            Priority: Minor
>             Fix For: 2.2.0, 2.1.1
>
>
> Currently, when creating topics via ZooKeeper, there is a small but definite 
> delay between creating the nodes in ZK, and having the topics created in the 
> brokers. the KafkaProducer maintains a metadata cache about topics which get 
> updated after the broker metadata is updated. If an application adds 
> partitions to a topic, and immediately tries to produce records to a new 
> partition, a KafkaException is throw with a message similar to the following:
> {code:java}
> Caused by: org.apache.kafka.common.KafkaException: Invalid partition given 
> with record: 12 is not in the range [0...1).
> {code}
> In this case, since the application has context that it created the topics, 
> it might be worthwhile to consider if a more specific exception can be thrown 
> instead of KafkaException. For example:
> {code:java}
> public class PartitionNotFoundException extends KafkaException {...}{code}
> This could allow the application to be able to interpret such an error, and 
> act accordingly.
> EDIT: Correct "create topics" to "adds partitions to a topic".



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to