diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/routineload/KafkaRoutineLoadJob.java b/fe/fe-core/src/main/java/org/apache/doris/load/routineload/KafkaRoutineLoadJob.java index 8540bb43963b5ca..c00f16b7d8abdaf 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/load/routineload/KafkaRoutineLoadJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/load/routineload/KafkaRoutineLoadJob.java @@ -285,16 +285,27 @@ protected boolean checkCommitInfo(RLTaskTxnCommitAttachment rlTaskTxnCommitAttac return false; } + private void updateProgressAndOffsetsCache(RLTaskTxnCommitAttachment attachment) { + ((KafkaProgress) attachment.getProgress()).getOffsetByPartition().entrySet().stream() + .forEach(entity -> { + if (cachedPartitionWithLatestOffsets.containsKey(entity.getKey()) + && cachedPartitionWithLatestOffsets.get(entity.getKey()) < entity.getValue() + 1) { + cachedPartitionWithLatestOffsets.put(entity.getKey(), entity.getValue() + 1); + } + }); + this.progress.update(attachment); + } + @Override protected void updateProgress(RLTaskTxnCommitAttachment attachment) throws UserException { super.updateProgress(attachment); - this.progress.update(attachment); + updateProgressAndOffsetsCache(attachment); } @Override protected void replayUpdateProgress(RLTaskTxnCommitAttachment attachment) { super.replayUpdateProgress(attachment); - this.progress.update(attachment); + updateProgressAndOffsetsCache(attachment); } @Override