Skip to content

Apache Lucene open-source search software

LUCENE-6386: correct javadocs about temp disk space required for forceMerge(1)

Michael McCandless989cf8653391
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 0d8221dc884..0468133a323 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -123,6 +123,10 @@ Bug Fixes
DocumentsWriterStallControl to prevent hangs during indexing if we
miss a .notify/All somewhere (Mike McCandless)
+* LUCENE-6386: Correct IndexWriter.forceMerge documentation to state
+ that up to 3X (X = current index size) spare disk space may be needed
+ to complete forceMerge(1). (Robert Muir, Shai Erera, Mike McCandless)
+
Optimizations
* LUCENE-6183, LUCENE-5647: Avoid recompressing stored fields
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 a64be82aef2..47267682017 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -1547,14 +1547,15 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
* longer be changed).</p>
*
* <p>Note that this requires free space that is proportional
- * to the size of the index in your Directory (2X if you're
- * using compound file format). For example, if your index
- * size is 10 MB then you need an additional 10 MB free for
- * this to complete (20 MB if you're using compound file
- * format). This is also affected by the {@link Codec} that
- * is used to execute the merge, and may result in even a
- * bigger index. Also, it's best to call {@link #commit()}
- * afterwards, to allow IndexWriter to free up disk space.</p>
+ * to the size of the index in your Directory: 2X if you are
+ * not using compound file format, and 3X if you are.
+ * For example, if your index size is 10 MB then you need
+ * an additional 20 MB free for this to complete (30 MB if
+ * you're using compound file format). This is also affected
+ * by the {@link Codec} that is used to execute the merge,
+ * and may result in even a bigger index. Also, it's best
+ * to call {@link #commit()} afterwards, to allow IndexWriter
+ * to free up disk space.</p>
*
* <p>If some but not all readers re-open while merging
* is underway, this will cause {@code > 2X} temporary
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java
index 9c219e4cadd..19030cc00a1 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java
@@ -199,8 +199,8 @@ public class TestIndexWriterForceMerge extends LuceneTestCase {
assertTrue("forceMerge used too much temporary space: starting usage was "
+ startDiskUsage + " bytes; final usage was " + finalDiskUsage
+ " bytes; max temp usage was " + maxDiskUsage
- + " but should have been " + (3 * maxStartFinalDiskUsage)
- + " (= 3X starting usage), BEFORE=" + startListing + "AFTER=" + listFiles(dir), maxDiskUsage <= 3 * maxStartFinalDiskUsage);
+ + " but should have been at most " + (4 * maxStartFinalDiskUsage)
+ + " (= 4X starting usage), BEFORE=" + startListing + "AFTER=" + listFiles(dir), maxDiskUsage <= 4 * maxStartFinalDiskUsage);
dir.close();
}