Apache Solr open-source search software
SOLR-4254: Harden the 'leader requests replica to recover' code path.
Mark Robert Miller463d10dc4a7d
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 689860c356c..05937eadb98 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -495,6 +495,9 @@ Other Changes* SOLR-3279: Upgrade Carrot2 to 3.6.2 (Stanisław Osiński)+* SOLR-4254: Harden the 'leader requests replica to recover' code path.+ (Mark Miller, yonik)+================== 4.0.0 ==================Versions of Major Componentsdiff --git a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.javaindex 69d0c61bc0b..086e80ffe8a 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java@@ -777,33 +777,41 @@ public class CoreAdminHandler extends RequestHandlerBase {SolrQueryResponse rsp) throws IOException {final SolrParams params = req.getParams();log.info("It has been requested that we recover");- String cname = params.get(CoreAdminParams.CORE);- if (cname == null) {- cname = "";- }- SolrCore core = null;- try {- core = coreContainer.getCore(cname);- if (core != null) {- // try to publish as recovering right away+ Thread thread = new Thread() {+ @Override+ public void run() {+ String cname = params.get(CoreAdminParams.CORE);+ if (cname == null) {+ cname = "";+ }+ SolrCore core = null;try {- coreContainer.getZkController().publish(core.getCoreDescriptor(), ZkStateReader.RECOVERING);- } catch (KeeperException e) {- SolrException.log(log, "", e);- } catch (InterruptedException e) {- SolrException.log(log, "", e);+ core = coreContainer.getCore(cname);+ if (core != null) {+ // try to publish as recovering right away+ try {+ coreContainer.getZkController().publish(core.getCoreDescriptor(), ZkStateReader.RECOVERING);+ } catch (InterruptedException e) {+ Thread.currentThread().interrupt();+ SolrException.log(log, "", e);+ } catch (Throwable t) {+ SolrException.log(log, "", t);+ }++ core.getUpdateHandler().getSolrCoreState().doRecovery(coreContainer, cname);+ } else {+ SolrException.log(log, "Cound not find core to call recovery:" + cname);+ }+ } finally {+ // no recoveryStrat close for now+ if (core != null) {+ core.close();+ }}-- core.getUpdateHandler().getSolrCoreState().doRecovery(coreContainer, cname);- } else {- SolrException.log(log, "Cound not find core to call recovery:" + cname);}- } finally {- // no recoveryStrat close for now- if (core != null) {- core.close();- }- }+ };++ thread.start();}protected void handleRequestSyncAction(SolrQueryRequest req,diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.javaindex 5a326a384c0..083bba8536c 100644--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java@@ -422,8 +422,8 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {log.info("try and ask " + recoveryUrl + " to recover");try {server = new HttpSolrServer(recoveryUrl);- server.setSoTimeout(5000);- server.setConnectionTimeout(5000);+ server.setSoTimeout(15000);+ server.setConnectionTimeout(15000);RequestRecovery recoverRequestCmd = new RequestRecovery();recoverRequestCmd.setAction(CoreAdminAction.REQUESTRECOVERY);