You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ja...@apache.org on 2026/04/27 21:47:22 UTC

(solr) branch branch_10x updated: SOLR-18174 Fix test race condition failure in AsyncTrackerSemaphoreLeakTest (#4331)

This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new f194e33c4e7 SOLR-18174 Fix test race condition failure in AsyncTrackerSemaphoreLeakTest (#4331)
f194e33c4e7 is described below

commit f194e33c4e7774bc25db2a59329a392b28e3a108
Author: Jan Høydahl <ja...@apache.org>
AuthorDate: Mon Apr 27 23:44:12 2026 +0200

    SOLR-18174 Fix test race condition failure in AsyncTrackerSemaphoreLeakTest (#4331)
    
    (cherry picked from commit 2093185efaffa5e6677125c54db7fd3151bb6bf1)
---
 .../solr/handler/component/AsyncTrackerSemaphoreLeakTest.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/solr/core/src/test/org/apache/solr/handler/component/AsyncTrackerSemaphoreLeakTest.java b/solr/core/src/test/org/apache/solr/handler/component/AsyncTrackerSemaphoreLeakTest.java
index 1ff3ec542ed..fb04ec1ef67 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/AsyncTrackerSemaphoreLeakTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/AsyncTrackerSemaphoreLeakTest.java
@@ -204,7 +204,16 @@ public class AsyncTrackerSemaphoreLeakTest extends SolrCloudTestCase {
                 + " fires synchronously on the IO thread before onComplete can release().");
       }
 
-      int permitsAfterFailures = testClient.asyncTrackerAvailablePermits();
+      // Poll briefly: apiFutures complete on the executor thread, but completeListener fires on
+      // Jetty's IO thread after response listeners, so allOf().get() can race ahead of release().
+      int permitsAfterFailures;
+      long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5);
+      do {
+        permitsAfterFailures = testClient.asyncTrackerAvailablePermits();
+        if (permitsAfterFailures == MAX_PERMITS) break;
+        //noinspection BusyWait
+        Thread.sleep(10);
+      } while (System.nanoTime() < deadline);
       log.info("Permits after retries: {}/{}", permitsAfterFailures, MAX_PERMITS);
       assertEquals(
           "All permits should be restored after retries complete",