diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5c4e16e4515..06b87ec651c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -41,6 +41,9 @@ Release 2.7.2 - UNRELEASED HDFS-8995. Flaw in registration bookeeping can make DN die on reconnect. (Kihwal Lee via yliu) + HDFS-8384. Allow NN to startup if there are files having a lease but are not + under construction. (jing9) + Release 2.7.1 - 2015-07-06 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 0888e80ad10..2dda12b6dd4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -4195,7 +4195,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, assert hasWriteLock(); FileUnderConstructionFeature uc = pendingFile.getFileUnderConstructionFeature(); - Preconditions.checkArgument(uc != null); + if (uc == null) { + throw new IOException("Cannot finalize file " + src + + " because it is not under construction"); + } leaseManager.removeLease(uc.getClientName(), src); pendingFile.recordModification(latestSnapshot); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java index 9ce8ebc650e..c0438273225 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java @@ -116,7 +116,11 @@ public class LeaseManager { final INodeFile cons; try { cons = this.fsnamesystem.getFSDirectory().getINode(path).asFile(); - Preconditions.checkState(cons.isUnderConstruction()); + if (!cons.isUnderConstruction()) { + LOG.warn("The file " + cons.getFullPathName() + + " is not under construction but has lease."); + continue; + } } catch (UnresolvedLinkException e) { throw new AssertionError("Lease files should reside on this FS"); } @@ -444,8 +448,12 @@ public class LeaseManager { // verify that path exists in namespace try { INodeFile node = INodeFile.valueOf(fsnamesystem.dir.getINode(p), p); - Preconditions.checkState(node.isUnderConstruction()); - inodes.put(p, node); + if (node.isUnderConstruction()) { + inodes.put(p, node); + } else { + LOG.warn("Ignore the lease of file " + p + + " for checkpoint since the file is not under construction"); + } } catch (IOException ioe) { LOG.error(ioe); }