mirror of https://github.com/apache/lucene.git
SOLR-5232: fix retry logic
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1538112 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d24357e87b
commit
f412b66a51
|
@ -69,42 +69,38 @@ public class SolrCmdDistributor {
|
||||||
|
|
||||||
List<Error> errors = new ArrayList<Error>(this.errors);
|
List<Error> errors = new ArrayList<Error>(this.errors);
|
||||||
errors.addAll(servers.getErrors());
|
errors.addAll(servers.getErrors());
|
||||||
allErrors.addAll(errors);
|
|
||||||
boolean blockUntilFinishedAgain = false;
|
boolean blockUntilFinishedAgain = false;
|
||||||
for (Error err : errors) {
|
for (Error err : errors) {
|
||||||
try {
|
String oldNodeUrl = err.req.node.getUrl();
|
||||||
String oldNodeUrl = err.req.node.getUrl();
|
|
||||||
|
// if there is a retry url, we want to retry...
|
||||||
// if there is a retry url, we want to retry...
|
boolean isRetry = err.req.node.checkRetry();
|
||||||
boolean isRetry = err.req.node.checkRetry();
|
boolean doRetry = false;
|
||||||
boolean doRetry = false;
|
int rspCode = err.statusCode;
|
||||||
int rspCode = err.statusCode;
|
|
||||||
|
if (testing_errorHook != null) Diagnostics.call(testing_errorHook, err.e);
|
||||||
if (testing_errorHook != null) Diagnostics.call(testing_errorHook,
|
|
||||||
err.e);
|
// this can happen in certain situations such as shutdown
|
||||||
|
if (isRetry) {
|
||||||
// this can happen in certain situations such as shutdown
|
if (rspCode == 404 || rspCode == 403 || rspCode == 503
|
||||||
if (isRetry) {
|
|| rspCode == 500) {
|
||||||
if (rspCode == 404 || rspCode == 403 || rspCode == 503
|
doRetry = true;
|
||||||
|| rspCode == 500) {
|
|
||||||
doRetry = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 (isRetry && err.req.retries < MAX_RETRIES_ON_FORWARD && doRetry) {
|
// 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++;
|
err.req.retries++;
|
||||||
|
|
||||||
SolrException.log(SolrCmdDistributor.log, "forwarding update to "
|
SolrException.log(SolrCmdDistributor.log, "forwarding update to "
|
||||||
+ oldNodeUrl + " failed - retrying ... ");
|
+ oldNodeUrl + " failed - retrying ... retries: " + err.req.retries);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -114,9 +110,11 @@ public class SolrCmdDistributor {
|
||||||
|
|
||||||
submit(err.req);
|
submit(err.req);
|
||||||
blockUntilFinishedAgain = true;
|
blockUntilFinishedAgain = true;
|
||||||
|
} else {
|
||||||
|
allErrors.add(err);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
SolrException.log(log, "Retry attempt failed", e);
|
allErrors.add(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue