lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1394314 - in /lucene/dev/trunk: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/index/ lucene/core/src/java/org/apache/lucene/store/ lucene/core/src/test/org/apache/lucene/index/
Date Thu, 04 Oct 2012 22:50:35 GMT
Author: rmuir
Date: Thu Oct  4 22:50:34 2012
New Revision: 1394314

URL: http://svn.apache.org/viewvc?rev=1394314&view=rev
Log:
LUCENE-4456: more fixes that are only exposed by additional random sleeps

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/core/   (props changed)
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java

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=1394314&r1=1394313&r2=1394314&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 Thu
Oct  4 22:50:34 2012
@@ -492,6 +492,7 @@ final class DocumentsWriter {
       throws IOException {
     assert newSegment != null;
     assert newSegment.segmentInfo != null;
+    //System.out.println("FLUSH: " + newSegment.segmentInfo.info.name);
     final SegmentInfoPerCommit segInfo = indexWriter.prepareFlushedSegment(newSegment);
     final BufferedDeletes deletes = newSegment.segmentDeletes;
     if (infoStream.isEnabled("DW")) {

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java?rev=1394314&r1=1394313&r2=1394314&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java Thu Oct
 4 22:50:34 2012
@@ -3211,14 +3211,17 @@ public class IndexWriter implements Clos
       deleter.deleteNewFiles(merge.info.files());
     }
 
+    // Must note the change to segmentInfos so any commits
+    // in-flight don't lose it (IFD will incRef/protect the
+    // new files we created):
+    checkpoint();
+
     // Must close before checkpoint, otherwise IFD won't be
     // able to delete the held-open files from the merge
     // readers:
     closeMergeReaders(merge, false);
 
-    // Must note the change to segmentInfos so any commits
-    // in-flight don't lose it:
-    checkpoint();
+    deleter.deletePendingFiles();
 
     if (infoStream.isEnabled("IW")) {
       infoStream.message("IW", "after commitMerge: " + segString());
@@ -3282,6 +3285,9 @@ public class IndexWriter implements Clos
       try {
         try {
           mergeInit(merge);
+          //if (merge.info != null) {
+          //System.out.println("MERGE: " + merge.info.info.name);
+          //}
 
           if (infoStream.isEnabled("IW")) {
             infoStream.message("IW", "now merge\n  merge=" + segString(merge.segments) +
"\n  index=" + segString());
@@ -3672,7 +3678,18 @@ public class IndexWriter implements Clos
       merge.checkAborted(directory);
 
       // This is where all the work happens:
-      MergeState mergeState = merger.merge();
+      MergeState mergeState;
+      boolean success3 = false;
+      try {
+        mergeState = merger.merge();
+        success3 = true;
+      } finally {
+        if (!success3) {
+          synchronized(this) {  
+            deleter.refresh(merge.info.info.name);
+          }
+        }
+      }
       assert mergeState.segmentInfo == merge.info.info;
       merge.info.info.setFiles(new HashSet<String>(dirWrapper.getCreatedFiles()));
 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java?rev=1394314&r1=1394313&r2=1394314&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java Thu Oct
 4 22:50:34 2012
@@ -733,25 +733,19 @@ public final class SegmentInfos implemen
 
   final void rollbackCommit(Directory dir) {
     if (pendingSegnOutput != null) {
-      try {
-        pendingSegnOutput.close();
-      } catch (Throwable t) {
-        // Suppress so we keep throwing the original exception
-        // in our caller
-      }
+      // Suppress so we keep throwing the original exception
+      // in our caller
+      IOUtils.closeWhileHandlingException(pendingSegnOutput);
+      pendingSegnOutput = null;
 
       // Must carefully compute fileName from "generation"
       // since lastGeneration isn't incremented:
-      try {
-        final String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
-                                                                              "",
-                                                                             generation);
-        dir.deleteFile(segmentFileName);
-      } catch (Throwable t) {
-        // Suppress so we keep throwing the original exception
-        // in our caller
-      }
-      pendingSegnOutput = null;
+      final String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
+                                                                            "",
+                                                                           generation);
+      // Suppress so we keep throwing the original exception
+      // in our caller
+      IOUtils.deleteFilesIgnoringExceptions(dir, segmentFileName);
     }
   }
 
@@ -813,8 +807,19 @@ public final class SegmentInfos implemen
         IOUtils.closeWhileHandlingException(pendingSegnOutput);
         rollbackCommit(dir);
       } else {
-        pendingSegnOutput.close();
-        pendingSegnOutput = null;
+        success = false;
+        try {
+          pendingSegnOutput.close();
+          success = true;
+        } finally {
+          if (!success) {
+            final String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
+                                                                                 "",
+                                                                                 generation);
+            IOUtils.deleteFilesIgnoringExceptions(dir, segmentFileName);
+          }
+          pendingSegnOutput = null;
+        }
       }
     }
 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java?rev=1394314&r1=1394313&r2=1394314&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java
Thu Oct  4 22:50:34 2012
@@ -340,7 +340,7 @@ final class StandardDirectoryReader exte
       try {
         r.decRef();
       } catch (Throwable t) {
-        if (t == null) firstExc = t;
+        if (firstExc == null) firstExc = t;
       }
     }
 

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java?rev=1394314&r1=1394313&r2=1394314&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
(original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java
Thu Oct  4 22:50:34 2012
@@ -129,6 +129,8 @@ final class CompoundFileWriter implement
     }
     IOException priorException = null;
     IndexOutput entryTableOut = null;
+    // TODO this code should clean up after itself
+    // (remove partial .cfs/.cfe)
     try {
       if (!pendingEntries.isEmpty() || outputTaken.get()) {
         throw new IllegalStateException("CFS has pending open files");
@@ -137,8 +139,6 @@ final class CompoundFileWriter implement
       // open the compound stream
       getOutput();
       assert dataOut != null;
-      long finalLength = dataOut.getFilePointer();
-      assert assertFileLength(finalLength, dataOut);
     } catch (IOException e) {
       priorException = e;
     } finally {
@@ -154,14 +154,6 @@ final class CompoundFileWriter implement
     }
   }
 
-  private static boolean assertFileLength(long expected, IndexOutput out)
-      throws IOException {
-    out.flush();
-    assert expected == out.length() : "expected: " + expected + " was "
-        + out.length();
-    return true;
-  }
-
   private final void ensureOpen() {
     if (closed) {
       throw new AlreadyClosedException("CFS Directory is already closed");

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1394314&r1=1394313&r2=1394314&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Thu
Oct  4 22:50:34 2012
@@ -1039,7 +1039,7 @@ public class TestIndexWriter extends Luc
             allowInterrupt = true;
           }
         } catch (ThreadInterruptedException re) {
-          if (VERBOSE) {
+          if (true || VERBOSE) {
             System.out.println("TEST: got interrupt");
             re.printStackTrace(System.out);
           }



Mime
View raw message