lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r635897 - in /lucene/java/branches/lucene_2_3: CHANGES.txt src/java/org/apache/lucene/index/DocumentsWriter.java src/test/org/apache/lucene/index/TestIndexWriter.java
Date Tue, 11 Mar 2008 12:18:34 GMT
Author: mikemccand
Date: Tue Mar 11 05:18:26 2008
New Revision: 635897

URL: http://svn.apache.org/viewvc?rev=635897&view=rev
Log:
LUCENE-1208 (porting to 2.3): fix deadlock case on hitting an exception while processing a
document that had triggered a flush

Modified:
    lucene/java/branches/lucene_2_3/CHANGES.txt
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java

Modified: lucene/java/branches/lucene_2_3/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/CHANGES.txt?rev=635897&r1=635896&r2=635897&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/CHANGES.txt (original)
+++ lucene/java/branches/lucene_2_3/CHANGES.txt Tue Mar 11 05:18:26 2008
@@ -19,6 +19,9 @@
  5. LUCENE-1200: Fix rare deadlock case in addIndexes* when
     ConcurrentMergeScheduler is in use (Mike McCandless)
 
+ 6. LUCENE-1208: Fix deadlock case on hitting an exception while
+    processing a document that had triggered a flush (Mike McCandless)
+
 ======================= Release 2.3.1 2008-02-22 =======================
 
 Bug fixes

Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=635897&r1=635896&r2=635897&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
(original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
Tue Mar 11 05:18:26 2008
@@ -2445,6 +2445,15 @@
       } finally {
         if (!success) {
           synchronized(this) {
+
+            // If this thread state had decided to flush, we
+            // must clear it so another thread can flush
+            if (state.doFlushAfter) {
+              state.doFlushAfter = false;
+              flushPending = false;
+              notifyAll();
+            }
+
             // Immediately mark this document as deleted
             // since likely it was partially added.  This
             // keeps indexing as "all or none" (atomic) when

Modified: lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=635897&r1=635896&r2=635897&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java
(original)
+++ lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java
Tue Mar 11 05:18:26 2008
@@ -2882,4 +2882,34 @@
     _TestUtil.checkIndex(dir);
     dir.close();
   }
+
+  // LUCENE-1208
+  public void testExceptionJustBeforeFlush() throws IOException {
+    MockRAMDirectory dir = new MockRAMDirectory();
+    MockIndexWriter w = new MockIndexWriter(dir, false, new WhitespaceAnalyzer(), true);
+    w.setMaxBufferedDocs(2);
+    Document doc = new Document();
+    doc.add(new Field("field", "a field", Field.Store.YES,
+                      Field.Index.TOKENIZED));
+    w.addDocument(doc);
+
+    Analyzer analyzer = new Analyzer() {
+      public TokenStream tokenStream(String fieldName, Reader reader) {
+        return new CrashingFilter(fieldName, new WhitespaceTokenizer(reader));
+      }
+    };
+
+    Document crashDoc = new Document();
+    crashDoc.add(new Field("crash", "do it on token 4", Field.Store.YES,
+                           Field.Index.TOKENIZED));
+    try {
+      w.addDocument(crashDoc, analyzer);
+      fail("did not hit exxpected exception");
+    } catch (IOException ioe) {
+      // expected
+    }
+    w.addDocument(doc);
+    w.close();
+    dir.close();
+  }    
 }



Mime
View raw message