From 1f16f430d2f4afb00280b6bd03dfca2751bfb55f Mon Sep 17 00:00:00 2001 From: Stephen O'Donnell Date: Wed, 17 Apr 2024 11:01:06 +0100 Subject: [PATCH] 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) --- .../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 385ea6d0c3e..3d789912a66 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 @@ private static void validate(ContainerCommandResponseProto response) throw new IllegalArgumentException("Not GetBlock: response=" + response); } final GetBlockResponseProto b = response.getGetBlock(); + final long blockLength = b.getBlockData().getSize(); final List 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()); }