Skip to content

Commit 4787055

Browse files
committed
TEST: Ensure merge triggered in _source retention test (#33487)
We invoke force merge twice in the test to verify that recovery sources are pruned when the global checkpoint advanced. However, if the global checkpoint equals to the local checkpoint in the first force-merge, the second force-merge will be a noop because all deleted docs are expunged in the first merge already. We need to flush a new segment to make merge happen so we can verify that all recovery sources are pruned.
1 parent eb70fd6 commit 4787055

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,16 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc
15221522
settings.put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING.getKey(), 0);
15231523
indexSettings.updateIndexMetaData(IndexMetaData.builder(defaultSettings.getIndexMetaData()).settings(settings).build());
15241524
engine.onSettingsChanged();
1525+
// If the global checkpoint equals to the local checkpoint, the next force-merge will be a noop
1526+
// because all deleted documents are expunged in the previous force-merge already. We need to flush
1527+
// a new segment to make merge happen so that we can verify that all _recovery_source are pruned.
1528+
if (globalCheckpoint.get() == engine.getLocalCheckpoint() && liveDocs.isEmpty() == false) {
1529+
String deleteId = randomFrom(liveDocs);
1530+
engine.delete(new Engine.Delete("test", deleteId, newUid(deleteId), primaryTerm.get()));
1531+
liveDocsWithSource.remove(deleteId);
1532+
liveDocs.remove(deleteId);
1533+
engine.flush();
1534+
}
15251535
globalCheckpoint.set(engine.getLocalCheckpoint());
15261536
engine.syncTranslog();
15271537
engine.forceMerge(true, 1, false, false, false);

0 commit comments

Comments
 (0)