From 95b0aa44da1c715a9b9b4330bd64cab3a73a76c1 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Fri, 15 Apr 2011 08:26:16 +0000 Subject: [PATCH] LUCENE-3031: setFlushPending fails if we concurrently hit a aborting exception git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/realtime_search@1092625 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/index/DocumentsWriterFlushControl.java | 14 ++++++++------ .../java/org/apache/lucene/index/FlushPolicy.java | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java b/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java index 37843d8eae7..3a5c790631e 100644 --- a/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java +++ b/lucene/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java @@ -167,12 +167,14 @@ public final class DocumentsWriterFlushControl { */ public synchronized void setFlushPending(ThreadState perThread) { assert !perThread.flushPending; - assert perThread.perThread.getNumDocsInRAM() > 0; - perThread.flushPending = true; // write access synced - final long bytes = perThread.perThreadBytes; - flushBytes += bytes; - activeBytes -= bytes; - numPending++; // write access synced + if (perThread.perThread.getNumDocsInRAM() > 0) { + perThread.flushPending = true; // write access synced + final long bytes = perThread.perThreadBytes; + flushBytes += bytes; + activeBytes -= bytes; + numPending++; // write access synced + } // don't assert on numDocs since we could hit an abort excp. while selecting that dwpt for flushing + } synchronized void doOnAbort(ThreadState state) { diff --git a/lucene/src/java/org/apache/lucene/index/FlushPolicy.java b/lucene/src/java/org/apache/lucene/index/FlushPolicy.java index b4b375e31e9..0997eca4ebe 100644 --- a/lucene/src/java/org/apache/lucene/index/FlushPolicy.java +++ b/lucene/src/java/org/apache/lucene/index/FlushPolicy.java @@ -132,7 +132,6 @@ public abstract class FlushPolicy { } } } - assert maxRamUsingThreadState.perThread.getNumDocsInRAM() > 0; assert writer.get().message( "set largest ram consuming thread pending on lower watermark"); return maxRamUsingThreadState;