Apache Solr open-source search software
SOLR-11278: Fix race-condition in CDCR submitting a bootstrap call and checking it's status
Varun Thacker8e12f201131d
diff --git a/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorManager.java b/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorManager.javaindex 677f5d33e6e..6ef5ebdb25d 100644--- a/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorManager.java+++ b/solr/core/src/java/org/apache/solr/handler/CdcrReplicatorManager.java@@ -312,7 +312,9 @@ class CdcrReplicatorManager implements CdcrStateManager.CdcrStateObserver {timeOut = new TimeOut(BOOTSTRAP_TIMEOUT_SECONDS, TimeUnit.SECONDS); // reset the timerretries++;}- } else if (status == BootstrapStatus.NOTFOUND) {+ } else if (status == BootstrapStatus.NOTFOUND || status == BootstrapStatus.CANCELLED) {+ log.info("CDCR bootstrap " + (status == BootstrapStatus.NOTFOUND ? "not found" : "cancelled") + "in {} seconds",+ BOOTSTRAP_TIMEOUT_SECONDS - timeOut.timeLeft(TimeUnit.SECONDS));// the leader of the target shard may have changed and therefore there is no record of the// bootstrap process so we must retry the operationwhile (!closed && sendBootstrapCommand() != BootstrapStatus.SUBMITTED) {@@ -320,7 +322,9 @@ class CdcrReplicatorManager implements CdcrStateManager.CdcrStateObserver {}retries = 1;timeOut = new TimeOut(6L * 3600L * 3600L, TimeUnit.SECONDS); // reset the timer- } else if (status == BootstrapStatus.UNKNOWN) {+ } else if (status == BootstrapStatus.UNKNOWN || status == BootstrapStatus.SUBMITTED) {+ log.info("CDCR bootstrap is " + (status == BootstrapStatus.UNKNOWN ? "unknown" : "submitted"),+ BOOTSTRAP_TIMEOUT_SECONDS - timeOut.timeLeft(TimeUnit.SECONDS));// we were not able to query the status on the remote end// so just sleep for a bit and try againThread.sleep(BOOTSTRAP_RETRY_DELAY_MS);diff --git a/solr/core/src/test/org/apache/solr/cloud/CdcrBootstrapTest.java b/solr/core/src/test/org/apache/solr/cloud/CdcrBootstrapTest.javaindex a5b37d8a5d0..6959bd825d5 100644--- a/solr/core/src/test/org/apache/solr/cloud/CdcrBootstrapTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CdcrBootstrapTest.java@@ -239,7 +239,6 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {}}- @AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-11278")public void testBootstrapWithContinousIndexingOnSourceCluster() throws Exception {// start the target first so that we know its zkhostMiniSolrCloudCluster target = new MiniSolrCloudCluster(1, createTempDir("cdcr-target"), buildJettyConfig("/solr"));