diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java index 11838bfe0e000..2cd93fdade508 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/ManyShardsIT.java @@ -110,26 +110,27 @@ public void testConcurrentQueries() throws Exception { CountDownLatch latch = new CountDownLatch(1); for (int q = 0; q < numQueries; q++) { threads[q] = new Thread(() -> { - try { - assertTrue(latch.await(1, TimeUnit.MINUTES)); - } catch (InterruptedException e) { - throw new AssertionError(e); - } + safeAwait(latch); final var pragmas = Settings.builder(); if (randomBoolean() && canUseQueryPragmas()) { pragmas.put(randomPragmas().getSettings()) .put("task_concurrency", between(1, 2)) .put("exchange_concurrent_clients", between(1, 2)); } - run("from test-* | stats count(user) by tags", new QueryPragmas(pragmas.build())).close(); - }); + try (var response = run("from test-* | stats count(user) by tags", new QueryPragmas(pragmas.build()))) { + // do nothing + } catch (Exception | AssertionError e) { + logger.warn("Query failed with exception", e); + throw e; + } + }, "testConcurrentQueries"); } for (Thread thread : threads) { thread.start(); } latch.countDown(); for (Thread thread : threads) { - thread.join(); + thread.join(10_000); } }