lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r613615 - in /lucene/java/branches/lucene_2_3/src: java/org/apache/lucene/index/ test/org/apache/lucene/index/
Date Sun, 20 Jan 2008 17:05:00 GMT
Author: mikemccand
Date: Sun Jan 20 09:04:58 2008
New Revision: 613615

URL: http://svn.apache.org/viewvc?rev=613615&view=rev
Log:
LUCENE-1143: clear docStoreOffset when DocumentsWriter aborts

Modified:
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
    lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestIndexWriter.java

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=613615&r1=613614&r2=613615&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
Sun Jan 20 09:04:58 2008
@@ -423,6 +423,8 @@
         resetPostingsData();
 
         docStoreSegment = null;
+        numDocsInStore = 0;
+        docStoreOffset = 0;
         files = null;
 
       } finally {

Modified: lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java?rev=613615&r1=613614&r2=613615&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/branches/lucene_2_3/src/java/org/apache/lucene/index/IndexWriter.java Sun
Jan 20 09:04:58 2008
@@ -2447,6 +2447,11 @@
       }
 
       int docStoreOffset = docWriter.getDocStoreOffset();
+
+      // docStoreOffset should only be non-zero when
+      // autoCommit == false
+      assert !autoCommit || 0 == docStoreOffset;
+
       boolean docStoreIsCompoundFile = false;
 
       // Check if the doc stores must be separately flushed

Modified: lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java?rev=613615&r1=613614&r2=613615&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
(original)
+++ lucene/java/branches/lucene_2_3/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
Sun Jan 20 09:04:58 2008
@@ -76,10 +76,8 @@
         writer.addDocument(doc);
       }
 
