Skip to content

Apache Lucene open-source search software

SOLR-6721: ZkController.ensureReplicaInLeaderInitiatedRecovery puts replica in local map before writing to ZK

Shalin Shekhar Mangar6639fc546aa2
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 55524d2728d..7a68275a97d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -275,6 +275,9 @@ Bug Fixes
* SOLR-6579:SnapPuller Replication blocks clean shutdown of tomcat
(Philip Black-Knight via Noble Paul)
+* SOLR-6721: ZkController.ensureReplicaInLeaderInitiatedRecovery puts replica
+ in local map before writing to ZK. (shalin)
+
Optimizations
----------------------
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 55d2ae0bfca..4dbcfcaa5a3 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -190,7 +190,7 @@ public final class ZkController {
private volatile boolean isClosed;
// keeps track of replicas that have been asked to recover by leaders running on this node
- private Map<String,String> replicasInLeaderInitiatedRecovery = new HashMap<String,String>();
+ private final Map<String,String> replicasInLeaderInitiatedRecovery = new HashMap<String,String>();
// This is an expert and unsupported development mode that does not create
// an Overseer or register a /live node. This let's you monitor the cluster
@@ -1925,10 +1925,10 @@ public final class ZkController {
// if the replica's state is not DOWN right now, make it so ...
// we only really need to try to send the recovery command if the node itself is "live"
if (getZkStateReader().getClusterState().liveNodesContain(replicaNodeName)) {
- replicasInLeaderInitiatedRecovery.put(replicaUrl,
- getLeaderInitiatedRecoveryZnodePath(collection, shardId, replicaCoreNodeName));
// create a znode that requires the replica needs to "ack" to verify it knows it was out-of-sync
updateLeaderInitiatedRecoveryState(collection, shardId, replicaCoreNodeName, ZkStateReader.DOWN);
+ replicasInLeaderInitiatedRecovery.put(replicaUrl,
+ getLeaderInitiatedRecoveryZnodePath(collection, shardId, replicaCoreNodeName));
log.info("Put replica core={} coreNodeName={} on "+
replicaNodeName+" into leader-initiated recovery.", replicaCoreProps.getCoreName(), replicaCoreNodeName);
publishDownState = true;
@@ -1957,8 +1957,8 @@ public final class ZkController {
}
return nodeIsLive;
- }
-
+ }
+
public boolean isReplicaInRecoveryHandling(String replicaUrl) {
boolean exists = false;
synchronized (replicasInLeaderInitiatedRecovery) {