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

[test] Fix IndexShardTests#testScheduledRefresh #110312

Merged
merged 13 commits into from
Jul 16, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -3849,7 +3849,6 @@ public void testIsSearchIdle() throws Exception {
closeShards(primary);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/101008")
@TestIssueLogging(
issueUrl = "https://github.com/elastic/elasticsearch/issues/101008",
value = "org.elasticsearch.index.shard.IndexShard:TRACE"
Expand Down Expand Up @@ -3925,11 +3924,16 @@ public void testScheduledRefresh() throws Exception {
logger.info("--> ensure search idle");
assertTrue(primary.isSearchIdle());
assertTrue(primary.searchIdleTime() >= TimeValue.ZERO.millis());
long periodicFlushesBefore = primary.flushStats().getPeriodic();
Copy link
Contributor

Choose a reason for hiding this comment

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

Also can you change the comment above
while shard is search active and ensure scheduleRefresh(...) makes documen visible:
?
because the shard was search idle and that's why scheduled refresh is false there.

primary.flushOnIdle(0);
assertBusy(() -> assertThat(primary.flushStats().getPeriodic(), greaterThan(periodicFlushesBefore)));

long externalRefreshesBefore = primary.refreshStats().getExternalTotal();
logger.info("--> scheduledRefresh(future5)");
kingherc marked this conversation as resolved.
Show resolved Hide resolved
PlainActionFuture<Boolean> future5 = new PlainActionFuture<>();
primary.scheduledRefresh(future5);
assertTrue(future5.actionGet()); // make sure we refresh once the shard is inactive
primary.scheduledRefresh(ActionListener.noop());
// We can't check whether scheduledRefresh returns true because it races with a potential
Copy link
Contributor

Choose a reason for hiding this comment

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

Since @fcofdez approved, I am also fine with the current state and we see if in the future there's any issues with any other concurrent refreshes going on.

I believe this comment may not be up to date now. Since above we assertBusy that the flush has happened, probably the scheduled refresh here will also be true. I'd just remove the comment to avoid confusion.

// refresh triggered by the flush. We just check that one the refreshes ultimately wins.
kingherc marked this conversation as resolved.
Show resolved Hide resolved
assertBusy(() -> assertThat(primary.refreshStats().getExternalTotal(), equalTo(externalRefreshesBefore + 1)));
try (Engine.Searcher searcher = primary.acquireSearcher("test")) {
assertEquals(3, searcher.getIndexReader().numDocs());
}
Expand Down
Loading