Skip to content
Merged
Show file tree
Hide file tree
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 @@ -133,9 +133,7 @@ public void tearDown() throws Exception {
ensureNoInitializingShards();
ensureAllFreeContextActionsAreConsumed();

SearchService searchService = getInstanceFromNode(SearchService.class);
assertThat(searchService.getActiveContexts(), equalTo(0));
assertThat(searchService.getOpenScrollContexts(), equalTo(0));
ensureAllContextsReleased(getInstanceFromNode(SearchService.class));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know people argued this would increase test runtimes, but not really in my opinion. This is failing at a low rate and we only really add a delay to those tests where the assertions fails, so not a big deal IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW I was one of those people, and I still don't like this change. Fire-and-forget actions on the GENERIC pool is a bad code smell IMO, it's going to cause us problems at scale at some point. I'm not going to ask for rework here, just recording that opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The scale problem started worrying me as well, opened #111156 right after :D

super.tearDown();
var deleteDataStreamsRequest = new DeleteDataStreamAction.Request("*");
deleteDataStreamsRequest.indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.MockSearchService;
import org.elasticsearch.search.SearchService;
import org.elasticsearch.test.junit.listeners.LoggingListener;
import org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter;
import org.elasticsearch.threadpool.ExecutorBuilder;
Expand Down Expand Up @@ -208,6 +209,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;

/**
* Base testcase for randomized unit testing with Elasticsearch
Expand Down Expand Up @@ -2515,4 +2517,15 @@ public static void runInParallel(int numberOfTasks, IntConsumer taskFactory) thr
throw new AssertionError(e);
}
}

public static void ensureAllContextsReleased(SearchService searchService) {
try {
assertBusy(() -> {
assertThat(searchService.getActiveContexts(), equalTo(0));
assertThat(searchService.getOpenScrollContexts(), equalTo(0));
});
} catch (Exception e) {
throw new AssertionError("Failed to verify search contexts", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2545,15 +2545,7 @@ public void assertRequestsFinished() {

private void assertSearchContextsReleased() {
for (NodeAndClient nodeAndClient : nodes.values()) {
SearchService searchService = getInstance(SearchService.class, nodeAndClient.name);
try {
assertBusy(() -> {
assertThat(searchService.getActiveContexts(), equalTo(0));
assertThat(searchService.getOpenScrollContexts(), equalTo(0));
});
} catch (Exception e) {
throw new AssertionError("Failed to verify search contexts", e);
}
ESTestCase.ensureAllContextsReleased(getInstance(SearchService.class, nodeAndClient.name));
}
}

Expand Down