Skip to content

HDDS-16421. Close the stream's block file when a request is rejected on the stream - #11250

Open
ss77892 wants to merge 2 commits into
apache:masterfrom
ss77892:HDDS-16421
Open

ss77892 wants to merge 2 commits into
apache:masterfrom
ss77892:HDDS-16421

Conversation

@ss77892

@ss77892 ss77892 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

readBlockImpl reports an out of range offset with StreamObserver.onError, which ends the call from the datanode side. GrpcXceiverService closes the stream's RandomAccessFileChannel only when the client completes the stream or a request throws, so the block file stayed open. rejectReadBlock closes it before reporting the error.

Improvements to TestKeyValueHandler. Replace the readBlock helper with a StreamFixture for multi-request ReadBlock tests. The old helper wrote one zero-filled block, sent one request and closed the block file, so a test could neither send several requests on one stream nor check the state of the stream's block file. StreamFixture keeps the container, block and RandomAccessFileChannel for the test's lifetime, appends chunks whose bytes encode their position, and assertResponses checks the streamed data against that. No test behavior changes. Those changes would be required for several followups including HDDS-16377

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16421

How was this patch tested?

UTs
freon/warp workloads

…on the stream

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! @ss77892 The fix looks solid overall, +1. 👍 I left one minor non-blocking suggestion.


/** A request rejected on the stream ends the call from the datanode side, so the block file must be closed there. */
@Test
public void testReadBlockErrorOnTheStreamClosesTheBlockFile() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would it be worth adding a successful read before the out-of-range request? It helps confirm that an already-open file is being closed on the same stream.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chihsuan Thank you for looking into it! I've added a successful read to the test.

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.

2 participants