hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r679459 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Date Thu, 24 Jul 2008 16:49:21 GMT
Author: rangadi
Date: Thu Jul 24 09:49:20 2008
New Revision: 679459

URL: http://svn.apache.org/viewvc?rev=679459&view=rev
Log:
HADOOP-3776. Fix NPE at NameNode when datanode reports a block after it is
deleted at NameNode. (rangadi)

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=679459&r1=679458&r2=679459&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Jul 24 09:49:20 2008
@@ -917,6 +917,9 @@
 
     HADOOP-3806. Remove debug statement to stdout from QuickSort. (cdouglas)
 
+    HADOOP-3776. Fix NPE at NameNode when datanode reports a block after it is
+    deleted at NameNode. (rangadi)
+
 Release 0.17.2 - Unreleased
 
   BUG FIXES

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=679459&r1=679458&r2=679459&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Thu
Jul 24 09:49:20 2008
@@ -2694,15 +2694,21 @@
                                     DatanodeDescriptor node,
                                     DatanodeDescriptor delNodeHint) {
     BlockInfo storedBlock = blocksMap.getStoredBlock(block);
-    boolean added = false;
-    if(storedBlock == null) { // block is not in the blocksMaps
-      // add block to the blocksMap and to the data-node
-      added = blocksMap.addNode(block, node, defaultReplication);
-      storedBlock = blocksMap.getStoredBlock(block);
-    } else {
-      // add block to the data-node
-      added = node.addBlock(storedBlock);
-    }
+    if(storedBlock == null || storedBlock.getINode() == null) {
+      // If this block does not belong to anyfile, then we are done.
+      NameNode.stateChangeLog.info("BLOCK* NameSystem.addStoredBlock: "
+                                   + "addStoredBlock request received for " 
+                                   + block + " on " + node.getName()
+                                   + " size " + block.getNumBytes()
+                                   + " But it does not belong to any file.");
+      // we could add this block to invalidate set of this datanode. 
+      // it will happen in next block report otherwise.
+      return block;      
+    }
+     
+    // add block to the data-node
+    boolean added = node.addBlock(storedBlock);
+    
     assert storedBlock != null : "Block must be stored by now";
 
     if (block != storedBlock) {
@@ -2780,8 +2786,6 @@
                                    + " size " + block.getNumBytes());
     }
 
-    assert isValidBlock(storedBlock) : "Trying to add an invalid block";
-
     // filter out containingNodes that are marked for decommission.
     NumberReplicas num = countNodes(storedBlock);
     int numLiveReplicas = num.liveReplicas();



Mime
View raw message