diff --git a/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatAppendFile.java b/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatAppendFile.java index 891170d703a..f7537700e73 100644 --- a/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatAppendFile.java +++ b/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatAppendFile.java @@ -215,6 +215,11 @@ public CompletableFuture readAsync(long offset, int length) { } } + if (index < 0) { + log.error("FlatAppendFile#readAsync offset={} is lower than minimum offset:{}", offset, fileSegmentList.get(0).getBaseOffset()); + throw new IndexOutOfBoundsException("offset is lower than minimum offset"); + } + FileSegment fileSegment1 = fileSegmentList.get(index); FileSegment fileSegment2 = offset + length > fileSegment1.getCommitOffset() && fileSegmentList.size() > index + 1 ? fileSegmentList.get(index + 1) : null; diff --git a/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatCommitLogFile.java b/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatCommitLogFile.java index 16c05204759..ab9445ced17 100644 --- a/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatCommitLogFile.java +++ b/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/FlatCommitLogFile.java @@ -68,6 +68,9 @@ public CompletableFuture getMinOffsetFromFileAsync() { .thenApply(buffer -> { firstOffset.set(MessageFormatUtil.getQueueOffset(buffer)); return firstOffset.get(); + }).exceptionally(e -> { + log.error("Get min offset from file failed, filePath={}", filePath, e); + return GET_OFFSET_ERROR; }); }