also check for SolrServerException#rootCause - we want to retry if it is an IOException as well

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1346975 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-06-06 16:35:43 +00:00
parent 3e5607cc60
commit 3bb8c907e8
1 changed files with 16 additions and 8 deletions

View File

@ -34,6 +34,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpClientUtil; import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest; import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
@ -360,20 +361,27 @@ public class SolrCmdDistributor {
int rspCode = sreq.rspCode; int rspCode = sreq.rspCode;
// this can happen in certain situations such as shutdown // this can happen in certain situations such as shutdown
if (isRetry && (rspCode == 404 || rspCode == 403 || rspCode == 503 || rspCode == 500)) { if (isRetry) {
if (rspCode == 404 || rspCode == 403 || rspCode == 503
|| rspCode == 500) {
doRetry = true; doRetry = true;
} }
// if its an ioexception, lets try again // if its an ioexception, lets try again
if (isRetry && sreq.exception instanceof IOException) { if (sreq.exception instanceof IOException) {
doRetry = true; doRetry = true;
} else if (sreq.exception instanceof SolrServerException) {
if (((SolrServerException) sreq.exception).getRootCause() instanceof IOException) {
doRetry = true;
}
}
} }
if (isRetry && sreq.retries < MAX_RETRIES_ON_FORWARD && doRetry) { if (isRetry && sreq.retries < MAX_RETRIES_ON_FORWARD && doRetry) {
sreq.retries++; sreq.retries++;
sreq.rspCode = 0; sreq.rspCode = 0;
sreq.exception = null; sreq.exception = null;
SolrException.log(SolrCmdDistributor.log, "forwarding update to " + sreq.node.getUrl() + " failed - retrying ... ", null); SolrException.log(SolrCmdDistributor.log, "forwarding update to " + sreq.node.getUrl() + " failed - retrying ... ");
Thread.sleep(500); Thread.sleep(500);
submit(sreq); submit(sreq);
checkResponses(block); checkResponses(block);