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.
This commit is contained in:
Nhat Nguyen 2018-09-07 12:58:00 -04:00 committed by GitHub
parent e42cc5cd8c
commit ab7e696108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -1521,6 +1521,16 @@ public class InternalEngineTests extends EngineTestCase {
settings.put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING.getKey(), 0);
indexSettings.updateIndexMetaData(IndexMetaData.builder(defaultSettings.getIndexMetaData()).settings(settings).build());
engine.onSettingsChanged();
// If the global checkpoint equals to the local checkpoint, the next force-merge will be a noop
// because all deleted documents are expunged in the previous force-merge already. We need to flush
// a new segment to make merge happen so that we can verify that all _recovery_source are pruned.
if (globalCheckpoint.get() == engine.getLocalCheckpoint() && liveDocs.isEmpty() == false) {
String deleteId = randomFrom(liveDocs);
engine.delete(new Engine.Delete("test", deleteId, newUid(deleteId), primaryTerm.get()));
liveDocsWithSource.remove(deleteId);
liveDocs.remove(deleteId);
engine.flush();
}
globalCheckpoint.set(engine.getLocalCheckpoint());
engine.syncTranslog();
engine.forceMerge(true, 1, false, false, false);