Skip to content

Apache Lucene open-source search software

SOLR-3141: Warn in logs when expensive optimize calls are made

Jan Høydahlbe807919b632
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d0289a73830..d37ce33a5e8 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -668,6 +668,8 @@ Other Changes
* SOLR-8308: Core gets inaccessible after RENAME operation with special characters
(Erik Hatcher, Erick Erickson)
+* SOLR-3141: Warn in logs when expensive optimize calls are made (yonik, janhoy)
+
================== 5.4.1 ==================
Bug Fixes
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index fe14bd5bbda..6fe4884812d 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -594,8 +594,14 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
try {
IndexWriter writer = iw.get();
if (cmd.optimize) {
+ if (cmd.maxOptimizeSegments == 1) {
+ log.warn("Starting optimize... Reading and rewriting the entire index! Use with care.");
+ } else {
+ log.warn("Starting optimize... Reading and rewriting a potentially large percent of the entire index, reducing to " + cmd.maxOptimizeSegments + " segments");
+ }
writer.forceMerge(cmd.maxOptimizeSegments);
} else if (cmd.expungeDeletes) {
+ log.warn("Starting expungeDeletes... Reading and rewriting segments with enough deletes, potentially the entire index");
writer.forceMergeDeletes();
}