Skip to content

Apache Lucene open-source search software

IndexWriter InfoStream improvements: log elapsed seconds waiting for merges to abort; don't log merge-on-commit when there are no merges to run (#15103)

Michael McCandlessb1c1770e8052
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 5c1509af82a..4241bcedf46 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -872,7 +872,7 @@ public class IndexWriter
count,
readerPool.ramBytesUsed() / 1024. / 1024.,
ramBufferSizeMB,
- ((System.nanoTime() - startNS) / (double) TimeUnit.SECONDS.toNanos(1))));
+ (System.nanoTime() - startNS) / (double) TimeUnit.SECONDS.toNanos(1)));
}
}
}
@@ -2697,6 +2697,7 @@ public class IndexWriter
* you lose a lot of work that must later be redone.
*/
private synchronized void abortMerges() throws IOException {
+ long startNS = System.nanoTime();
merges.disable();
// Abort all pending & running merges:
IOUtils.applyToAll(
@@ -2739,7 +2740,10 @@ public class IndexWriter
notifyAll();
if (infoStream.isEnabled("IW")) {
- infoStream.message("IW", "all running merges have aborted");
+ double elapsedSec = (System.nanoTime() - startNS) / (double) TimeUnit.SECONDS.toNanos(1);
+ infoStream.message(
+ "IW",
+ String.format(Locale.ROOT, "all running merges have aborted [%.3f seconds]", elapsedSec));
}
}
@@ -3730,7 +3734,7 @@ public class IndexWriter
maybeCloseOnTragicEvent();
}
- if (pointInTimeMerges != null) {
+ if (pointInTimeMerges != null && pointInTimeMerges.merges.size() != 0) {
if (infoStream.isEnabled("IW")) {
infoStream.message(
"IW", "now run merges during commit: " + pointInTimeMerges.segString(directory));