HDFS-12358. Handle IOException when transferring edit log to Journal current dir through JN sync. Contributed by Hanisha Koneru.

This commit is contained in:
Arpit Agarwal 2017-08-26 22:47:55 -07:00
parent bb6a3c8330
commit 077a5eed9f
1 changed files with 14 additions and 11 deletions

View File

@ -403,20 +403,23 @@ private boolean downloadMissingLogSegment(URL url, RemoteEditLog log)
LOG.info("Downloaded file " + tmpEditsFile.getName() + " of size " +
tmpEditsFile.length() + " bytes.");
final boolean moveSuccess = journal.moveTmpSegmentToCurrent(tmpEditsFile,
boolean moveSuccess = false;
try {
moveSuccess = journal.moveTmpSegmentToCurrent(tmpEditsFile,
finalEditsFile, log.getEndTxId());
if (!moveSuccess) {
// If move is not successful, delete the tmpFile
LOG.debug("Move to current directory unsuccessful. Deleting temporary " +
"file: " + tmpEditsFile);
if (!tmpEditsFile.delete()) {
} catch (IOException e) {
LOG.info("Could not move %s to current directory.", tmpEditsFile);
} finally {
if (tmpEditsFile.exists() && !tmpEditsFile.delete()) {
LOG.warn("Deleting " + tmpEditsFile + " has failed");
}
return false;
} else {
metrics.incrNumEditLogsSynced();
}
if (moveSuccess) {
metrics.incrNumEditLogsSynced();
return true;
} else {
return false;
}
}
private static DataTransferThrottler getThrottler(Configuration conf) {