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


##########
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:
   After a failed stripe read, a later successful seek leaves unBuffered set, 
so the next read
   reconstructs the same stripe again.
   
   Scenario: seek(p1) fails in readStripe, so unBuffered = true. The caller 
then calls seek(p2), which succeeds and loads p2's stripe into bufs. The next 
read() sees unBuffered, calls seek(getPos()) = seek(p2) and reads and decodes 
the whole stripe a second time: with RS-6-3 and 1 MB chunks, about 6 MB of 
extra datanode reads plus a decode. The
   same redundant reload already happens on master after unbuffer() followed by 
seek().
   Introduced by this PR for the failure case (pre-existing for unbuffer()).
   
   Fix option(-s): clear the flag at the end of a successful seek (`position = 
pos; unBuffered = false;`). seek() always allocates and reloads the buffers, so 
the flag is no longer needed at that point.



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