From a864ef823167380eb1e2724b453c7730b93f5bbe Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 10 Jul 2018 08:50:59 +0200 Subject: [PATCH] LUCENE-8394: Explicitly handle the case when segments are smaller than the floor size. --- .../src/java/org/apache/lucene/index/TieredMergePolicy.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java index 499273daa5f..7f917bba46b 100644 --- a/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java +++ b/lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java @@ -410,6 +410,9 @@ public class TieredMergePolicy extends MergePolicy { bytesLeft -= segsPerTier * levelSize; levelSize = Math.min(maxMergedSegmentBytes, levelSize * mergeFactor); } + // allowedSegCount may occasionally be less than segsPerTier + // if segment sizes are below the floor size + allowedSegCount = Math.max(allowedSegCount, segsPerTier); if (verbose(mergeContext) && tooBigCount > 0) { message(" allowedSegmentCount=" + allowedSegCount + " vs count=" + infos.size() +