hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r679461 - in /hadoop/core/branches/branch-0.18: CHANGES.txt src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java
Date Thu, 24 Jul 2008 16:51:28 GMT
Author: rangadi
Date: Thu Jul 24 09:51:28 2008
New Revision: 679461

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

Modified:
    hadoop/core/branches/branch-0.18/CHANGES.txt
    hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java

Modified: hadoop/core/branches/branch-0.18/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.18/CHANGES.txt?rev=679461&r1=679460&r2=679461&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.18/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.18/CHANGES.txt Thu Jul 24 09:51:28 2008
@@ -779,6 +779,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/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java?rev=679461&r1=679460&r2=679461&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java (original)
+++ hadoop/core/branches/branch-0.18/src/hdfs/org/apache/hadoop/dfs/FSNamesystem.java Thu
Jul 24 09:51:28 2008
@@ -2707,15 +2707,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) {
@@ -2793,8 +2799,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