Skip to content

fix(s3stream): prevent closed reader from restoring blocks - #3555

Open
BackendArchitectX wants to merge 1 commit into
AutoMQ:mainfrom
BackendArchitectX:BackendArchitectX/test-streamreader-close-inflight
Open

fix(s3stream): prevent closed reader from restoring blocks#3555
BackendArchitectX wants to merge 1 commit into
AutoMQ:mainfrom
BackendArchitectX:BackendArchitectX/test-streamreader-close-inflight

Conversation

@BackendArchitectX

Copy link
Copy Markdown
Contributor

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

  • ./gradlew :s3stream:test --tests com.automq.stream.s3.cache.blockcache.StreamReaderTest
  • ./gradlew :s3stream:checkstyleMain :s3stream:checkstyleTest :s3stream:spotlessJavaCheck
  • git diff --check

All passed locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant