Browse Source

HDFS-7042. Upgrade fails for Windows HA cluster due to file locks held during rename in JournalNode. Contributed by Chris Nauroth.

(cherry picked from commit 80ac6aabcea9f808fd55504cdaef2da7b50da7f1)
cnauroth 10 years ago
parent
commit
ac296f9522

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -493,6 +493,9 @@ Release 2.6.0 - UNRELEASED
     HDFS-6776. Using distcp to copy data between insecure and secure cluster via webdhfs 
     doesn't work. (yzhangal via tucu)
 
+    HDFS-7042. Upgrade fails for Windows HA cluster due to file locks held during
+    rename in JournalNode. (cnauroth)
+
 Release 2.5.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 7 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java

@@ -994,6 +994,9 @@ public class Journal implements Closeable {
   }
 
   public synchronized void doPreUpgrade() throws IOException {
+    // Do not hold file lock on committedTxnId, because the containing
+    // directory will be renamed.  It will be reopened lazily on next access.
+    committedTxnId.close();
     storage.getJournalManager().doPreUpgrade();
   }
 
@@ -1043,7 +1046,10 @@ public class Journal implements Closeable {
         targetLayoutVersion);
   }
 
-  public void doRollback() throws IOException {
+  public synchronized void doRollback() throws IOException {
+    // Do not hold file lock on committedTxnId, because the containing
+    // directory will be renamed.  It will be reopened lazily on next access.
+    committedTxnId.close();
     storage.getJournalManager().doRollback();
   }
 

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/util/BestEffortLongFile.java

@@ -112,6 +112,7 @@ public class BestEffortLongFile implements Closeable {
   public void close() throws IOException {
     if (ch != null) {
       ch.close();
+      ch = null;
     }
   }
 }