@@ -87,48 +87,53 @@ private EsqlQueryResponse runQueryWithDisruption(EsqlQueryRequest request) {
8787 request .allowPartialResults (randomBoolean ());
8888 }
8989 ActionFuture <EsqlQueryResponse > future = client ().execute (EsqlQueryAction .INSTANCE , request );
90+ EsqlQueryResponse resp = null ;
9091 try {
91- var resp = future .actionGet (2 , TimeUnit .MINUTES );
92+ resp = future .actionGet (2 , TimeUnit .MINUTES );
9293 if (resp .isPartial () == false ) {
9394 return resp ;
9495 }
95- try (resp ) {
96- assertTrue (request .allowPartialResults ());
97- }
9896 } catch (Exception ignored ) {
9997
10098 } finally {
10199 clearDisruption ();
102100 }
103- try {
104- var resp = future .actionGet (2 , TimeUnit .MINUTES );
101+ // wait for the response after clear disruption
102+ if (resp == null ) {
103+ try {
104+ resp = future .actionGet (2 , TimeUnit .MINUTES );
105+ } catch (Exception e ) {
106+ logger .info (
107+ "running tasks: {}" ,
108+ client ().admin ()
109+ .cluster ()
110+ .prepareListTasks ()
111+ .get ()
112+ .getTasks ()
113+ .stream ()
114+ .filter (
115+ // Skip the tasks we that'd get in the way while debugging
116+ t -> false == t .action ().contains (TransportListTasksAction .TYPE .name ())
117+ && false == t .action ().contains (HealthNode .TASK_NAME )
118+ )
119+ .toList ()
120+ );
121+ assertTrue ("request must be failed or completed after clearing disruption" , future .isDone ());
122+ ensureBlocksReleased ();
123+ logger .info ("--> failed to execute esql query with disruption; retrying..." , e );
124+ EsqlTestUtils .assertEsqlFailure (e );
125+ }
126+ }
127+ // use the response if it's not partial
128+ if (resp != null ) {
105129 if (resp .isPartial () == false ) {
106130 return resp ;
107131 }
108- try (resp ) {
132+ try (var ignored = resp ) {
109133 assertTrue (request .allowPartialResults ());
110134 }
111- } catch (Exception e ) {
112- logger .info (
113- "running tasks: {}" ,
114- client ().admin ()
115- .cluster ()
116- .prepareListTasks ()
117- .get ()
118- .getTasks ()
119- .stream ()
120- .filter (
121- // Skip the tasks we that'd get in the way while debugging
122- t -> false == t .action ().contains (TransportListTasksAction .TYPE .name ())
123- && false == t .action ().contains (HealthNode .TASK_NAME )
124- )
125- .toList ()
126- );
127- assertTrue ("request must be failed or completed after clearing disruption" , future .isDone ());
128- ensureBlocksReleased ();
129- logger .info ("--> failed to execute esql query with disruption; retrying..." , e );
130- EsqlTestUtils .assertEsqlFailure (e );
131135 }
136+ // re-run the query
132137 return super .run (request );
133138 }
134139
0 commit comments