You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2020/08/09 16:12:44 UTC

[GitHub] [kylin] hit-lacus commented on a change in pull request #1351: KYLIN-4683 Fail to consume kafka when partition number get larger

hit-lacus commented on a change in pull request #1351:
URL: https://github.com/apache/kylin/pull/1351#discussion_r467601221



##########
File path: stream-source-kafka/src/main/java/org/apache/kylin/stream/source/kafka/consumer/KafkaConnector.java
##########
@@ -81,9 +81,15 @@ public void open() {
         } else if (startMode == ConsumerStartMode.LATEST) {
             kafkaConsumer.seekToEnd(topicPartitions);
         } else {
+            List<TopicPartition> newTopicPartitions = Lists.newArrayList();
             for (TopicPartition topicPartition : topicPartitions) {
                 Long offset = partitionOffsets.get(topicPartition.partition());
-                kafkaConsumer.seek(topicPartition, offset);
+                if (offset != null) {
+                    kafkaConsumer.seek(topicPartition, offset);
+                } else {
+                    newTopicPartitions.add(topicPartition);
+                }
+                kafkaConsumer.seekToBeginning(newTopicPartitions);

Review comment:
       I think `kafkaConsumer.seekToBeginning(newTopicPartitions);` should not in **for-loop** .




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