HDDS-15422. Stream read seek should not close stream#10415
Conversation
yandrey321
left a comment
There was a problem hiding this comment.
we need tests for validating that stream is not closed when:
- seek inside the length of prefetched buffer
- seek outside the length of prefetched buffer
- read last N bytes from the input stream, seek to 0, read
@yandrey321 , We already have such a lot test for seek and position read; see TestStreamBlockInputStream.
The way I checked it is to turn on debug log and run org.apache.hadoop.ozone.client.rpc.read.TestStreamBlockInputStream before and after this fix. You may try it. |
| LOG.debug("{}: seek {} -> {}", this, position, pos); | ||
| closeStream(); | ||
| LOG.debug("{}: seek {} -> {}", getName(streamingReader), position, pos); | ||
| buffer = null; |
There was a problem hiding this comment.
When I was checking HBase behavior, I noticed that it's quite a common scenario where it does seek {current} -> 0 and seek 0 -> current + small offset without any reads in between. Usually, the last seek lands in the existing buffer/prefetch. Would it be more reasonable if we try to preserve the buffer if the actual read happen for the data we already have in the buffer?
There was a problem hiding this comment.
That's a good point! Let's put it back to the queue for seek.
we need to make sure that we'd not have regression when the next person would change the behavior. |
@yandrey321 , this is a good suggestion only if such test is easy to be done in low cost. It would be great if you could contribute on it. I look forward to see your contribution! |
What changes were proposed in this pull request?
What is the link to the Apache JIRA
HDDS-15422
How was this patch tested?
By existing tests. Checked that the StreamReader won't be closed for seek and position read.