Skip to content

Commit

Permalink
Ensure no scheduled refresh in testPendingRefreshWithIntervalChange
Browse files Browse the repository at this point in the history
If a refresh, which is scheduled by the setting change, executes after
the index-2 operation and win the refresh race (i.e., maybeRefresh) with
the scheduledRefresh that we are going to check, then the latter will
return false.

Closes #39565
Relates #39462

PR #40387
  • Loading branch information
dnhatn committed Apr 4, 2019
1 parent 11f2da9 commit e716b9c
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
import org.elasticsearch.test.IndexSettingsModule;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolStats;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -738,8 +740,7 @@ public void onFailure(Exception e) {
t.join();
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/39565")
public void testPendingRefreshWithIntervalChange() throws InterruptedException {
public void testPendingRefreshWithIntervalChange() throws Exception {
Settings.Builder builder = Settings.builder();
builder.put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), TimeValue.ZERO);
IndexService indexService = createIndex("test", builder.build());
Expand Down Expand Up @@ -767,7 +768,14 @@ public void testPendingRefreshWithIntervalChange() throws InterruptedException {
// wait for both to ensure we don't have in-flight operations
updateSettingsLatch.await();
refreshLatch.await();

// ensure no scheduled refresh to compete with the scheduleRefresh we are going to verify.
assertBusy(() -> {
for (ThreadPoolStats.Stats stat : indexService.getThreadPool().stats()) {
if (stat.getName().equals(ThreadPool.Names.REFRESH) && (stat.getQueue() > 0 || stat.getActive() > 0)) {
throw new AssertionError(); // cause assert busy to retry
}
}
});
client().prepareIndex("test", "test", "2").setSource("{\"foo\" : \"bar\"}", XContentType.JSON).get();
assertTrue(shard.scheduledRefresh());
assertTrue(shard.isSearchIdle());
Expand Down

0 comments on commit e716b9c

Please sign in to comment.