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 2021/09/21 19:59:37 UTC

[GitHub] [kafka] 3schwartz commented on a change in pull request #11340: fix issue : KafkaConsumer cannot jump out of the poll method, and the…

3schwartz commented on a change in pull request #11340:
URL: https://github.com/apache/kafka/pull/11340#discussion_r713359407



##########
File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java
##########
@@ -1069,6 +1065,37 @@ private void maybeAutoCommitOffsetsSync(Timer timer) {
         }
     }
 
+    private void cleanUpConsumedOffsets(Map<TopicPartition, OffsetAndMetadata> willCommitOffsets) {
+
+        if (willCommitOffsets.isEmpty())
+            return;
+
+        Set<String> validTopics = metadata.fetch().topics();
+        Set<TopicPartition> toGiveUpTopicPartitions = new HashSet<>();
+
+        Iterator<Map.Entry<TopicPartition, OffsetAndMetadata>> iterator = willCommitOffsets.entrySet().iterator();
+
+        while (iterator.hasNext()) {
+
+            Map.Entry<TopicPartition, OffsetAndMetadata> entry = iterator.next();
+
+            if (!validTopics.contains(entry.getKey().topic())) {
+
+                toGiveUpTopicPartitions.add(entry.getKey());
+                iterator.remove();
+            }
+
+        }
+
+        if (toGiveUpTopicPartitions.size() > 0) {
+
+            //Because toGiveUpTopicPartitions may receive `UnknownTopicOrPartitionException` when submitting their offsets.
+            //We are prepared to abandon them. The worst effect is that these partitions may repeatedly consume some messages
+            log.warn("Synchronous auto-commit of offsets {} will be abandoned", toGiveUpTopicPartitions);

Review comment:
       I believe the messages is in correct - it is the whole partitions for which any offsets are not committed.
   
   `log.warn("Synchronous auto-commit of offsets for partitions {} will be abandoned", toGiveUpTopicPartitions);`




-- 
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-unsubscribe@kafka.apache.org

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