dweiss opened a new issue, #17036: URL: https://github.com/apache/lucene/issues/17036
### Description `TestSimpleTextTermVectorsFormat.testMergeWithIndexSortAndDeletes` hit the 2-hour suite timeout in a nightly run: https://jenkins.thetaphi.de/job/Lucene-nightly-main-Linux/2258/ This is not a slow test. `IndexWriter.forceMerge(1)` never returns: the index is down to a single segment and `MockRandomMergePolicy.findForcedMerges` keeps selecting that one segment for a merge with itself. Locally I saw over 1,200 such single-segment merges in three minutes. It reproduces on `main` (596ef11ddf9): ``` ./gradlew :lucene:codecs:test --tests "org.apache.lucene.codecs.simpletext.TestSimpleTextTermVectorsFormat.testMergeWithIndexSortAndDeletes" -Ptests.nightly=true -Ptests.multiplier=3 -Ptests.seed=1606E3560E62C9C1 ``` ### Cause `MergePolicy.isMerged` decides whether a single segment still needs merging: ```java return delCount == 0 && info.info.getCodec().compoundFormat().useCompoundFile(size(info, mergeContext), this) == info.info.getUseCompoundFile(); ``` `IndexWriter` asks the same question (`CompoundFormat.useCompoundFile(size, mergePolicy)`) when it packages a merged segment, but the size it passes is measured *before* the compound file is written. `isMerged` measures the segment *after* packing. The two sizes differ, and if the configured `maxCFSSegmentSize` falls between them the answers disagree forever: 1. The merged segment is at or below `maxCFSSegmentSize`, so it is written as a compound file. 2. As a compound file it is slightly larger than `maxCFSSegmentSize`, so `useCompoundFile` now returns `false` while the segment's flag is `true`: `isMerged` returns `false`. 3. The merge policy merges the segment again, with the same outcome. For the seed above, a debug print in `findForcedMerges` shows the same state on every iteration (only the segment name changes): ``` seg=_db size=1116069 cfs=true maxCFS=1115649 dels=0 merged=false seg=_dc size=1116069 cfs=true maxCFS=1115649 dels=0 merged=false ... ``` The packed segment is 420 bytes over the limit. The limit comes from `LuceneTestCaseParent.configureRandom`, which picks `maxCFSSegmentSizeMB` between 0.2 and 2.2 MB. ### Is this a regression? For `MockRandomMergePolicy`, yes: it started with #15295 ("Switching to a fixed CFS threshold", unreleased, 11.0.0). Before that change `MockRandomMergePolicy` overrode `useCompoundFile` to return a random value (`random.nextInt(5) != 1`), so `isMerged` was effectively a coin flip for it and a repeated single-segment merge always ended after a few rounds. #15295 removed the override and moved the decision into `CompoundFormat`, which made it a deterministic function of the segment size. The underlying mismatch (size before packing vs. size after packing, compared against `maxCFSSegmentSize`) looks older than that: the previous `MergePolicy.useCompoundFile` compared `size(mergedInfo)` against `maxCFSSegmentSize` in the same two places. `TieredMergePolicy` and `LogMergePolicy` also consult `isMerged` for a single remaining segment in `findForcedMerges`, so they may be affected when `maxCFSSegmentSizeMB` is set and a segment lands in that narrow window. I have not tried to reproduce it with those policies. ### Possible fixes - Make `isMerged` not depend on a size that changes when the segment is packed (for example, do not treat a compound-file mismatch caused only by the size limit as "not merged"). - Or record the decision made at merge time so that `isMerged` does not recompute it from a different size. ### Version and environment details `main` at 596ef11ddf9. The Jenkins run used JDK 28-ea; locally it reproduces with JDK 25.0.3 on Linux. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
