kumarpritam863 commented on code in PR #17376:
URL: https://github.com/apache/iceberg/pull/17376#discussion_r3662765480
##########
kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/channel/Channel.java:
##########
@@ -123,7 +151,7 @@ protected void consumeAvailable(Duration pollDuration) {
record -> {
// the consumer stores the offsets that corresponds to the next
record to consume,
// so increment the record offset by one
- controlTopicOffsets.put(record.partition(), record.offset() + 1);
+ controlTopicOffsets.merge(record.partition(), record.offset() + 1,
Long::max);
Review Comment:
Yes @emlynazuma what you suggested looked clean and sufficient to handle
seeking part. Also preventing zombie coordinator in the open and close is much
more important than this as that is the reason which is causing this. Also I
was thinking that rather than doing all this mumbo-zumbo can't we just do this:
```
protected void consumeAvailable(Duration pollDuration) {
ConsumerRecords<String, byte[]> records = consumer.poll(pollDuration);
while (!records.isEmpty()) {
for (ConsumerRecord<String, byte[]> record : records) {
// the consumer stores the offset of the next record to consume,
// so increment the record offset by one
if (record.offset() <
controlTopicOffsets.getOrDefault(record.partition(), 0L)) {
LOG.warn("Channel {} processed an already processed offset {} for
partition {}", taskId, record.offset(), record.partition());
continue;
}
controlTopicOffsets.put(record.partition(), record.offset() + 1);
Event event = AvroUtil.decode(record.value());
if (event.groupId().equals(connectGroupId)) {
LOG.debug("Received event of type: {}", event.type().name());
if (receive(new Envelope(event, record.partition(),
record.offset()))) {
LOG.info("Handled event of type: {}", event.type().name());
}
}
}
records = consumer.poll(pollDuration);
}
}
```
This along with the open and close fix and ensuring closed coordinator in
the committer should be sufficient I guess. What do you think?
--
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]