Skip to content

Commit

Permalink
fix cleanup of tmp dir in HdfsDataSegmentPusher (#3639)
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshug authored and fjy committed Nov 1, 2016
1 parent 1125c5c commit 616735b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ public DataSegment push(File inDir, DataSegment segment) throws IOException

// Create parent if it does not exist, recreation is not an error
fs.mkdirs(outDir.getParent());

if (!fs.rename(tmpFile.getParent(), outDir)) {
if (!fs.delete(tmpFile.getParent(), true)) {
log.error("Failed to delete temp directory[%s]", tmpFile.getParent());
}
if (fs.exists(outDir)) {
log.info(
"Unable to rename temp directory[%s] to segment directory[%s]. It is already pushed by a replica task.",
Expand All @@ -134,6 +130,14 @@ public DataSegment push(File inDir, DataSegment segment) throws IOException
));
}
}
} finally {
try {
if (fs.exists(tmpFile.getParent()) && !fs.delete(tmpFile.getParent(), true)) {
log.error("Failed to delete temp directory[%s]", tmpFile.getParent());
}
} catch(IOException ex) {
log.error(ex, "Failed to delete temp directory[%s]", tmpFile.getParent());
}
}

return dataSegment;
Expand Down

0 comments on commit 616735b

Please sign in to comment.