lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1591616 - in /lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene: codecs/lucene40/Lucene40StoredFieldsWriter.java codecs/lucene40/Lucene40TermVectorsWriter.java index/DefaultIndexingChain.java
Date Thu, 01 May 2014 11:34:44 GMT
Author: mikemccand
Date: Thu May  1 11:34:44 2014
New Revision: 1591616

URL: http://svn.apache.org/r1591616
Log:
LUCENE-5611: always abort if we hit exc in StoredFieldsWriter.start/FinishDocument

Modified:
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java?rev=1591616&r1=1591615&r2=1591616&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
Thu May  1 11:34:44 2014
@@ -224,13 +224,14 @@ public final class Lucene40StoredFieldsW
 
   @Override
   public void finish(FieldInfos fis, int numDocs) {
-    if (HEADER_LENGTH_IDX+((long) numDocs)*8 != indexStream.getFilePointer())
+    long indexFP = indexStream.getFilePointer();
+    if (HEADER_LENGTH_IDX+((long) numDocs)*8 != indexFP)
       // This is most likely a bug in Sun JRE 1.6.0_04/_05;
       // we detect that the bug has struck, here, and
       // throw an exception to prevent the corruption from
       // entering the index.  See LUCENE-1282 for
       // details.
-      throw new RuntimeException("fdx size mismatch: docCount is " + numDocs + " but fdx
file size is " + indexStream.getFilePointer() + " file=" + indexStream.toString() + "; now
aborting this merge to prevent index corruption");
+      throw new RuntimeException("fdx size mismatch: docCount is " + numDocs + " but fdx
file size is " + indexFP + " (wrote numDocs=" + ((indexFP-HEADER_LENGTH_IDX)/8.0) + " file="
+ indexStream.toString() + "; now aborting this merge to prevent index corruption");
   }
   
   @Override

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java?rev=1591616&r1=1591615&r2=1591616&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40TermVectorsWriter.java
Thu May  1 11:34:44 2014
@@ -426,13 +426,14 @@ public final class Lucene40TermVectorsWr
   
   @Override
   public void finish(FieldInfos fis, int numDocs) {
-    if (HEADER_LENGTH_INDEX+((long) numDocs)*16 != tvx.getFilePointer())
+    long indexFP = tvx.getFilePointer();
+    if (HEADER_LENGTH_INDEX+((long) numDocs)*16 != indexFP)
       // This is most likely a bug in Sun JRE 1.6.0_04/_05;
       // we detect that the bug has struck, here, and
       // throw an exception to prevent the corruption from
       // entering the index.  See LUCENE-1282 for
       // details.
-      throw new RuntimeException("tvx size mismatch: mergedDocs is " + numDocs + " but tvx
size is " + tvx.getFilePointer() + " file=" + tvx.toString() + "; now aborting this merge
to prevent index corruption");
+      throw new RuntimeException("tvx size mismatch: mergedDocs is " + numDocs + " but tvx
size is " + indexFP + " (wrote numDocs=" + ((indexFP - HEADER_LENGTH_INDEX)/16.0) + " file="
+ tvx.toString() + "; now aborting this merge to prevent index corruption");
   }
 
   /** Close all streams. */

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java?rev=1591616&r1=1591615&r2=1591616&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java
Thu May  1 11:34:44 2014
@@ -160,9 +160,9 @@ final class DefaultIndexingChain extends
    *  stored fields. */
   private void fillStoredFields(int docID) throws IOException {
     while (lastStoredDocID < docID) {
-      storedFieldsWriter.startDocument();
+      startStoredFields();
       lastStoredDocID++;
-      storedFieldsWriter.finishDocument();
+      finishStoredFields();
     }
   }
 
@@ -242,6 +242,34 @@ final class DefaultIndexingChain extends
     hashMask = newHashMask;
   }
 
+  /** Calls StoredFieldsWriter.startDocument, aborting the
+   *  segment if it hits any exception. */
+  private void startStoredFields() throws IOException {
+    boolean success = false;
+    try {
+      storedFieldsWriter.startDocument();
+      success = true;
+    } finally {
+      if (success == false) {
+        docWriter.setAborting();        
+      }
+    }
+  }
+
+  /** Calls StoredFieldsWriter.finishDocument, aborting the
+   *  segment if it hits any exception. */
+  private void finishStoredFields() throws IOException {
+    boolean success = false;
+    try {
+      storedFieldsWriter.finishDocument();
+      success = true;
+    } finally {
+      if (success == false) {
+        docWriter.setAborting();        
+      }
+    }
+  }
+
   @Override
   public void processDocument() throws IOException {
 
@@ -261,48 +289,24 @@ final class DefaultIndexingChain extends
     termsHash.startDocument();
 
     fillStoredFields(docState.docID);
-    storedFieldsWriter.startDocument();
+    startStoredFields();
     lastStoredDocID++;
 
-    boolean success = false;
     try {
       for (IndexableField field : docState.doc) {
         fieldCount = processField(field, fieldGen, fieldCount);
       }
-
-      boolean success2 = false;
-      try {
-        storedFieldsWriter.finishDocument();
-        success2 = true;
-      } finally {
-        if (!success2) {
-          docWriter.setAborting();
-        }
-      }
-      
-      success = true;
     } finally {
-      if (success == false && !docWriter.aborting) {
-        // Non-aborting exception; we have to call
-        // storedFieldsWriter.finishDocument in this case:
-        boolean success3 = false;
-        try {
-          storedFieldsWriter.finishDocument();
-          success3 = true;
-        } finally {
-          if (!success3) {
-            docWriter.setAborting();
-          }
+      if (docWriter.aborting == false) {
+        // Finish each indexed field name seen in the document:
+        for (int i=0;i<fieldCount;i++) {
+          fields[i].finish();
         }
-      }
-      
-      // Finish each indexed field name seen in the document:
-      for (int i=0;i<fieldCount;i++) {
-        fields[i].finish();
+        finishStoredFields();
       }
     }
 
-    success = false;
+    boolean success = false;
     try {
       termsHash.finishDocument();
       success = true;



Mime
View raw message