From 077a5eed9f505f3ad8fe46d86f3fabed762eeb15 Mon Sep 17 00:00:00 2001 From: Arpit Agarwal Date: Sat, 26 Aug 2017 22:47:55 -0700 Subject: [PATCH] HDFS-12358. Handle IOException when transferring edit log to Journal current dir through JN sync. Contributed by Hanisha Koneru. --- .../qjournal/server/JournalNodeSyncer.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java index 537ba0a0fd..0155b85411 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java @@ -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, - 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()) { + boolean moveSuccess = false; + try { + moveSuccess = journal.moveTmpSegmentToCurrent(tmpEditsFile, + finalEditsFile, log.getEndTxId()); + } 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(); } - return true; + if (moveSuccess) { + metrics.incrNumEditLogsSynced(); + return true; + } else { + return false; + } } private static DataTransferThrottler getThrottler(Configuration conf) {