fix(s3stream): prevent closed reader from restoring blocks - #3555
Open
BackendArchitectX wants to merge 1 commit into
Open
fix(s3stream): prevent closed reader from restoring blocks#3555BackendArchitectX wants to merge 1 commit into
BackendArchitectX wants to merge 1 commit into
Conversation
BackendArchitectX
requested review from
1sonofqiu,
Gezi-lzq and
superhx
as code owners
August 31, 2026 17:16
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.
Why
StreamReader.close() clears the current block state, but an in-flight block-index/readahead load can still complete afterward.
Because close() does not invalidate blocksEpoch, the in-flight load still sees the same epoch and can add blocks back into a reader that has already been closed.
What
Invalidate in-flight block-index loads when a StreamReader is closed.
How
Increment blocksEpoch in close() before clearing the current blocks.
Existing block-index loading already checks the captured epoch before continuing and before inserting blocks, so changing the epoch prevents work started before close from restoring stale state.
A regression test starts readahead with a delayed metadata load, closes the reader, then completes the load and verifies that blocksMap remains empty.
Verification
All passed locally.