lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1039743 - in /lucene/java/branches/lucene_3_0: CHANGES.txt src/java/org/apache/lucene/index/IndexWriter.java src/java/org/apache/lucene/index/SegmentInfos.java
Date Sat, 27 Nov 2010 19:59:56 GMT
Author: mikemccand
Date: Sat Nov 27 19:59:56 2010
New Revision: 1039743

URL: http://svn.apache.org/viewvc?rev=1039743&view=rev
Log:
LUCENE-2782: fix rare thread hazard with IW.commit

Modified:
    lucene/java/branches/lucene_3_0/CHANGES.txt
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SegmentInfos.java

Modified: lucene/java/branches/lucene_3_0/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/CHANGES.txt?rev=1039743&r1=1039742&r2=1039743&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/CHANGES.txt (original)
+++ lucene/java/branches/lucene_3_0/CHANGES.txt Sat Nov 27 19:59:56 2010
@@ -115,6 +115,9 @@ Bug fixes
 * LUCENE-2216: OpenBitSet.hashCode returned different hash codes for
   sets that only differed by trailing zeros. (Dawid Weiss, yonik)
 
+* LUCENE-2782: Fix rare potential thread hazard with
+  IndexWriter.commit (Mike McCandless)
+
 API Changes
 
 * LUCENE-2773: LogMergePolicy accepts a double noCFSRatio (default =

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java?rev=1039743&r1=1039742&r2=1039743&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/IndexWriter.java Sat
Nov 27 19:59:56 2010
@@ -4716,6 +4716,7 @@ public class IndexWriter implements Clos
         try {
 
           assert lastCommitChangeCount <= changeCount;
+          myChangeCount = changeCount;
 
           if (changeCount == lastCommitChangeCount) {
             if (infoStream != null)
@@ -4735,13 +4736,29 @@ public class IndexWriter implements Clos
         
           readerPool.commit();
         
+          // It's possible another flush (that did not close
+          // the open do stores) snuck in after the flush we
+          // just did, so we remove any tail segments
+          // referencing the open doc store from the
+          // SegmentInfos we are about to sync (the main
+          // SegmentInfos will keep them):
           toSync = (SegmentInfos) segmentInfos.clone();
-        
+          final String dss = docWriter.getDocStoreSegment();
+          if (dss != null) {
+            while(true) {
+              final String dss2 = toSync.info(toSync.size()-1).getDocStoreSegment();
+              if (dss2 == null || !dss2.equals(dss)) {
+                break;
+              }
+              toSync.remove(toSync.size()-1);
+              changeCount++;
+            }
+          }
+
           if (commitUserData != null)
             toSync.setUserData(commitUserData);
         
           deleter.incRef(toSync, false);
-          myChangeCount = changeCount;
         
           Collection<String> files = toSync.files(directory, false);
           for(final String fileName: files) {

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SegmentInfos.java?rev=1039743&r1=1039742&r2=1039743&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/index/SegmentInfos.java Sat
Nov 27 19:59:56 2010
@@ -675,9 +675,7 @@ public final class SegmentInfos extends 
 
         try {
           Object v = doBody(segmentFileName);
-          if (exc != null) {
-            message("success on " + segmentFileName);
-          }
+          message("success on " + segmentFileName);
           return v;
         } catch (IOException err) {
 



Mime
View raw message