Kaynağa Gözat

HADOOP-849. Fix OutOfMemory exceptions in TaskTracker due to a file handle leak in SequenceFile. Contributed by Devaraj.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@492243 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 yıl önce
ebeveyn
işleme
ef0cb35bf5
2 değiştirilmiş dosya ile 16 ekleme ve 0 silme
  1. 4 0
      CHANGES.txt
  2. 12 0
      src/java/org/apache/hadoop/io/SequenceFile.java

+ 4 - 0
CHANGES.txt

@@ -156,6 +156,10 @@ Trunk (unreleased changes)
 43. HADOOP-844.  Send metrics messages on a fixed-delay schedule
     instead of a fixed-rate schedule.  (David Bowen via cutting)
 
+44. HADOOP-849.  Fix OutOfMemory exceptions in TaskTracker due to a
+    file handle leak in SequenceFile.  (Devaraj Das via cutting)
+
+
 Release 0.9.2 - 2006-12-15
 
  1. HADOOP-639. Restructure InterTrackerProtocol to make task

+ 12 - 0
src/java/org/apache/hadoop/io/SequenceFile.java

@@ -2167,6 +2167,17 @@ public class SequenceFile {
             //queue
             this.close();
             
+            //this is required to handle the corner case where we have empty
+            //map outputs to merge. The empty map outputs will just have the 
+            //sequence file header; they won't be inserted in the priority 
+            //queue. Thus, they won't be deleted in the regular process where 
+            //cleanup happens when a stream is popped off (when the key/value
+            //from that stream has been iterated over) from the queue.
+            for (int i = 0; i < mStream.length; i++) {
+              if (mStream[i].in != null) //true if cleanup didn't happen
+                mStream[i].cleanup();
+            }
+
             SegmentDescriptor tempSegment = 
                  new SegmentDescriptor(0, fs.getLength(outputFile), outputFile);
             //put the segment back in the TreeMap
@@ -2305,6 +2316,7 @@ public class SequenceFile {
       /** closes the underlying reader */
       private void close() throws IOException {
         this.in.close();
+        this.in = null;
       }
 
       /** The default cleanup. Subclasses can override this with a custom