Browse Source

HADOOP-1135. Fix bug in block report processing which may cause the namenode to delete blocks. Contributed by Dhruba Borthakur.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@521148 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 18 years ago
parent
commit
51e7a0fb0b
2 changed files with 12 additions and 6 deletions
  1. 6 0
      CHANGES.txt
  2. 6 6
      src/java/org/apache/hadoop/dfs/FSNamesystem.java

+ 6 - 0
CHANGES.txt

@@ -1,6 +1,12 @@
 Hadoop Change Log
 Hadoop Change Log
 
 
 
 
+Trunk (unreleased changes)
+
+ 1. HADOOP-1135.  Fix bug in block report processing which may cause
+    the namenode to delete blocks.  (Dhruba Borthakur via tomwhite)
+
+
 Release 0.12.1 - 2007-03-17
 Release 0.12.1 - 2007-03-17
 
 
  1. HADOOP-1035.  Fix a StackOverflowError in FSDataSet.
  1. HADOOP-1035.  Fix a StackOverflowError in FSDataSet.

+ 6 - 6
src/java/org/apache/hadoop/dfs/FSNamesystem.java

@@ -2051,14 +2051,14 @@ class FSNamesystem implements FSConstants {
             // they are added to recentInvalidateSets and will be sent out
             // they are added to recentInvalidateSets and will be sent out
             // thorugh succeeding heartbeat responses.
             // thorugh succeeding heartbeat responses.
             //
             //
-            if (obsolete.size() > FSConstants.BLOCK_INVALIDATE_CHUNK) {
+            if (! dir.isValidBlock(b) && ! pendingCreateBlocks.contains(b)) {
+              if (obsolete.size() > FSConstants.BLOCK_INVALIDATE_CHUNK) {
                 addToInvalidates(b, node);
                 addToInvalidates(b, node);
-            } else {
-                if (! dir.isValidBlock(b) && ! pendingCreateBlocks.contains(b)) {
-                  obsolete.add(b);
-                  NameNode.stateChangeLog.debug("BLOCK* NameSystem.processReport: "
+              } else {
+                obsolete.add(b);
+              }
+              NameNode.stateChangeLog.debug("BLOCK* NameSystem.processReport: "
                         +"ask "+nodeID.getName()+" to delete "+b.getBlockName() );
                         +"ask "+nodeID.getName()+" to delete "+b.getBlockName() );
-                }
             }
             }
         }
         }
         return (Block[]) obsolete.toArray(new Block[obsolete.size()]);
         return (Block[]) obsolete.toArray(new Block[obsolete.size()]);