lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1029039 - in /lucene/java/branches/lucene_3_0: ./ src/java/org/apache/lucene/index/ src/test/org/apache/lucene/index/
Date Sat, 30 Oct 2010 12:10:05 GMT
Author: mikemccand
Date: Sat Oct 30 12:10:04 2010
New Revision: 1029039

URL: http://svn.apache.org/viewvc?rev=1029039&view=rev
Log:
LUCENE-2328: don't leak memory tracking sync'd files in IW

Modified:
    lucene/java/branches/lucene_3_0/CHANGES.txt
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexFileDeleter.java
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexReader.java
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriterDelete.java

Modified: lucene/java/branches/lucene_3_0/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/CHANGES.txt?rev=1029039&r1=1029038&r2=1029039&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/CHANGES.txt (original)
+++ lucene/java/branches/lucene_3_0/CHANGES.txt Sat Oct 30 12:10:04 2010
@@ -61,6 +61,9 @@ Bug fixes
 * LUCENE-2235: Implement missing PerFieldAnalyzerWrapper.getOffsetGap().
   (Javier Godoy via Uwe Schindler)
 
+* LUCENE-2328: Fixed memory leak in how IndexWriter/Reader tracked
+  already sync'd files. (Earwin Burrfoot via Mike McCandless)
+
 * LUCENE-2549: Fix TimeLimitingCollector#TimeExceededException to record
   the absolute docid.  (Uwe Schindler)
  

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/DirectoryReader.java?rev=1029039&r1=1029038&r2=1029039&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/DirectoryReader.java
(original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/DirectoryReader.java
Sat Oct 30 12:10:04 2010
@@ -733,7 +733,7 @@ class DirectoryReader extends IndexReade
       // KeepOnlyLastCommitDeleter:
       IndexFileDeleter deleter = new IndexFileDeleter(directory,
                                                       deletionPolicy == null ? new KeepOnlyLastCommitDeletionPolicy()
: deletionPolicy,
-                                                      segmentInfos, null, null);
+                                                      segmentInfos, null, null, synced);
       segmentInfos.updateGeneration(deleter.getLastSegmentInfos());
 
       // Checkpoint the state we are about to change, in

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexFileDeleter.java?rev=1029039&r1=1029038&r2=1029039&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexFileDeleter.java
(original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexFileDeleter.java
Sat Oct 30 12:10:04 2010
@@ -24,6 +24,7 @@ import java.io.FileNotFoundException;
 import java.io.PrintStream;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Set;
 
 import java.util.List;
 import java.util.ArrayList;
@@ -101,6 +102,8 @@ final class IndexFileDeleter {
   final boolean startingCommitDeleted;
   private SegmentInfos lastSegmentInfos;
 
+  private final Set<String> synced;
+
   /** Change to true to see details of reference counts when
    *  infoStream != null */
   public static boolean VERBOSE_REF_COUNTS = false;
@@ -123,11 +126,12 @@ final class IndexFileDeleter {
    * @throws CorruptIndexException if the index is corrupt
    * @throws IOException if there is a low-level IO error
    */
-  public IndexFileDeleter(Directory directory, IndexDeletionPolicy policy, SegmentInfos segmentInfos,
PrintStream infoStream, DocumentsWriter docWriter)
+  public IndexFileDeleter(Directory directory, IndexDeletionPolicy policy, SegmentInfos segmentInfos,
PrintStream infoStream, DocumentsWriter docWriter, Set<String> synced)
     throws CorruptIndexException, IOException {
 
     this.docWriter = docWriter;
     this.infoStream = infoStream;
+    this.synced = synced;
 
     if (infoStream != null)
       message("init: current segments file is \"" + segmentInfos.getCurrentSegmentFileName()
+ "\"; deletionPolicy=" + policy);
@@ -476,6 +480,12 @@ final class IndexFileDeleter {
       // commit points nor by the in-memory SegmentInfos:
       deleteFile(fileName);
       refCounts.remove(fileName);
+
+      if (synced != null) {
+        synchronized(synced) {
+          synced.remove(fileName);
+        }
+      }
     }
   }
 

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java?rev=1029039&r1=1029038&r2=1029039&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java Sat
Oct 30 12:10:04 2010
@@ -1126,7 +1126,7 @@ public class IndexWriter implements Clos
       // KeepOnlyLastCommitDeleter:
       deleter = new IndexFileDeleter(directory,
                                      deletionPolicy == null ? new KeepOnlyLastCommitDeletionPolicy()
: deletionPolicy,
-                                     segmentInfos, infoStream, docWriter);
+                                     segmentInfos, infoStream, docWriter, synced);
 
       if (deleter.startingCommitDeleted)
         // Deletion policy deleted the "head" commit point.
@@ -4567,7 +4567,7 @@ public class IndexWriter implements Clos
   }
 
   // Files that have been sync'd already
-  private HashSet<String> synced = new HashSet<String>();
+  private final HashSet<String> synced = new HashSet<String>();
 
   // Files that are now being sync'd
   private HashSet<String> syncing = new HashSet<String>();

Modified: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexReader.java?rev=1029039&r1=1029038&r2=1029039&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexReader.java
(original)
+++ lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexReader.java
Sat Oct 30 12:10:04 2010
@@ -989,7 +989,7 @@ public class TestIndexReader extends Luc
           String[] startFiles = dir.listAll();
           SegmentInfos infos = new SegmentInfos();
           infos.read(dir);
-          new IndexFileDeleter(dir, new KeepOnlyLastCommitDeletionPolicy(), infos, null,
null);
+          new IndexFileDeleter(dir, new KeepOnlyLastCommitDeletionPolicy(), infos, null,
null, null);
           String[] endFiles = dir.listAll();
 
           Arrays.sort(startFiles);

Modified: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1029039&r1=1029038&r2=1029039&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriter.java
(original)
+++ lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriter.java
Sat Oct 30 12:10:04 2010
@@ -524,7 +524,7 @@ public class TestIndexWriter extends Luc
       String[] startFiles = dir.listAll();
       SegmentInfos infos = new SegmentInfos();
       infos.read(dir);
-      new IndexFileDeleter(dir, new KeepOnlyLastCommitDeletionPolicy(), infos, null, null);
+      new IndexFileDeleter(dir, new KeepOnlyLastCommitDeletionPolicy(), infos, null, null,
null);
       String[] endFiles = dir.listAll();
 
       Arrays.sort(startFiles);

Modified: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriterDelete.java?rev=1029039&r1=1029038&r2=1029039&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
(original)
+++ lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
Sat Oct 30 12:10:04 2010
@@ -790,7 +790,7 @@ public class TestIndexWriterDelete exten
     String[] startFiles = dir.listAll();
     SegmentInfos infos = new SegmentInfos();
     infos.read(dir);
-    new IndexFileDeleter(dir, new KeepOnlyLastCommitDeletionPolicy(), infos, null, null);
+    new IndexFileDeleter(dir, new KeepOnlyLastCommitDeletionPolicy(), infos, null, null,
null);
     String[] endFiles = dir.listAll();
 
     if (!Arrays.equals(startFiles, endFiles)) {



Mime
View raw message