aparnasuresh85 commented on code in PR #2493:
URL: https://github.com/apache/solr/pull/2493#discussion_r1697023501


##########
solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java:
##########
@@ -211,23 +216,33 @@ public ShardResponse takeCompletedIncludingErrors() {
    */
   @Override
   public ShardResponse takeCompletedOrError() {
-    return take(true);
+    return take(true, -1);
   }
 
-  private ShardResponse take(boolean bailOnError) {
+  private ShardResponse take(boolean bailOnError, long maxAllowedTimeInMillis) 
{
     try {
-      while (pending.get() > 0) {
-        ShardResponse rsp = responses.take();
-        responseFutureMap.remove(rsp);
+      long deadline = System.nanoTime();
+      if (maxAllowedTimeInMillis > 0) {
+        deadline += TimeUnit.MILLISECONDS.toNanos(maxAllowedTimeInMillis);
+      } else {
+        deadline = System.nanoTime() + TimeUnit.DAYS.toNanos(1);
+      }
 
+      ShardResponse previousResponse = null;
+      while (pending.get() > 0) {
+        long waitTime = deadline - System.nanoTime();
+        ShardResponse rsp = responses.poll(waitTime, TimeUnit.NANOSECONDS);
         pending.decrementAndGet();
+        if (rsp == null) return previousResponse;

Review Comment:
   Rather than terminating early when the first request times out, can we throw 
an exception to allow LBSolrClient to attempt the query on another replica? 
Returning previousResponse upon a timeout doesn't seem appropriate. Instead, 
the query should be tried on all replicas for the shard.
   
   This approach would also enhance metric tracking. By doing this, we can 
ensure that query failures are clearly distinguished from partial results



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to