SOLR-5479: SolrCmdDistributor retry logic stops if a leader for the request cannot be found in 1 second.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1543940 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-11-20 20:44:43 +00:00
parent f005912635
commit 83e28ca6dd
2 changed files with 50 additions and 35 deletions

View File

@ -114,6 +114,9 @@ Bug Fixes
* SOLR-5461: Request proxying should only set con.setDoOutput(true) if the
request is a post. (Mark Miller)
* SOLR-5479: SolrCmdDistributor retry logic stops if a leader for the request
cannot be found in 1 second. (Mark Miller)
Optimizations
----------------------

View File

@ -72,48 +72,56 @@ public class SolrCmdDistributor {
List<Error> resubmitList = new ArrayList<Error>();
for (Error err : errors) {
String oldNodeUrl = err.req.node.getUrl();
try {
String oldNodeUrl = err.req.node.getUrl();
// if there is a retry url, we want to retry...
boolean isRetry = err.req.node.checkRetry();
boolean doRetry = false;
int rspCode = err.statusCode;
// if there is a retry url, we want to retry...
boolean isRetry = err.req.node.checkRetry();
if (testing_errorHook != null) Diagnostics.call(testing_errorHook, err.e);
boolean doRetry = false;
int rspCode = err.statusCode;
// this can happen in certain situations such as shutdown
if (isRetry) {
if (rspCode == 404 || rspCode == 403 || rspCode == 503
|| rspCode == 500) {
doRetry = true;
}
if (testing_errorHook != null) Diagnostics.call(testing_errorHook,
err.e);
// if its an ioexception, lets try again
if (err.e instanceof IOException) {
doRetry = true;
} else if (err.e instanceof SolrServerException) {
if (((SolrServerException) err.e).getRootCause() instanceof IOException) {
// this can happen in certain situations such as shutdown
if (isRetry) {
if (rspCode == 404 || rspCode == 403 || rspCode == 503
|| rspCode == 500) {
doRetry = true;
}
}
if (err.req.retries < MAX_RETRIES_ON_FORWARD && doRetry) {
err.req.retries++;
SolrException.log(SolrCmdDistributor.log, "forwarding update to "
+ oldNodeUrl + " failed - retrying ... retries: " + err.req.retries);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.warn(null, e);
// if its an ioexception, lets try again
if (err.e instanceof IOException) {
doRetry = true;
} else if (err.e instanceof SolrServerException) {
if (((SolrServerException) err.e).getRootCause() instanceof IOException) {
doRetry = true;
}
}
if (err.req.retries < MAX_RETRIES_ON_FORWARD && doRetry) {
err.req.retries++;
resubmitList.add(err);
SolrException.log(SolrCmdDistributor.log, "forwarding update to "
+ oldNodeUrl + " failed - retrying ... retries: "
+ err.req.retries);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.warn(null, e);
}
resubmitList.add(err);
} else {
allErrors.add(err);
}
} else {
allErrors.add(err);
}
} else {
allErrors.add(err);
} catch (Exception e) {
// continue on
log.error("Unexpected Error while doing request retries", e);
}
}
@ -353,6 +361,10 @@ public class SolrCmdDistributor {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return false;
} catch (Exception e) {
// we retry with same info
log.warn(null, e);
return true;
}
this.nodeProps = leaderProps;