This is an automated email from the ASF dual-hosted git repository.

sodonnell pushed a commit to branch ozone-1.4
in repository https://gitbox.apache.org/repos/asf/ozone.git

commit 1f16f430d2f4afb00280b6bd03dfca2751bfb55f
Author: Stephen O'Donnell <[email protected]>
AuthorDate: Wed Apr 17 11:01:06 2024 +0100

    HDDS-10704. Do not fail read of EC block if the last chunk is empty (#6540)
    
    (cherry picked from commit 4f9b86ece1184de830d305ee8bd1e71bd1ca5d51)
    (cherry picked from commit 962a72d159282a07aeb75a27c966cac7bc6a572b)
---
 .../org/apache/hadoop/hdds/scm/storage/BlockInputStream.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
index 385ea6d0c3..3d789912a6 100644
--- 
a/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
+++ 
b/hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java
@@ -289,10 +289,18 @@ public class BlockInputStream extends 
BlockExtendedInputStream {
       throw new IllegalArgumentException("Not GetBlock: response=" + response);
     }
     final GetBlockResponseProto b = response.getGetBlock();
+    final long blockLength = b.getBlockData().getSize();
     final List<ChunkInfo> chunks = b.getBlockData().getChunksList();
     for (int i = 0; i < chunks.size(); i++) {
       final ChunkInfo c = chunks.get(i);
-      if (c.getLen() <= 0) {
+      // HDDS-10682 caused an empty chunk to get written to the end of some EC 
blocks. Due to this
+      // validation, these blocks will not be readable. In the EC case, the 
empty chunk is always
+      // the last chunk and the offset is the block length. We can safely 
ignore this case and not fail.
+      if (c.getLen() <= 0 && i == chunks.size() - 1 && c.getOffset() == 
blockLength) {
+        DatanodeBlockID blockID = b.getBlockData().getBlockID();
+        LOG.warn("The last chunk is empty for container/block {}/{} with an 
offset of the block length. " +
+            "Likely due to HDDS-10682. This is safe to ignore.", 
blockID.getContainerID(), blockID.getLocalID());
+      } else if (c.getLen() <= 0) {
         throw new IOException("Failed to get chunkInfo["
             + i + "]: len == " + c.getLen());
       }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to