Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-6189: Don't publish the state as down if the node is not live when determining if a replica should be in leader-initiated recovery.

Timothy Potterb24d80fba39e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6b9a5bb9f50..21b635a1c2d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -96,6 +96,9 @@ Bug Fixes
* SOLR-6165: DataImportHandler should write BigInteger and BigDecimal values as strings.
(Anand Sengamalai via shalin)
+
+* SOLR-6189: Avoid publishing the state as down if the node is not live when determining
+ if a replica should be in leader-initiated recovery. (Timothy Potter)
Other Changes
---------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index bcefb140d89..9d165f29fce 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -1776,9 +1776,11 @@ public final class ZkController {
// about the same replica having trouble and we only need to send the "needs"
// recovery signal once
boolean nodeIsLive = true;
+ boolean publishDownState = false;
synchronized (replicasInLeaderInitiatedRecovery) {
if (replicasInLeaderInitiatedRecovery.containsKey(replicaUrl)) {
if (!forcePublishState) {
+ log.debug("Replica {} already in leader-initiated recovery handling.", replicaUrl);
return false; // already in this recovery process
}
}
@@ -1794,22 +1796,32 @@ public final class ZkController {
getLeaderInitiatedRecoveryZnodePath(collection, shardId, replicaCoreName));
// create a znode that requires the replica needs to "ack" to verify it knows it was out-of-sync
updateLeaderInitiatedRecoveryState(collection, shardId, replicaCoreName, ZkStateReader.DOWN);
+ log.info("Put replica "+replicaCoreName+" on "+
+ replicaNodeName+" into leader-initiated recovery.");
+ publishDownState = true;
} else {
nodeIsLive = false; // we really don't need to send the recovery request if the node is NOT live
+ log.info("Node "+replicaNodeName+
+ " is not live, so skipping leader-initiated recovery for replica: "+
+ replicaCoreName);
+ // publishDownState will be false to avoid publishing the "down" state too many times
+ // as many errors can occur together and will each call into this method (SOLR-6189)
}
}
- String replicaCoreName = replicaCoreProps.getCoreName();
- ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, "state",
- ZkStateReader.STATE_PROP, ZkStateReader.DOWN,
- ZkStateReader.BASE_URL_PROP, replicaCoreProps.getBaseUrl(),
- ZkStateReader.CORE_NAME_PROP, replicaCoreProps.getCoreName(),
- ZkStateReader.NODE_NAME_PROP, replicaCoreProps.getNodeName(),
- ZkStateReader.SHARD_ID_PROP, shardId,
- ZkStateReader.COLLECTION_PROP, collection);
- log.warn("Leader is publishing core={} state={} on behalf of un-reachable replica {}; forcePublishState? "+forcePublishState,
- replicaCoreName, ZkStateReader.DOWN, replicaUrl);
- overseerJobQueue.offer(ZkStateReader.toJSON(m));
+ if (publishDownState || forcePublishState) {
+ String replicaCoreName = replicaCoreProps.getCoreName();
+ ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, "state",
+ ZkStateReader.STATE_PROP, ZkStateReader.DOWN,
+ ZkStateReader.BASE_URL_PROP, replicaCoreProps.getBaseUrl(),
+ ZkStateReader.CORE_NAME_PROP, replicaCoreProps.getCoreName(),
+ ZkStateReader.NODE_NAME_PROP, replicaCoreProps.getNodeName(),
+ ZkStateReader.SHARD_ID_PROP, shardId,
+ ZkStateReader.COLLECTION_PROP, collection);
+ log.warn("Leader is publishing core={} state={} on behalf of un-reachable replica {}; forcePublishState? "+forcePublishState,
+ replicaCoreName, ZkStateReader.DOWN, replicaUrl);
+ overseerJobQueue.offer(ZkStateReader.toJSON(m));
+ }
return nodeIsLive;
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
index 2373e628ebb..0f7ab61b011 100644
--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
@@ -79,13 +79,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
@Override
@After
- public void tearDown() throws Exception {
- if (!proxies.isEmpty()) {
- for (SocketProxy proxy : proxies.values()) {
- proxy.close();
- }
- }
-
+ public void tearDown() throws Exception {
System.clearProperty("numShards");
try {
@@ -93,6 +87,13 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
} catch (Exception exc) {}
resetExceptionIgnores();
+
+ // close socket proxies after super.tearDown
+ if (!proxies.isEmpty()) {
+ for (SocketProxy proxy : proxies.values()) {
+ proxy.close();
+ }
+ }
}
/**