-      // Even though this won't delete any docs,
-      // IndexWriter's flush will still make a clone for all
-      // SegmentInfos on hitting the exception:
-      writer.deleteDocuments(new Term("id", "1000"));
+      writer.addDocument(doc);
+
       failure.setDoFail();
       try {
         writer.flush();

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=613615&r1=613614&r2=613615&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
Sun Jan 20 09:04:58 2008
@@ -2254,8 +2254,9 @@
 
       int idUpto = 0;
       int fullCount = 0;
+      final long stopTime = System.currentTimeMillis() + 500;
 
-      while(true) {
+      while(System.currentTimeMillis() < stopTime) {
         try {
           writer.updateDocument(new Term("id", ""+(idUpto++)), doc);
         } catch (IOException ioe) {
@@ -2435,13 +2436,20 @@
 
   // Throws IOException during FieldsWriter.flushDocument and during DocumentsWriter.abort
   private static class FailOnlyOnAbortOrFlush extends MockRAMDirectory.Failure {
+    private boolean onlyOnce;
+    public FailOnlyOnAbortOrFlush(boolean onlyOnce) {
+      this.onlyOnce = true;
+    }
     public void eval(MockRAMDirectory dir)  throws IOException {
       if (doFail) {
         StackTraceElement[] trace = new Exception().getStackTrace();
         for (int i = 0; i < trace.length; i++) {
           if ("abort".equals(trace[i].getMethodName()) ||
-              "flushDocument".equals(trace[i].getMethodName()))
+              "flushDocument".equals(trace[i].getMethodName())) {
+            if (onlyOnce)
+              doFail = false;
             throw new IOException("now failing on purpose");
+          }
         }
       }
     }
@@ -2522,11 +2530,24 @@
           assertTrue("hit unexpected Throwable", threads[i].error == null);
       }
 
+      boolean success = false;
       try {
         writer.close(false);
+        success = true;
       } catch (IOException ioe) {
       }
 
+      if (success) {
+        IndexReader reader = IndexReader.open(dir);
+        for(int j=0;j<reader.maxDoc();j++) {
+          if (!reader.isDeleted(j)) {
+            reader.document(j);
+            reader.getTermFreqVectors(j);
+          }
+        }
+        reader.close();
+      }
+
       dir.close();
     }
   }
@@ -2534,23 +2555,42 @@
   // LUCENE-1130: make sure initial IOException, and then 2nd
   // IOException during abort(), is OK:
   public void testIOExceptionDuringAbort() throws IOException {
-    _testSingleThreadFailure(new FailOnlyOnAbortOrFlush());
+    _testSingleThreadFailure(new FailOnlyOnAbortOrFlush(false));
+  }
+
+  // LUCENE-1130: make sure initial IOException, and then 2nd
+  // IOException during abort(), is OK:
+  public void testIOExceptionDuringAbortOnlyOnce() throws IOException {
+    _testSingleThreadFailure(new FailOnlyOnAbortOrFlush(true));
   }
 
   // LUCENE-1130: make sure initial IOException, and then 2nd
   // IOException during abort(), with multiple threads, is OK:
   public void testIOExceptionDuringAbortWithThreads() throws IOException {
-    _testMultipleThreadsFailure(new FailOnlyOnAbortOrFlush());
+    _testMultipleThreadsFailure(new FailOnlyOnAbortOrFlush(false));
+  }
+
+  // LUCENE-1130: make sure initial IOException, and then 2nd
+  // IOException during abort(), with multiple threads, is OK:
+  public void testIOExceptionDuringAbortWithThreadsOnlyOnce() throws IOException {
+    _testMultipleThreadsFailure(new FailOnlyOnAbortOrFlush(true));
   }
 
   // Throws IOException during DocumentsWriter.closeDocStore
   private static class FailOnlyInCloseDocStore extends MockRAMDirectory.Failure {
+    private boolean onlyOnce;
+    public FailOnlyInCloseDocStore(boolean onlyOnce) {
+      this.onlyOnce = true;
+    }
     public void eval(MockRAMDirectory dir)  throws IOException {
       if (doFail) {
         StackTraceElement[] trace = new Exception().getStackTrace();
         for (int i = 0; i < trace.length; i++) {
-          if ("closeDocStore".equals(trace[i].getMethodName()))
+          if ("closeDocStore".equals(trace[i].getMethodName())) {
+            if (onlyOnce)
+              doFail = false;
             throw new IOException("now failing on purpose");
+          }
         }
       }
     }
@@ -2558,33 +2598,62 @@
 
   // LUCENE-1130: test IOException in closeDocStore
   public void testIOExceptionDuringCloseDocStore() throws IOException {
-    _testSingleThreadFailure(new FailOnlyInCloseDocStore());
+    _testSingleThreadFailure(new FailOnlyInCloseDocStore(false));
+  }
+
+  // LUCENE-1130: test IOException in closeDocStore
+  public void testIOExceptionDuringCloseDocStoreOnlyOnce() throws IOException {
+    _testSingleThreadFailure(new FailOnlyInCloseDocStore(true));
   }
 
   // LUCENE-1130: test IOException in closeDocStore, with threads
   public void testIOExceptionDuringCloseDocStoreWithThreads() throws IOException {
-    _testMultipleThreadsFailure(new FailOnlyInCloseDocStore());
+    _testMultipleThreadsFailure(new FailOnlyInCloseDocStore(false));
+  }
+
+  // LUCENE-1130: test IOException in closeDocStore, with threads
+  public void testIOExceptionDuringCloseDocStoreWithThreadsOnlyOnce() throws IOException
{
+    _testMultipleThreadsFailure(new FailOnlyInCloseDocStore(true));
   }
 
   // Throws IOException during DocumentsWriter.writeSegment
   private static class FailOnlyInWriteSegment extends MockRAMDirectory.Failure {
+    private boolean onlyOnce;
+    public FailOnlyInWriteSegment(boolean onlyOnce) {
+      this.onlyOnce = true;
+    }
     public void eval(MockRAMDirectory dir)  throws IOException {
       if (doFail) {
         StackTraceElement[] trace = new Exception().getStackTrace();
         for (int i = 0; i < trace.length; i++) {
-          if ("writeSegment".equals(trace[i].getMethodName()))
+          if ("writeSegment".equals(trace[i].getMethodName())) {
+            if (onlyOnce)
+              doFail = false;
+            // new RuntimeException().printStackTrace(System.out);
             throw new IOException("now failing on purpose");
+          }
         }
       }
     }
   }
+
   // LUCENE-1130: test IOException in writeSegment
   public void testIOExceptionDuringWriteSegment() throws IOException {
-    _testSingleThreadFailure(new FailOnlyInWriteSegment());
+    _testSingleThreadFailure(new FailOnlyInWriteSegment(false));
+  }
+
+  // LUCENE-1130: test IOException in writeSegment
+  public void testIOExceptionDuringWriteSegmentOnlyOnce() throws IOException {
+    _testSingleThreadFailure(new FailOnlyInWriteSegment(true));
   }
 
   // LUCENE-1130: test IOException in writeSegment, with threads
   public void testIOExceptionDuringWriteSegmentWithThreads() throws IOException {
-    _testMultipleThreadsFailure(new FailOnlyInWriteSegment());
+    _testMultipleThreadsFailure(new FailOnlyInWriteSegment(false));
+  }
+
+  // LUCENE-1130: test IOException in writeSegment, with threads
+  public void testIOExceptionDuringWriteSegmentWithThreadsOnlyOnce() throws IOException {
+    _testMultipleThreadsFailure(new FailOnlyInWriteSegment(true));
   }
 }



Mime
View raw message