mirror of https://github.com/apache/lucene.git
SOLR-5397: If a retry fails, *always* finish the rest of the retries
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1536511 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d40d4d2c6
commit
03ed51acef
|
@ -72,46 +72,51 @@ public class SolrCmdDistributor {
|
||||||
allErrors.addAll(errors);
|
allErrors.addAll(errors);
|
||||||
boolean blockUntilFinishedAgain = false;
|
boolean blockUntilFinishedAgain = false;
|
||||||
for (Error err : errors) {
|
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...
|
// 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
|
// this can happen in certain situations such as shutdown
|
||||||
if (isRetry) {
|
if (isRetry) {
|
||||||
if (rspCode == 404 || rspCode == 403 || rspCode == 503
|
if (rspCode == 404 || rspCode == 403 || rspCode == 503
|
||||||
|| rspCode == 500) {
|
|| 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;
|
doRetry = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRetry && err.req.retries < MAX_RETRIES_ON_FORWARD && doRetry) {
|
// if its an ioexception, lets try again
|
||||||
err.req.retries++;
|
if (err.e instanceof IOException) {
|
||||||
|
doRetry = true;
|
||||||
SolrException.log(SolrCmdDistributor.log, "forwarding update to "
|
} else if (err.e instanceof SolrServerException) {
|
||||||
+ oldNodeUrl + " failed - retrying ... ");
|
if (((SolrServerException) err.e).getRootCause() instanceof IOException) {
|
||||||
try {
|
doRetry = true;
|
||||||
Thread.sleep(500);
|
}
|
||||||
} catch (InterruptedException e) {
|
}
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
log.warn(null, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit(err.req);
|
if (isRetry && err.req.retries < MAX_RETRIES_ON_FORWARD && doRetry) {
|
||||||
blockUntilFinishedAgain = true;
|
err.req.retries++;
|
||||||
|
|
||||||
|
SolrException.log(SolrCmdDistributor.log, "forwarding update to "
|
||||||
|
+ oldNodeUrl + " failed - retrying ... ");
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
log.warn(null, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
submit(err.req);
|
||||||
|
blockUntilFinishedAgain = true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
SolrException.log(log, "Retry attempt failed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,12 @@ import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
|
||||||
import org.apache.solr.client.solrj.impl.HttpClientUtil;
|
import org.apache.solr.client.solrj.impl.HttpClientUtil;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
import org.apache.solr.common.util.JavaBinCodec;
|
|
||||||
import org.apache.solr.update.SolrCmdDistributor.Error;
|
import org.apache.solr.update.SolrCmdDistributor.Error;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class StreamingSolrServers {
|
public class StreamingSolrServers {
|
||||||
public static Logger scdlog = LoggerFactory.getLogger(SolrCmdDistributor.class);
|
public static Logger log = LoggerFactory.getLogger(StreamingSolrServers.class);
|
||||||
|
|
||||||
private static HttpClient httpClient;
|
private static HttpClient httpClient;
|
||||||
static {
|
static {
|
||||||
|
@ -73,7 +72,7 @@ public class StreamingSolrServers {
|
||||||
server = new ConcurrentUpdateSolrServer(url, httpClient, 100, 1, updateExecutor) {
|
server = new ConcurrentUpdateSolrServer(url, httpClient, 100, 1, updateExecutor) {
|
||||||
@Override
|
@Override
|
||||||
public void handleError(Throwable ex) {
|
public void handleError(Throwable ex) {
|
||||||
scdlog.error("error", ex);
|
log.error("error", ex);
|
||||||
Error error = new Error();
|
Error error = new Error();
|
||||||
error.e = (Exception) ex;
|
error.e = (Exception) ex;
|
||||||
if (ex instanceof SolrException) {
|
if (ex instanceof SolrException) {
|
||||||
|
|
Loading…
Reference in New Issue