Browse Source

HADOOP-3382. Fix memory leak when files are not cleanly closed (rangadi)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.17@656467 13f79535-47bb-0310-9956-ffa450edef68
Raghu Angadi 17 years ago
parent
commit
534fe7647f
2 changed files with 16 additions and 3 deletions
  1. 2 0
      CHANGES.txt
  2. 14 3
      src/java/org/apache/hadoop/dfs/FSNamesystem.java

+ 2 - 0
CHANGES.txt

@@ -584,6 +584,8 @@ Release 0.17.0 - Unreleased
 
     HADOOP-3031. Fix javac warnings in test classes. (cdouglas)
 
+    HADOOP-3382. Fix memory leak when files are not cleanly closed (rangadi)
+
 Release 0.16.4 - 2008-05-05
 
   BUG FIXES

+ 14 - 3
src/java/org/apache/hadoop/dfs/FSNamesystem.java

@@ -1845,6 +1845,17 @@ class FSNamesystem implements FSConstants, FSNamesystemMBean {
       Block last = blocks[blocks.length - 1];
       if (last.getNumBytes() == 0) {
           pendingFile.removeBlock(last);
+          blocksMap.removeINode(last);
+          for (Iterator<DatanodeDescriptor> it = 
+               blocksMap.nodeIterator(last); it.hasNext();) {
+            DatanodeDescriptor node = it.next();
+            addToInvalidates(last, node);
+          }
+          /* What else do we need to do?
+           * removeStoredBlock()? we do different things when a block is 
+           * removed in different contexts. Mostly these should be
+           * same and/or should be in one place.
+           */
       }
     }
 
@@ -1859,9 +1870,9 @@ class FSNamesystem implements FSConstants, FSNamesystemMBean {
     // replicate blocks of this file.
     checkReplicationFactor(newFile);
   
-    NameNode.stateChangeLog.debug("DIR* NameSystem.internalReleaseCreate: " + 
-                                  src + " is no longer written to by " + 
-                                  holder);
+    NameNode.stateChangeLog.info("DIR* NameSystem.internalReleaseCreate: " + 
+                                 src + " is no longer written to by " + 
+                                 holder);
   }
 
   /**