lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r1097156 - in /lucene/dev/branches/realtime_search/lucene/src: java/org/apache/lucene/index/ test/org/apache/lucene/index/
Date Wed, 27 Apr 2011 15:47:45 GMT
Author: simonw
Date: Wed Apr 27 15:47:45 2011
New Revision: 1097156

URL: http://svn.apache.org/viewvc?rev=1097156&view=rev
Log:
LUCENE-3023: make sure we don't miss a new initialized DWPT when flushing all DWPT

Modified:
    lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
    lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
    lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java
    lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/ThreadAffinityDocumentsWriterThreadPool.java
    lucene/dev/branches/realtime_search/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java

Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java?rev=1097156&r1=1097155&r2=1097156&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
(original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
Wed Apr 27 15:47:45 2011
@@ -73,14 +73,19 @@ final class DocumentsWriterDeleteQueue {
   /* only acquired to update the global deletes */
   private final ReentrantLock globalBufferLock = new ReentrantLock();
 
-  long generation;
+  final long generation;
   
   DocumentsWriterDeleteQueue() {
-    this(new BufferedDeletes(false));
+    this(0);
+  }
+  
+  DocumentsWriterDeleteQueue(long generation) {
+    this(new BufferedDeletes(false), generation);
   }
 
-  DocumentsWriterDeleteQueue(BufferedDeletes globalBufferedDeletes) {
+  DocumentsWriterDeleteQueue(BufferedDeletes globalBufferedDeletes,long generation) {
     this.globalBufferedDeletes = globalBufferedDeletes;
+    this.generation = generation;
     /*
      * we use a sentinel instance as our initial tail. No slice will ever try to
      * apply this tail since the head is always omitted.

Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java?rev=1097156&r1=1097155&r2=1097156&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
(original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
Wed Apr 27 15:47:45 2011
@@ -303,8 +303,7 @@ public final class DocumentsWriterFlushC
       flushingQueue = documentsWriter.deleteQueue;
       // Set a new delete queue - all subsequent DWPT will use this queue until
       // we do another full flush
-      DocumentsWriterDeleteQueue newQueue = new DocumentsWriterDeleteQueue();
-      newQueue.generation = flushingQueue.generation + 1;
+      DocumentsWriterDeleteQueue newQueue = new DocumentsWriterDeleteQueue(flushingQueue.generation+1);
       documentsWriter.deleteQueue = newQueue;
     }
     final Iterator<ThreadState> allActiveThreads = perThreadPool

Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java?rev=1097156&r1=1097155&r2=1097156&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java
(original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java
Wed Apr 27 15:47:45 2011
@@ -158,19 +158,19 @@ public abstract class DocumentsWriterPer
   /**
    * Returns a new {@link ThreadState} iff any new state is available otherwise
    * <code>null</code>.
+   * <p>
+   * NOTE: the returned {@link ThreadState} is already locked iff non-
+   * <code>null</code>.
    * 
-   * @param lock
-   *          <code>true</code> iff the new {@link ThreadState} should be locked
-   *          before published otherwise <code>false</code>.
    * @return a new {@link ThreadState} iff any new state is available otherwise
    *         <code>null</code>
    */
-  public synchronized ThreadState newThreadState(boolean lock) {
+  public synchronized ThreadState newThreadState() {
     if (numThreadStatesActive < perThreads.length) {
       final ThreadState threadState = perThreads[numThreadStatesActive];
-      threadState.lock();
-      threadState.perThread.initialize();
+      threadState.lock(); // lock so nobody else will get this ThreadState
       numThreadStatesActive++; // increment will publish the ThreadState
+      threadState.perThread.initialize();
       return threadState;
     }
     return null;

Modified: lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/ThreadAffinityDocumentsWriterThreadPool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/ThreadAffinityDocumentsWriterThreadPool.java?rev=1097156&r1=1097155&r2=1097156&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/ThreadAffinityDocumentsWriterThreadPool.java
(original)
+++ lucene/dev/branches/realtime_search/lucene/src/java/org/apache/lucene/index/ThreadAffinityDocumentsWriterThreadPool.java
Wed Apr 27 15:47:45 2011
@@ -54,7 +54,7 @@ public class ThreadAffinityDocumentsWrit
     // Find the state that has minimum number of threads waiting
     minThreadState = minContendedThreadState();
     if (minThreadState == null || minThreadState.hasQueuedThreads()) {
-      final ThreadState newState = newThreadState(true);
+      final ThreadState newState = newThreadState(); // state is already locked if non-null
       if (newState != null) {
         assert newState.isHeldByCurrentThread();
         threadBindings.put(requestingThread, newState);

Modified: lucene/dev/branches/realtime_search/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java?rev=1097156&r1=1097155&r2=1097156&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java
(original)
+++ lucene/dev/branches/realtime_search/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java
Wed Apr 27 15:47:45 2011
@@ -33,8 +33,7 @@ import org.apache.lucene.util.ThreadInte
 public class TestDocumentsWriterDeleteQueue extends LuceneTestCase {
 
   public void testUpdateDelteSlices() {
-    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue(
-        new BufferedDeletes(false));
+    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue();
     final int size = 200 + random.nextInt(500) * RANDOM_MULTIPLIER;
     Integer[] ids = new Integer[size];
     for (int i = 0; i < ids.length; i++) {
@@ -88,8 +87,7 @@ public class TestDocumentsWriterDeleteQu
   }
   
   public void testClear() {
-    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue(
-        new BufferedDeletes(false));
+    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue();
     Term template = new Term("id");
     assertFalse(queue.anyChanges());
     queue.clear();
@@ -117,8 +115,7 @@ public class TestDocumentsWriterDeleteQu
   }
 
   public void testAnyChanges() {
-    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue(
-        new BufferedDeletes(false));
+    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue();
     Term template = new Term("id");
     final int size = 200 + random.nextInt(500) * RANDOM_MULTIPLIER;
     int termsSinceFreeze = 0;
@@ -146,8 +143,7 @@ public class TestDocumentsWriterDeleteQu
   }
 
   public void testStressDeleteQueue() throws InterruptedException {
-    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue(
-        new BufferedDeletes(false));
+    DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue();
     Set<Term> uniqueValues = new HashSet<Term>();
     final int size = 10000 + random.nextInt(500) * RANDOM_MULTIPLIER;
     Integer[] ids = new Integer[size];



Mime
View raw message