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 2012/08/01 20:20:46 UTC

svn commit: r1368157 - in /lucene/dev/trunk/lucene: CHANGES.txt core/src/java/org/apache/lucene/index/DocumentsWriter.java core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java

Author: simonw
Date: Wed Aug  1 18:20:46 2012
New Revision: 1368157

URL: http://svn.apache.org/viewvc?rev=1368157&view=rev
Log:
LUCENE-4277: fix IndexWriter deadlock during rollback

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1368157&r1=1368156&r2=1368157&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Wed Aug  1 18:20:46 2012
@@ -140,6 +140,10 @@ Bug Fixes
   IndexWriter to only delete files matching this pattern from an index
   directory, to reduce risk when the wrong index path is accidentally
   passed to IndexWriter (Robert Muir, Mike McCandless)
+  
+* LUCENE-4277: Fix IndexWriter deadlock during rollback if flushable DWPT
+  instance are already checked out and queued up but not yet flushed. 
+  (Simon Willnauer)
 
 Changes in Runtime Behavior
 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=1368157&r1=1368156&r2=1368157&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java Wed Aug  1 18:20:46 2012
@@ -202,11 +202,9 @@ final class DocumentsWriter {
    *  discarding any docs added since last flush. */
   synchronized void abort() {
     boolean success = false;
-    synchronized (this) {
-      deleteQueue.clear();
-    }
 
     try {
+      deleteQueue.clear();
       if (infoStream.isEnabled("DW")) {
         infoStream.message("DW", "abort");
       }
@@ -230,6 +228,7 @@ final class DocumentsWriter {
           perThread.unlock();
         }
       }
+      flushControl.abortPendingFlushes();
       flushControl.waitForFlush();
       success = true;
     } finally {

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java?rev=1368157&r1=1368156&r2=1368157&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java Wed Aug  1 18:20:46 2012
@@ -567,19 +567,34 @@ final class DocumentsWriterFlushControl 
   }
 
   synchronized void abortFullFlushes() {
+   try {
+     abortPendingFlushes();
+   } finally {
+     fullFlush = false;
+   }
+  }
+  
+  synchronized void abortPendingFlushes() {
     try {
       for (DocumentsWriterPerThread dwpt : flushQueue) {
-        doAfterFlush(dwpt);
-        dwpt.abort();
+        try {
+          dwpt.abort();
+          doAfterFlush(dwpt);
+        } catch (Throwable ex) {
+          // ignore - keep on aborting the flush queue
+        }
       }
       for (BlockedFlush blockedFlush : blockedFlushes) {
-        flushingWriters
-            .put(blockedFlush.dwpt, Long.valueOf(blockedFlush.bytes));
-        doAfterFlush(blockedFlush.dwpt);
-        blockedFlush.dwpt.abort();
+        try {
+          flushingWriters
+              .put(blockedFlush.dwpt, Long.valueOf(blockedFlush.bytes));
+          blockedFlush.dwpt.abort();
+          doAfterFlush(blockedFlush.dwpt);
+        } catch (Throwable ex) {
+          // ignore - keep on aborting the blocked queue
+        }
       }
     } finally {
-      fullFlush = false;
       flushQueue.clear();
       blockedFlushes.clear();
       updateStallState();