You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2011/11/07 21:14:23 UTC
svn commit: r1198911 -
/lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java
Author: simonw
Date: Mon Nov 7 20:14:23 2011
New Revision: 1198911
URL: http://svn.apache.org/viewvc?rev=1198911&view=rev
Log:
LUCENE-3528: singal waiting threads even when IS#close throws an exception
Modified:
lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java
Modified: lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java?rev=1198911&r1=1198910&r2=1198911&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java (original)
+++ lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/index/NRTManager.java Mon Nov 7 20:14:23 2011
@@ -51,6 +51,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;
@@ -275,6 +276,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();
}
@@ -298,13 +303,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;
}
}
@@ -339,7 +348,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();
}
}