Skip to content

Commit

Permalink
HDDS-10682. EC Reconstruction creates empty chunks at the end of bloc…
Browse files Browse the repository at this point in the history
…ks with partial stripes (#6515)

(cherry picked from commit a5fccbc)
  • Loading branch information
sodonnel authored and S O'Donnell committed Apr 18, 2024
1 parent b58be97 commit e453c61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,13 @@ public void reconstructECBlockGroup(BlockLocationInfo blockLocationInfo,
}
// TODO: can be submitted in parallel
for (int i = 0; i < bufs.length; i++) {
CompletableFuture<ContainerProtos.ContainerCommandResponseProto>
future = targetBlockStreams[i].write(bufs[i]);
checkFailures(targetBlockStreams[i], future);
if (bufs[i].remaining() != 0) {
// If the buffer is empty, we don't need to write it as it will cause
// an empty chunk to be added to the end of the block.
CompletableFuture<ContainerProtos.ContainerCommandResponseProto>
future = targetBlockStreams[i].write(bufs[i]);
checkFailures(targetBlockStreams[i], future);
}
bufs[i].clear();
}
length -= readLen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ public class TestContainerCommandsEC {
private static final int EC_CHUNK_SIZE = 1024 * 1024;
private static final int STRIPE_DATA_SIZE = EC_DATA * EC_CHUNK_SIZE;
private static final int NUM_DN = EC_DATA + EC_PARITY + 3;
private static byte[][] inputChunks = new byte[EC_DATA][EC_CHUNK_SIZE];
// Data slots are EC_DATA + 1 so we can generate enough data to have a full stripe
// plus one extra chunk.
private static byte[][] inputChunks = new byte[EC_DATA + 1][EC_CHUNK_SIZE];

// Each key size will be in range [min, max), min inclusive, max exclusive
private static final int[][] KEY_SIZE_RANGES =
Expand Down Expand Up @@ -621,13 +623,13 @@ void testECReconstructionCoordinatorWithPartialStripe(List<Integer> missingIndex
testECReconstructionCoordinator(missingIndexes, 1);
}

@Test
void testECReconstructParityWithPartialStripe()
throws Exception {
testECReconstructionCoordinator(ImmutableList.of(4, 5), 1);
@ParameterizedTest
@MethodSource("recoverableMissingIndexes")
void testECReconstructionCoordinatorWithFullAndPartialStripe(List<Integer> missingIndexes)
throws Exception {
testECReconstructionCoordinator(missingIndexes, 4);
}


static Stream<List<Integer>> recoverableMissingIndexes() {
return Stream
.concat(IntStream.rangeClosed(1, 5).mapToObj(ImmutableList::of), Stream
Expand Down

0 comments on commit e453c61

Please sign in to comment.