sodonnel commented on code in PR #10415:
URL: https://github.com/apache/ozone/pull/10415#discussion_r3375166979
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java:
##########
@@ -444,36 +507,16 @@ private ByteBuffer read(int length, boolean preRead)
throws IOException {
readBlock(length, preRead);
while (true) {
- final ByteBuffer buf = readFromQueue();
- if (buf != null && buf.hasRemaining()) {
- return buf;
+ final ReadBlockResponseProto proto = poll();
Review Comment:
Claude suggests there is a problem if we have pre-read to the end of the
stream so the stream is done, and then seek backwards. This is what it says,
although I am not sure how the stream can be done and we are still reading, but
it sounds plausible:
```
"Infinite spin in the read() while-loop when a backward seek leaves stale
ahead-of-position responses in the queue and then the stream ends."
Client at position 50 MB seeks backward to 10 MB; reuseReadBuffer returns
null; streamingReader is alive with ~30 stale responses (for offsets 51–80 MB)
queued. After readBlock() sends a new request at 10
MB, poll() returns each stale response in turn. For each,
getByteBuffer(staleProto, 10 MB) finds blockOffset(10 MB) < protoOffset(51+ MB)
and returns null; read is null; hasRemaining is false; the loop continues. If
the future
completes (stream done) before new responses arrive — e.g. server finishes
sending to the old read boundary — poll() returns null at line 474-475. Line
511 NPEs. The loop has no exit path for a null proto, so even without the NPE
it would spin forever: there is no break or return null when proto is null
and the stream is done."
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]