Skip to content

Commit fd25d3b

Browse files
Fix SO-Error in SearchWithRandomDisconnectsIT (#122593)
Obvious SO exception possibilitiy if we encounter exceptions back to back in the callback. Use promise style pattern instead of callback in the individual loops to limit stack-depth (this should be good enough for a fix, technically you could still run into very deep stacks if the search completes between the `isDone` check and adding the listener back-to-back a couple times but practically this should be good enough since all the instant-done situations are from the search fully failing outright. closes #116175
1 parent 95f8454 commit fd25d3b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ tests:
7272
- class: org.elasticsearch.action.search.SearchPhaseControllerTests
7373
method: testProgressListener
7474
issue: https://github.com/elastic/elasticsearch/issues/116149
75-
- class: org.elasticsearch.search.basic.SearchWithRandomDisconnectsIT
76-
method: testSearchWithRandomDisconnects
77-
issue: https://github.com/elastic/elasticsearch/issues/116175
7875
- class: org.elasticsearch.xpack.deprecation.DeprecationHttpIT
7976
method: testDeprecatedSettingsReturnWarnings
8077
issue: https://github.com/elastic/elasticsearch/issues/108628

server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWithRandomDisconnectsIT.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.action.search.SearchResponse;
1515
import org.elasticsearch.action.support.PlainActionFuture;
1616
import org.elasticsearch.common.settings.Settings;
17+
import org.elasticsearch.common.util.concurrent.ListenableFuture;
1718
import org.elasticsearch.discovery.AbstractDisruptionTestCase;
1819
import org.elasticsearch.index.IndexModule;
1920
import org.elasticsearch.index.IndexSettings;
@@ -67,11 +68,15 @@ public void onFailure(Exception e) {
6768
}
6869

6970
private void runMoreSearches() {
70-
if (done.get() == false) {
71-
prepareRandomSearch().execute(this);
72-
} else {
73-
finishFuture.onResponse(null);
71+
while (done.get() == false) {
72+
final ListenableFuture<SearchResponse> f = new ListenableFuture<>();
73+
prepareRandomSearch().execute(f);
74+
if (f.isDone() == false) {
75+
f.addListener(this);
76+
return;
77+
}
7478
}
79+
finishFuture.onResponse(null);
7580
}
7681
});
7782
}

0 commit comments

Comments
 (0)