jpountz commented on code in PR #900: URL: https://github.com/apache/lucene/pull/900#discussion_r875848606
########## lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java: ########## @@ -582,23 +589,29 @@ public MergeSpecification findMerges( if (anyMerging) { // skip } else if (!anyTooLarge) { - if (spec == null) spec = new MergeSpecification(); - final List<SegmentCommitInfo> mergeInfos = new ArrayList<>(end - start); - for (int i = start; i < end; i++) { - mergeInfos.add(levels.get(i).info); - assert infos.contains(levels.get(i).info); - } - if (verbose(mergeContext)) { - message( - " add merge=" - + segString(mergeContext, mergeInfos) - + " start=" - + start - + " end=" - + end, - mergeContext); - } - spec.add(new OneMerge(mergeInfos)); + if (mergeSize >= maxSegmentSize * 1.5) { + // Ignore any merge where the resulting segment is not at least 50% larger than the + // biggest input segment. + // Otherwise we could run into pathological O(N^2) merging where merges keep rewriting + // again and again the biggest input segment into a segment that is barely bigger. + if (spec == null) spec = new MergeSpecification(); Review Comment: It's not spotless, it's just because I didn't touch this line of code, only changed indentation. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org