Skip to content

Commit

Permalink
HDDS-10704. Do not fail read of EC block if the last chunk is empty (#…
Browse files Browse the repository at this point in the history
…6540)

(cherry picked from commit 4f9b86e)
  • Loading branch information
sodonnel authored and xichen01 committed Apr 18, 2024
1 parent bb79260 commit 333b142
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<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());
}
Expand Down

0 comments on commit 333b142

Please sign in to comment.