Skip to content
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

Fix Flaky - testForceMergeWithSoftDeletesRetentionAndRecoverySource #5364 #11494

Closed
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 @@ -1822,8 +1822,8 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc
)
) {
int numDocs = scaledRandomIntBetween(10, 100);
boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the useRecoverySource flag out of the for loop makes every document has same flag, the randomness is lost, I think we need to keep the randomness in order to cover different cases.

for (int i = 0; i < numDocs; i++) {
boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime;
ParsedDocument doc = testParsedDocument(Integer.toString(i), null, testDocument(), B_1, null, useRecoverySource);
engine.index(indexForDoc(doc));
liveDocs.add(doc.id());
Expand All @@ -1832,14 +1832,14 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc
}
}
for (int i = 0; i < numDocs; i++) {
boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime;
ParsedDocument doc = testParsedDocument(Integer.toString(i), null, testDocument(), B_1, null, useRecoverySource);
if (randomBoolean()) {
boolean isDeleted = randomBoolean();
if (isDeleted) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that if isDeleted is true, for each document, we delete it firstly, and then add them back? If so the randomness is also lost.

engine.delete(new Engine.Delete(doc.id(), newUid(doc.id()), primaryTerm.get()));
liveDocs.remove(doc.id());
liveDocsWithSource.remove(doc.id());
}
if (randomBoolean()) {
if (isDeleted) {
engine.index(indexForDoc(doc));
liveDocs.add(doc.id());
if (useRecoverySource == false) {
Expand All @@ -1848,9 +1848,8 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc
liveDocsWithSource.remove(doc.id());
}
}
if (randomBoolean()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the if condition?

engine.flush(randomBoolean(), true);
}
engine.flush(randomBoolean(), true);

}
engine.flush();
globalCheckpoint.set(randomLongBetween(0, engine.getPersistedLocalCheckpoint()));
Expand Down Expand Up @@ -1896,7 +1895,6 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc
numSegments = searcher.getDirectoryReader().leaves().size();
}
if (numSegments == 1) {
boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If numSegments = 1, we add a new document here, so the flag should be generated randomly.

ParsedDocument doc = testParsedDocument("dummy", null, testDocument(), B_1, null, useRecoverySource);
engine.index(indexForDoc(doc));
if (useRecoverySource == false) {
Expand Down
Loading