Author: kihwal
Date: Mon Dec  2 21:34:26 2013
New Revision: 1547197

URL: http://svn.apache.org/r1547197
Log:
HDFS-5558. LeaseManager monitor thread can crash if the last block is complete 
but another block is not. Contributed by Kihwal Lee.

Modified:
    
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Modified: 
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1547197&r1=1547196&r2=1547197&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt 
(original)
+++ 
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt 
Mon Dec  2 21:34:26 2013
@@ -65,6 +65,9 @@ Release 0.23.10 - UNRELEASED
     HDFS-5557. Write pipeline recovery for the last packet in the block may
     cause rejection of valid replicas. (kihwal)
 
+    HDFS-5558. LeaseManager monitor thread can crash if the last block is
+    complete but another block is not. (kihwal)
+
 Release 0.23.9 - 2013-07-08
 
   INCOMPATIBLE CHANGES

Modified: 
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1547197&r1=1547196&r2=1547197&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
 (original)
+++ 
hadoop/common/branches/branch-0.23/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
 Mon Dec  2 21:34:26 2013
@@ -1529,15 +1529,15 @@ public class FSNamesystem implements Nam
 
       INodeFileUnderConstruction pendingFile  = checkLease(src, clientName);
 
-      // commit the last block and complete it if it has minimum replicas
-      commitOrCompleteLastBlock(pendingFile, 
ExtendedBlock.getLocalBlock(previous));
-
-      //
-      // If we fail this, bad things happen!
-      //
+      // Make sure the penultimate block is complete before completing 
+      // the last block and adding another block
       if (!checkFileProgress(pendingFile, false)) {
         throw new NotReplicatedYetException("Not replicated yet:" + src);
       }
+
+      // commit the last block and complete it if it has minimum replicas
+      commitOrCompleteLastBlock(pendingFile, 
ExtendedBlock.getLocalBlock(previous));
+
       fileLength = pendingFile.computeContentSummary().getLength();
       blockSize = pendingFile.getPreferredBlockSize();
       clientNode = pendingFile.getClientNode();
@@ -1728,6 +1728,11 @@ public class FSNamesystem implements Nam
     }
 
     INodeFileUnderConstruction pendingFile = checkLease(src, holder);
+     // Check the state of the penultimate block. It should be completed
+     // before attempting to complete the last one.
+     if (!checkFileProgress(pendingFile, false)) {
+       return false;
+     }
     // commit the last block and complete it if it has minimum replicas
     commitOrCompleteLastBlock(pendingFile, last);
 
@@ -1806,7 +1811,7 @@ public class FSNamesystem implements Nam
         //
         BlockInfo b = v.getPenultimateBlock();
         if (b != null && !b.isComplete()) {
-          LOG.info("BLOCK* NameSystem.checkFileProgress: "
+          LOG.warn("BLOCK* NameSystem.checkFileProgress: "
               + "block " + b + " has not reached minimal replication "
               + blockManager.minReplication);
           return false;


Reply via email to