echonesis commented on code in PR #11940:
URL: https://github.com/apache/ozone/pull/11940#discussion_r4748579950


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/ozone/client/io/ECBlockReconstructedInputStream.java:
##########
@@ -222,7 +223,16 @@ private void readAndSeekStripe(int offset) throws 
IOException {
 
   private long readStripe() throws IOException {
     clearBuffers();
-    return stripeReader.readStripe(bufs);
+    try {
+      return stripeReader.readStripe(bufs);
+    } catch (IOException | RuntimeException e) {
+      // Do not return partly read data, and seek the stripe reader back to 
the current position on the next read.
+      for (ByteBuffer b : bufs) {
+        b.limit(0);
+      }
+      unBuffered = true;

Review Comment:
   Thanks for catching this. 
   A successful `seek()` already loads the target stripe and positions the 
buffers at the requested offset. I’ll clear `unBuffered` at the end of a 
successful `seek()` so the next `read()` can reuse those buffers. I’ll add a 
regression test for both a failed seek and `unbuffer()` followed by a 
successful seek, verifying that the next read returns the expected bytes 
without loading the stripe again.



-- 
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]

Reply via email to