Skip to content

Commit a74ba9c

Browse files
authored
Fix testShouldPeriodicallyFlushAfterMerge (#52243)
MockRandomMergePolicy randomly determines if a segment should use a compound format. This can cause a force merge performing two merges: (1) merging to a single segment, (2) rewriting the new segment using the compound format. If the second merge completes after we have flushed, then it can flip the flag shouldPeriodicallyFlushAfterBigMerge to true. Closes #52205
1 parent 96359c3 commit a74ba9c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -4753,6 +4753,9 @@ public void testShouldPeriodicallyFlush() throws Exception {
47534753
}
47544754

47554755
public void testShouldPeriodicallyFlushAfterMerge() throws Exception {
4756+
engine.close();
4757+
// Do not use MockRandomMergePolicy as it can cause a force merge performing two merges.
4758+
engine = createEngine(copy(engine.config(), newMergePolicy(random(), false)));
47564759
assertThat("Empty engine does not need flushing", engine.shouldPeriodicallyFlush(), equalTo(false));
47574760
ParsedDocument doc =
47584761
testParsedDocument(Integer.toString(0), null, testDocumentWithTextField(), SOURCE, null);

0 commit comments

Comments
 (0)