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/09/12 21:18:05 UTC
svn commit: r1169877 -
/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
Author: simonw
Date: Mon Sep 12 19:18:05 2011
New Revision: 1169877
URL: http://svn.apache.org/viewvc?rev=1169877&view=rev
Log:
LUCENE-3428: force DWPT unlock if unchecked exception is thrown by DWFC#addFlushableState
Modified:
lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java?rev=1169877&r1=1169876&r2=1169877&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java Mon Sep 12 19:18:05 2011
@@ -366,15 +366,23 @@ public final class DocumentsWriterFlushC
ThreadState obtainAndLock() {
final ThreadState perThread = perThreadPool.getAndLock(Thread
.currentThread(), documentsWriter);
- if (perThread.isActive()
- && perThread.perThread.deleteQueue != documentsWriter.deleteQueue) {
- // There is a flush-all in process and this DWPT is
- // now stale -- enroll it for flush and try for
- // another DWPT:
- addFlushableState(perThread);
+ boolean success = false;
+ try {
+ if (perThread.isActive()
+ && perThread.perThread.deleteQueue != documentsWriter.deleteQueue) {
+ // There is a flush-all in process and this DWPT is
+ // now stale -- enroll it for flush and try for
+ // another DWPT:
+ addFlushableState(perThread);
+ }
+ success = true;
+ // simply return the ThreadState even in a flush all case sine we already hold the lock
+ return perThread;
+ } finally {
+ if (!success) { // make sure we unlock if this fails
+ perThread.unlock();
+ }
}
- // simply return the ThreadState even in a flush all case sine we already hold the lock
- return perThread;
}
void markForFullFlush() {