You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/08/06 01:08:40 UTC

[GitHub] [kafka] thomaslee commented on pull request #9111: KAFKA-10337: await async commits in commitSync even if no offsets given

thomaslee commented on pull request #9111:
URL: https://github.com/apache/kafka/pull/9111#issuecomment-669624137


   It's somewhat easy to do it accidentally. The scenario I was concerned about looks something like this with auto offset commits disabled:
   
   ```java
   KafkaConsumer<...> consumer = ...;
   Map<TopicPartition, OffsetAndMetadata> offsets = new HashMap<>();
   
   //
   // in a message processing loop
   //
   consumer.commitAsync(offsets);
   offsets = new HashMap<>();
   
   //
   // before a rebalance (e.g. onPartitionsRevoked)
   //
   consumer.commitSync(offsets);
   ```
   
   Per the docs the `commitSync` call should ensure that the async commit finishes prior to the rebalance, but it may not if `offsets` is empty here.


----------------------------------------------------------------
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.

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