lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r1199408 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/backwards/src/test/ lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java solr/
Date Tue, 08 Nov 2011 19:34:58 GMT
Author: simonw
Date: Tue Nov  8 19:34:57 2011
New Revision: 1199408

URL: http://svn.apache.org/viewvc?rev=1199408&view=rev
Log:
LUCENE-3528: singal waiting threads even when IS#close throws an exception

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/backwards/src/test/   (props changed)
    lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java
    lucene/dev/branches/branch_3x/solr/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java?rev=1199408&r1=1199407&r2=1199408&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java
Tue Nov  8 19:34:57 2011
@@ -53,6 +53,7 @@ import org.apache.lucene.util.ThreadInte
  */
 
 public class NRTManager implements Closeable {
+  private static final long MAX_SEARCHER_GEN = Long.MAX_VALUE;
   private final IndexWriter writer;
   private final SearcherManagerRef withoutDeletes;
   private final SearcherManagerRef withDeletes;
@@ -277,6 +278,10 @@ public class NRTManager implements Close
         // Mark gen as of when reopen started:
         final long newSearcherGen = indexingGen.getAndIncrement();
         boolean setSearchGen = false;
+        if (reference.generation == MAX_SEARCHER_GEN) {
+          newGeneration.signalAll(); // wake up threads if we have a new generation
+          return false;
+        }
         if (!(setSearchGen = reference.manager.isSearcherCurrent())) {
           setSearchGen = reference.manager.maybeReopen();
         }
@@ -300,13 +305,17 @@ public class NRTManager implements Close
    * <p>
    * <b>NOTE</b>: caller must separately close the writer.
    */
-  public synchronized void close() throws IOException {
+  public void close() throws IOException {
     reopenLock.lock();
     try {
-      IOUtils.close(withDeletes, withoutDeletes);
-      newGeneration.signalAll();
+      try {
+        IOUtils.close(withDeletes, withoutDeletes);
+      } finally { // make sure we signal even if close throws an exception
+        newGeneration.signalAll();
+      }
     } finally {
       reopenLock.unlock();
+      assert withDeletes.generation == MAX_SEARCHER_GEN && withoutDeletes.generation
== MAX_SEARCHER_GEN;
     }
   }
 
@@ -341,7 +350,7 @@ public class NRTManager implements Close
     }
     
     public void close() throws IOException {
-      generation = Long.MAX_VALUE; // max it out to make sure nobody can wait on another
gen
+      generation = MAX_SEARCHER_GEN; // max it out to make sure nobody can wait on another
gen
       manager.close();
     }
   }



Mime
View raw message