[ISSUE #10878] Fix tieredstore reads across file segments - #11184
Open
beautyarbutin wants to merge 1 commit into
Open
beautyarbutin wants to merge 1 commit into
beautyarbutin wants to merge 1 commit into
Conversation
RockteMQ-AI
reviewed
Sep 21, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
Summary
This PR generalizes readAsync in FlatAppendFile to handle reads spanning any number of file segments, replacing the previous hard-coded 2-segment limit. A new test validates cross-segment reads across 3 segments.
Findings
- [Info]
FlatAppendFile.java:253— ThereadLengthcalculation for non-last segments assumes contiguous segments (no gaps). If segments are non-contiguous,fileSegment.getCommitOffset() - readOffsetcould yield unexpected values. Consider adding a guard or assertion for segment contiguity. - [Info]
FlatAppendFile.java:258—future.join()is called twice per future in thethenApplycallback (once forremaining(), once for the buffer). Since the futures are already complete at that point, this is safe but could be slightly cleaner with a single join per future. - [Info] The early-return optimization for single-segment reads (line 245) is a nice touch — avoids unnecessary future allocation.
Overall
The fix is correct and well-tested. The generalization from 2-segment to N-segment reads addresses a real limitation. LGTM with minor suggestions above.
Automated review by RockteMQ-AI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which Issue(s) This PR Fixes
Brief Description
FlatAppendFile.readAsyncpreviously combined at most the segment containing the requested offset and the immediately following segment. Reads spanning three or more committed segments therefore returned a truncated buffer.This change starts an asynchronous read for every segment covered by the request, waits for all reads to complete, and combines their buffers in segment order. The existing single-segment fast path and final-segment truncation behavior are preserved.
A regression test creates three 100-byte consume-queue segments with distinct byte values, reads 250 bytes starting at offset 50, and verifies the complete length and byte ordering across all three segments.
How Did You Test This Change?
On the unmodified implementation, the new regression failed with
expected.length=250 actual.length=150.After the fix:
FlatAppendFileTest: 7 tests passed