Skip to content

Commit 8ba37ed

Browse files
committed
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 89b6537 commit 8ba37ed

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
@@ -5131,6 +5131,9 @@ public void testShouldPeriodicallyFlush() throws Exception {
51315131
}
51325132

51335133
public void testShouldPeriodicallyFlushAfterMerge() throws Exception {
5134+
engine.close();
5135+
// Do not use MockRandomMergePolicy as it can cause a force merge performing two merges.
5136+
engine = createEngine(copy(engine.config(), newMergePolicy(random(), false)));
51345137
assertThat("Empty engine does not need flushing", engine.shouldPeriodicallyFlush(), equalTo(false));
51355138
ParsedDocument doc =
51365139
testParsedDocument(Integer.toString(0), null, testDocumentWithTextField(), SOURCE, null);

0 commit comments

Comments
 (0)