Skip to content
Closed
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 @@ -236,14 +236,6 @@ private void deleteChunk(Container container, BlockID blockID,

File file = getChunkFile(container, blockID, info);

// if the chunk file does not exist, it might have already been deleted.
// The call might be because of reapply of transactions on datanode
// restart.
if (!file.exists()) {
LOG.warn("Block file to be deleted does not exist: {}", file);
return;
}

if (verifyLength) {
Preconditions.checkNotNull(info, "Chunk info cannot be null for single " +
"chunk delete");
Expand All @@ -263,6 +255,16 @@ private File getChunkFile(Container container, BlockID blockID,
private static void checkFullDelete(ChunkInfo info, File chunkFile)
throws StorageContainerException {
long fileLength = chunkFile.length();
if (fileLength == 0) {
// if the chunk file does not exist, it might have already been deleted.
// The call might be because of reapply of transactions on datanode
// restart.
if (!chunkFile.exists()) {
LOG.warn("Block file to be deleted does not exist: {}", chunkFile);
return;
}
}

if ((info.getOffset() > 0) || (info.getLen() != fileLength)) {
String msg = String.format(
"Trying to delete partial chunk %s from file %s with length %s",
Expand Down