[
https://issues.apache.org/jira/browse/SOLR-13481?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rajeswri Natarajan updated SOLR-13481:
--------------------------------------
Description:
LBHttpSolrClient.java needs to be fixed , as if the doRequest 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); }
}
was:
LBHttpSolrClient.java needs to be fixed , as if the doRequest method throws
exception , the for loop will get terminated
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);
}
}
> Re-try the solr request will not happen, if one request throws Exception
> ------------------------------------------------------------------------
>
> Key: SOLR-13481
> URL: https://issues.apache.org/jira/browse/SOLR-13481
> Project: Solr
> Issue Type: Bug
> Security Level: Public(Default Security Level. Issues are Public)
> Components: clients - java
> Affects Versions: 7.6
> Reporter: Rajeswri Natarajan
> Priority: Major
>
> LBHttpSolrClient.java needs to be fixed , as if the doRequest 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); }
>
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]