sajjad-moradi commented on code in PR #8321:
URL: https://github.com/apache/pinot/pull/8321#discussion_r907654587
##########
pinot-plugins/pinot-stream-ingestion/pinot-kafka-2.0/src/main/java/org/apache/pinot/plugin/stream/kafka20/KafkaPartitionLevelConsumer.java:
##########
@@ -55,7 +58,12 @@ public MessageBatch<byte[]> fetchMessages(long startOffset,
long endOffset, int
LOGGER.debug("poll consumer: {}, startOffset: {}, endOffset:{} timeout:
{}ms", _topicPartition, startOffset,
endOffset, timeoutMillis);
}
- _consumer.seek(_topicPartition, startOffset);
+ Map<TopicPartition, Long> beginningOffsets =
_consumer.beginningOffsets(Lists.newArrayList(_topicPartition));
+ Long beginningOffset = beginningOffsets.values().iterator().next();
+ // explicitly check for OutOfRange, where startOffset < beginningOffset
+ // without this, _consumer.poll will auto offset reset to latest,
resulting in data loss
+ _consumer.seek(_topicPartition, Math.max(startOffset, beginningOffset));
Review Comment:
I agree. The alternate approach in 8309 should solve the issue and it's
backward compatible with no extra overhead.
👍
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]