Skip to content

Fix testForceMergeWithSoftDeletesRetentionAndRecoverySource #48766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1715,18 +1715,26 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc
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.getPersistedLocalCheckpoint() && liveDocs.isEmpty() == false) {
String deleteId = randomFrom(liveDocs);
engine.delete(new Engine.Delete(deleteId, newUid(deleteId), primaryTerm.get()));
liveDocsWithSource.remove(deleteId);
liveDocs.remove(deleteId);
engine.flush();
// If we already merged down to 1 segment, then the next force-merge will be a noop. We need to add an extra segment to make
// merges happen so we can verify that _recovery_source are pruned. See: https://github.com/elastic/elasticsearch/issues/41628.
final int numSegments;
try (Engine.Searcher searcher = engine.acquireSearcher("test", Engine.SearcherScope.INTERNAL)) {
numSegments = searcher.getDirectoryReader().leaves().size();
}
if (numSegments == 1) {
boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime;
ParsedDocument doc = testParsedDocument("dummy", null, testDocument(), B_1, null, useRecoverySource);
engine.index(indexForDoc(doc));
if (useRecoverySource == false) {
liveDocsWithSource.add(doc.id());
}
engine.syncTranslog();
globalCheckpoint.set(engine.getPersistedLocalCheckpoint());
engine.flush(randomBoolean(), true);
} else {
globalCheckpoint.set(engine.getPersistedLocalCheckpoint());
engine.syncTranslog();
}
globalCheckpoint.set(engine.getPersistedLocalCheckpoint());
engine.syncTranslog();
engine.forceMerge(true, 1, false, false, false);
assertConsistentHistoryBetweenTranslogAndLuceneIndex(engine, mapperService);
assertThat(readAllOperationsInLucene(engine, mapperService), hasSize(liveDocsWithSource.size()));
Expand Down