You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2010/10/23 12:06:41 UTC

svn commit: r1026592 - in /lucene/dev/trunk/lucene/src: java/org/apache/lucene/index/IndexWriter.java test/org/apache/lucene/index/TestBackwardsCompatibility.java

Author: mikemccand
Date: Sat Oct 23 10:06:40 2010
New Revision: 1026592

URL: http://svn.apache.org/viewvc?rev=1026592&view=rev
Log:
LUCENE-2618: allow optimize to complete during IW.close, take 2

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1026592&r1=1026591&r2=1026592&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java Sat Oct 23 10:06:40 2010
@@ -1064,6 +1064,12 @@ public class IndexWriter implements Clos
 
     boolean success = false;
 
+    // TODO: we should check whether this index is too old,
+    // and throw an IndexFormatTooOldExc up front, here,
+    // instead of later when merge, applyDeletes, getReader
+    // is attempted.  I think to do this we should store the
+    // oldest segment's version in segments_N.
+
     try {
       if (create) {
         // Try to read first.  This is to allow create
@@ -3662,7 +3668,7 @@ public class IndexWriter implements Clos
           // This merge (and, generally, any change to the
           // segments) may now enable new merges, so we call
           // merge policy & update pending merges.
-          if (success && !merge.isAborted() && !closed && !closing) {
+          if (success && !merge.isAborted() && (merge.optimize || (!closed && !closing))) {
             updatePendingMerges(merge.maxNumSegmentsOptimize, merge.optimize);
           }
         }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1026592&r1=1026591&r2=1026592&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Sat Oct 23 10:06:40 2010
@@ -183,7 +183,15 @@ public class TestBackwardsCompatibility 
       } finally {
         if (reader != null) reader.close();
         reader = null;
-        if (writer != null) writer.close();
+        if (writer != null) {
+          try {
+            writer.close();
+          } catch (IndexFormatTooOldException e) {
+            // OK -- since IW gives merge scheduler a chance
+            // to merge at close, it's possible and fine to
+            // hit this exc here
+          }
+        }
         writer = null;
       }