Skip to content

Commit b1c1770

Browse files
authored
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)
1 parent 32e97a6 commit b1c1770

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lucene/core/src/java/org/apache/lucene/index/IndexWriter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ final void writeSomeDocValuesUpdates() throws IOException {
872872
count,
873873
readerPool.ramBytesUsed() / 1024. / 1024.,
874874
ramBufferSizeMB,
875-
((System.nanoTime() - startNS) / (double) TimeUnit.SECONDS.toNanos(1))));
875+
(System.nanoTime() - startNS) / (double) TimeUnit.SECONDS.toNanos(1)));
876876
}
877877
}
878878
}
@@ -2697,6 +2697,7 @@ public long deleteAll() throws IOException {
26972697
* you lose a lot of work that must later be redone.
26982698
*/
26992699
private synchronized void abortMerges() throws IOException {
2700+
long startNS = System.nanoTime();
27002701
merges.disable();
27012702
// Abort all pending & running merges:
27022703
IOUtils.applyToAll(
@@ -2739,7 +2740,10 @@ private synchronized void abortMerges() throws IOException {
27392740

27402741
notifyAll();
27412742
if (infoStream.isEnabled("IW")) {
2742-
infoStream.message("IW", "all running merges have aborted");
2743+
double elapsedSec = (System.nanoTime() - startNS) / (double) TimeUnit.SECONDS.toNanos(1);
2744+
infoStream.message(
2745+
"IW",
2746+
String.format(Locale.ROOT, "all running merges have aborted [%.3f seconds]", elapsedSec));
27432747
}
27442748
}
27452749

@@ -3730,7 +3734,7 @@ private long prepareCommitInternal() throws IOException {
37303734
maybeCloseOnTragicEvent();
37313735
}
37323736

3733-
if (pointInTimeMerges != null) {
3737+
if (pointInTimeMerges != null && pointInTimeMerges.merges.size() != 0) {
37343738
if (infoStream.isEnabled("IW")) {
37353739
infoStream.message(
37363740
"IW", "now run merges during commit: " + pointInTimeMerges.segString(directory));

0 commit comments

Comments
 (0)