diff --git a/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/core/MessageStoreFetcherImpl.java b/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/core/MessageStoreFetcherImpl.java index 7f79dbcd984..c5e5f31ee22 100644 --- a/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/core/MessageStoreFetcherImpl.java +++ b/tieredstore/src/main/java/org/apache/rocketmq/tieredstore/core/MessageStoreFetcherImpl.java @@ -148,6 +148,9 @@ protected GetMessageResultExt getMessageFromCache( if (result.getMessageCount() == maxCount) { break; } + if (result.getBufferTotalSize() >= storeConfig.getReadAheadMessageSizeThreshold()) { + break; + } } result.setStatus(result.getMessageCount() > 0 ? GetMessageStatus.FOUND : GetMessageStatus.NO_MATCHED_MESSAGE);