Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cache): fix readhead fail when user read fast than readahead #1382

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,14 @@ private CompletableFuture<List<Block>> getBlocks(long startOffset, long endOffse
private void getBlocks0(GetBlocksContext ctx, long startOffset, long endOffset, int maxBytes) {
Long floorKey = blocksMap.floorKey(startOffset);
if (floorKey == null && !blocksMap.isEmpty()) {
LOGGER.error("[BUG] {} cannot find floor block for startOffset={}, the first block={}", this, startOffset, blocksMap.firstEntry());
throw new AutoMQException("[BUG] cannot find floor block");
if (ctx.readahead) {
// The user read may be faster than the readahead, and clear the read completed blocks.
ctx.cf.complete(ctx.blocks);
return;
} else {
LOGGER.error("[BUG] {} cannot find floor block for startOffset={}, the first block={}", this, startOffset, blocksMap.firstEntry());
throw new AutoMQException("[BUG] cannot find floor block");
}
}
CompletableFuture<Boolean> loadMoreBlocksCf;
int remainingSize = maxBytes;
Expand Down
Loading