From c9c0121d9399ff0009c51d6a32632dd0962e8c8f Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Thu, 29 Jun 2017 05:52:19 -0400 Subject: [PATCH] LUCENE-7887: don't clear BufferedUpdatesStream on abort --- .../java/org/apache/lucene/index/BufferedUpdatesStream.java | 3 +++ .../java/org/apache/lucene/index/FrozenBufferedUpdates.java | 6 +----- .../core/src/java/org/apache/lucene/index/IndexWriter.java | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java index 8c0a2bea48c..07d2b66d7ea 100644 --- a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java +++ b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdatesStream.java @@ -175,11 +175,14 @@ class BufferedUpdatesStream implements Accountable { // TODO: would be a bit more memory efficient to track this per-segment, so when each segment writes it writes all packets finished for // it, rather than only recording here, across all segments. But, more complex code, and more CPU, and maybe not so much impact in // practice? + assert packet.applied.getCount() == 1: "packet=" + packet; packet.applied.countDown(); updates.remove(packet); numTerms.addAndGet(-packet.numTermDeletes); + assert numTerms.get() >= 0: "numTerms=" + numTerms + " packet=" + packet; + bytesUsed.addAndGet(-packet.bytesUsed); finishedSegment(packet.delGen()); diff --git a/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java b/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java index d5d1de08afa..82488416c38 100644 --- a/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java +++ b/lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java @@ -299,7 +299,6 @@ class FrozenBufferedUpdates { if (infoStream.isEnabled("BD")) { infoStream.message("BD", "packet matches no segments"); } - break; } @@ -422,10 +421,7 @@ class FrozenBufferedUpdates { throw new IllegalArgumentException("gen is not yet set; call BufferedUpdatesStream.push first"); } - if (applied.getCount() == 0) { - // already done - return totalDelCount; - } + assert applied.getCount() != 0; if (privateSegment != null) { assert segStates.length == 1; diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index 487028227af..2ef928bb8a7 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -2364,8 +2364,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { // set it to false before calling rollbackInternal mergeScheduler.close(); - bufferedUpdatesStream.clear(); - docWriter.close(); // mark it as closed first to prevent subsequent indexing actions/flushes docWriter.abort(this); // don't sync on IW here synchronized(this) {