Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ protected StripedBlockChecksumReconstructor(ErasureCodingWorker worker,
assert targetIndices != null;
this.checksumWriter = checksumWriter;
this.requestedLen = requestedBlockLength;
init();
try {
init();
} catch (IOException e) {
getStripedReader().close();
cleanup();
throw e;
}
}

private void init() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,48 @@ public void testMixedBytesPerChecksum(String pMode) throws Exception {
}
}

@MethodSource("getParameters")
@ParameterizedTest
@Timeout(value = 90)
public void testStripedChecksumReconCleanupOnInitFailure(String pMode)
throws Exception {
initTestFileChecksum(pMode);
String stripedFile = ecDir + "/stripedFileChecksumInitFail";
prepareTestFiles(fileSize, new String[]{stripedFile});

LocatedBlocks locatedBlocks = client.getLocatedBlocks(stripedFile, 0);
LocatedBlock locatedBlock = locatedBlocks.get(0);
DatanodeInfo[] blockDns = locatedBlock.getLocations();

int numToKill = parityBlocks + 1;
int[] killedIdx = new int[numToKill];
int killed = 0;
for (int i = 0; i < blockDns.length && killed < numToKill; i++) {
int idx = 0;
for (DataNode dn : cluster.getDataNodes()) {
if (dn.getInfoPort() == blockDns[i].getInfoPort()) {
shutdownDataNode(dn);
killedIdx[killed++] = idx;
break;
}
idx++;
}
}

try {
Exception ex = assertThrows(Exception.class, () -> {
fs.getFileChecksum(new Path(stripedFile));
});
LOG.info("Got expected failure when too many DNs are down: {}",
ex.getMessage());
} finally {
for (int i = 0; i < killed; i++) {
cluster.restartDataNode(killedIdx[i]);
}
cluster.waitActive();
}
}

private FileChecksum getFileChecksum(String filePath, int range,
boolean killDn) throws Exception {
int dnIdxToDie = -1;
Expand Down
Loading