Repository navigation
fix(s3stream): prevent closed reader from restoring blocks - #3555
Open
BackendArchitectX wants to merge 1 commit into
Open
BackendArchitectX 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
BackendArchitectX
force-pushed
the
BackendArchitectX/test-streamreader-close-inflight
branch
from
September 8, 2026 15:12
fefa4c7 to
3800d2d
Compare
Contributor
Author
|
Hi @Gezi-lzq — could you please take a look at #3555 when you have a chance? The implementation changed materially after the original Aug 31 review request. The Sep 8 version added the I've now linked bug #3615 and validated both regressions against current The production change remains limited to four added lines. Thanks. |
Contributor
|
Thanks for the heads-up! I'll take a look and review it as soon as I can. |
Contributor
Author
Contributor
Author
This branch has not been deployed
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.
Fixes #3615
Why
StreamReader.close()clears the current block state, but block-index/readahead work can still continue around the close lifecycle boundary.There are two cases:
close().close().For work that started before close, the load can still see the same
blocksEpochand add blocks back into a reader that has already been closed.For work that starts after close, epoch invalidation alone is not sufficient because the new load observes the updated epoch.
What
Prevent both in-flight and post-close block-index loads from restoring block state after a
StreamReaderis closed.How
Increment
blocksEpochinclose()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.
Additionally, prevent
loadMoreBlocksWithoutData0()from starting a new block-index load once theStreamReaderis closed. This covers queued readahead and follow-up load continuations that begin after close.Together, these checks ensure that a closed
StreamReadercannot repopulate its block state through either existing in-flight work or newly started readahead work.Verification
Regression behavior was validated against current
main(7d4f733348).Without the production fix:
testClosePreventsInflightReadaheadFromRestoringBlocksfails because asynchronous readahead restoresblocksMapafterclose().testClosedReaderDoesNotStartNewReadaheadLoadfails becauseObjectManager#getObjects(...)is invoked after the reader has been closed.With this PR applied to the same
mainrevision:StreamReaderTestpasses;:s3stream:checkstyleMain,:s3stream:checkstyleTest, and:s3stream:spotlessJavaCheckpass;git diff --checkpasses.The production change remains limited to four added lines.
AI Disclosure
Tool: ChatGPT — GPT-5.6 Sol.
AI was used for review and validation guidance around the lifecycle race and regression strategy. I reviewed the implementation and executed the reported validation locally.