Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-13481

Re-try of solr request will not happen with different live servers, if one request throws Exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 7.6
    • None
    • clients - java
    • None

    Description

      LBHttpSolrClient.java needs to be fixed , as if the doRequest (called by request method below) method throws exception, the for loop will get terminated and the request will fail

       
      public Rsp request(Req req) throws SolrServerException, IOException {
           Rsp rsp = new Rsp();
           Exception ex = null;
           boolean isNonRetryable = req.request instanceof IsUpdateRequest ||
      ADMIN_PATHS.contains(req.request.getPath());
           List<ServerWrapper> skipped = null;
       
           final Integer numServersToTry = req.getNumServersToTry();
           int numServersTried = 0;
       
           boolean timeAllowedExceeded = false;
           long timeAllowedNano = getTimeAllowedInNanos(req.getRequest());
           long timeOutTime = System.nanoTime() + timeAllowedNano;
           for (String serverStr : req.getServers()) {
             if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano,
      timeOutTime))

      {          break;        }

       
             serverStr = normalize(serverStr);
             // if the server is currently a zombie, just skip to the next one
             ServerWrapper wrapper = zombieServers.get(serverStr);
             if (wrapper != null) {
               // System.out.println("ZOMBIE SERVER QUERIED: " + serverStr);
               final int numDeadServersToTry = req.getNumDeadServersToTry();
               if (numDeadServersToTry > 0) {
                 if (skipped == null)

      {              skipped = new ArrayList<>(numDeadServersToTry);              skipped.add(wrapper);            }

                 else if (skipped.size() < numDeadServersToTry)

      {              skipped.add(wrapper);            }

               }
               continue;
             }
             try {
               MDC.put("LBHttpSolrClient.url", serverStr);
       
               if (numServersToTry != null && numServersTried >
      numServersToTry.intValue())

      {            break;          }

       
               HttpSolrClient client = makeSolrClient(serverStr);
       
               ++numServersTried;
               ex = doRequest(client, req, rsp, isNonRetryable, false, null);
               if (ex == null) {            return rsp; // SUCCESS          }
             } finally {          MDC.remove("LBHttpSolrClient.url");        }
           }
       
           // try the servers we previously skipped
           if (skipped != null)

      {        for (ServerWrapper wrapper : skipped) \{          if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) \{            break;          }

       
               if (numServersToTry != null && numServersTried >
      numServersToTry.intValue())
      {            break;          }

       
               try {
                 MDC.put("LBHttpSolrClient.url", wrapper.client.getBaseURL());
                 ++numServersTried;
                 ex = doRequest(wrapper.client, req, rsp, isNonRetryable, true,
      wrapper.getKey());
                 if (ex == null)

      {              return rsp; // SUCCESS            }

               } finally

      {            MDC.remove("LBHttpSolrClient.url");          }

             }
           }
       
       
           final String solrServerExceptionMessage;
           if (timeAllowedExceeded)

      {        solrServerExceptionMessage = "Time allowed to handle this request exceeded";      }

      else {
             if (numServersToTry != null && numServersTried >
      numServersToTry.intValue())

      {          solrServerExceptionMessage = "No live SolrServers available to handle this request:"              + " numServersTried="+numServersTried              + " numServersToTry="+numServersToTry.intValue();        }

      else

      {          solrServerExceptionMessage = "No live SolrServers available to handle this request";        }

           }
           if (ex == null)

      {        throw new SolrServerException(solrServerExceptionMessage);      }

      else

      {        throw new SolrServerException(solrServerExceptionMessage+":" + zombieServers.keySet(), ex);      }

       
         }

      Attachments

        Activity

          People

            Unassigned Unassigned
            Raji Rajeswari Natarajan
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: