@@ -79,6 +79,11 @@ public class EsqlActionTaskIT extends AbstractPausableIntegTestCase {
7979 private String REDUCE_DESCRIPTION ;
8080 private boolean nodeLevelReduction ;
8181
82+ /**
83+ * Number of docs released by {@link #startEsql}.
84+ */
85+ private int prereleasedDocs ;
86+
8287 @ Before
8388 public void setup () {
8489 assumeTrue ("requires query pragmas" , canUseQueryPragmas ());
@@ -104,6 +109,7 @@ public void testTaskContents() throws Exception {
104109 ActionFuture <EsqlQueryResponse > response = startEsql ();
105110 try {
106111 getTasksStarting ();
112+ logger .info ("unblocking script" );
107113 scriptPermits .release (pageSize ());
108114 List <TaskInfo > foundTasks = getTasksRunning ();
109115 int luceneSources = 0 ;
@@ -216,9 +222,15 @@ private ActionFuture<EsqlQueryResponse> startEsql() {
216222 return startEsql ("from test | stats sum(pause_me)" );
217223 }
218224
225+ /**
226+ * Start an ESQL query, releasing a few docs from the {@code pause_me}
227+ * script so it'll actually start but won't finish it's first page.
228+ */
219229 private ActionFuture <EsqlQueryResponse > startEsql (String query ) {
220230 scriptPermits .drainPermits ();
221- scriptPermits .release (between (1 , 5 ));
231+ // Allow a few docs to calculate os the query gets "started"
232+ prereleasedDocs = between (1 , pageSize () / 2 );
233+ scriptPermits .release (prereleasedDocs );
222234 var settingsBuilder = Settings .builder ()
223235 // Force shard partitioning because that's all the tests know how to match. It is easier to reason about too.
224236 .put ("data_partitioning" , "shard" )
@@ -444,6 +456,7 @@ public void testTaskContentsForTopNQuery() throws Exception {
444456 ActionFuture <EsqlQueryResponse > response = startEsql ("from test | sort pause_me | keep pause_me" );
445457 try {
446458 getTasksStarting ();
459+ logger .info ("unblocking script" );
447460 scriptPermits .release (pageSize ());
448461 getTasksRunning ();
449462 } finally {
@@ -455,7 +468,6 @@ public void testTaskContentsForTopNQuery() throws Exception {
455468 }
456469 }
457470
458- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/107293" )
459471 public void testTaskContentsForLimitQuery () throws Exception {
460472 String limit = Integer .toString (randomIntBetween (pageSize () + 1 , 2 * numberOfDocs ()));
461473 READ_DESCRIPTION = """
@@ -475,7 +487,8 @@ public void testTaskContentsForLimitQuery() throws Exception {
475487 ActionFuture <EsqlQueryResponse > response = startEsql ("from test | keep pause_me | limit " + limit );
476488 try {
477489 getTasksStarting ();
478- scriptPermits .release (pageSize ());
490+ logger .info ("unblocking script" );
491+ scriptPermits .release (pageSize () - prereleasedDocs );
479492 getTasksRunning ();
480493 } finally {
481494 scriptPermits .release (numberOfDocs ());
@@ -504,6 +517,7 @@ public void testTaskContentsForGroupingStatsQuery() throws Exception {
504517 ActionFuture <EsqlQueryResponse > response = startEsql ("from test | stats max(foo) by pause_me" );
505518 try {
506519 getTasksStarting ();
520+ logger .info ("unblocking script" );
507521 scriptPermits .release (pageSize ());
508522 getTasksRunning ();
509523 } finally {
0 commit comments