diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.java index 321daa0aa2b..613d47058f5 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java @@ -2895,10 +2895,6 @@ public class IndexWriter implements Closeable { final synchronized void mergeInit(MergePolicy.OneMerge merge) throws IOException { boolean success = false; try { - // Lock order: IW -> BD - if (bufferedDeletes.applyDeletes(readerPool, segmentInfos, merge.segments)) { - checkpoint(); - } _mergeInit(merge); success = true; } finally { @@ -2929,6 +2925,11 @@ public class IndexWriter implements Closeable { if (merge.isAborted()) return; + // Lock order: IW -> BD + if (bufferedDeletes.applyDeletes(readerPool, segmentInfos, merge.segments)) { + checkpoint(); + } + // Bind a new segment name here so even with // ConcurrentMergePolicy we keep deterministic segment // names.