LUCENE-3428: force DWPT unlock if unchecked exception is thrown by DWFC#addFlushableState

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1169877 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Willnauer 2011-09-12 19:18:05 +00:00
parent ef17a6766d
commit 0b55ddeedf
1 changed files with 16 additions and 8 deletions

View File

@ -366,6 +366,8 @@ public final class DocumentsWriterFlushControl {
ThreadState obtainAndLock() {
final ThreadState perThread = perThreadPool.getAndLock(Thread
.currentThread(), documentsWriter);
boolean success = false;
try {
if (perThread.isActive()
&& perThread.perThread.deleteQueue != documentsWriter.deleteQueue) {
// There is a flush-all in process and this DWPT is
@ -373,8 +375,14 @@ public final class DocumentsWriterFlushControl {
// 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();
}
}
}
void markForFullFlush() {