From 51a370899fddc52da66477def533dd452c4b014f Mon Sep 17 00:00:00 2001 From: hitesh Date: Wed, 30 Oct 2024 09:12:01 -0700 Subject: [PATCH] fixed request leak --- .../apache/solr/servlet/PriorityBasedRateLimiter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/servlet/PriorityBasedRateLimiter.java b/solr/core/src/java/org/apache/solr/servlet/PriorityBasedRateLimiter.java index 3b9ce49a16b..b4d17afaae5 100644 --- a/solr/core/src/java/org/apache/solr/servlet/PriorityBasedRateLimiter.java +++ b/solr/core/src/java/org/apache/solr/servlet/PriorityBasedRateLimiter.java @@ -65,8 +65,13 @@ private boolean acquire(RequestPriorities priority) throws InterruptedException CountDownLatch wait = new CountDownLatch(1); this.waitingList.put(wait); long startTime = System.nanoTime(); - return wait.await(this.waitTimeoutInNanos, TimeUnit.NANOSECONDS) - && nextInQueue(this.waitTimeoutInNanos - (System.nanoTime() - startTime)); + if (wait.await(this.waitTimeoutInNanos, TimeUnit.NANOSECONDS)) { + return nextInQueue(this.waitTimeoutInNanos - (System.nanoTime() - startTime)); + } else { + // remove from the queue; this/other requests already waited long enough; thus best effort + this.waitingList.poll(); + return false; + } } } return true;