From 2700b952119feb2d53a163d3374f56c85a0de339 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Tue, 30 Aug 2016 00:01:17 +0530 Subject: [PATCH] SOLR-9455: Deleting a sub-shard in recovery state can mark parent shard as inactive --- solr/CHANGES.txt | 2 ++ .../java/org/apache/solr/cloud/DeleteShardCmd.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 70c9f1eb78e..5f8694febb5 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -89,6 +89,8 @@ Bug Fixes * SOLR-9188: blockUnknown property makes inter-node communication impossible (noble) +* SOLR-9455: Deleting a sub-shard in recovery state can mark parent shard as inactive. (shalin) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/DeleteShardCmd.java b/solr/core/src/java/org/apache/solr/cloud/DeleteShardCmd.java index f2ae5ca6a48..a7f6d5bf264 100644 --- a/solr/core/src/java/org/apache/solr/cloud/DeleteShardCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/DeleteShardCmd.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.solr.cloud.OverseerCollectionMessageHandler.Cmd; +import org.apache.solr.cloud.overseer.OverseerAction; import org.apache.solr.common.SolrException; import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.DocCollection; @@ -73,6 +74,19 @@ public class DeleteShardCmd implements Cmd { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "The slice: " + slice.getName() + " is currently " + state + ". Only non-active (or custom-hashed) slices can be deleted."); } + + if (state == Slice.State.RECOVERY) { + // mark the slice as 'construction' and only then try to delete the cores + // see SOLR-9455 + DistributedQueue inQueue = Overseer.getStateUpdateQueue(ocmh.zkStateReader.getZkClient()); + Map propMap = new HashMap<>(); + propMap.put(Overseer.QUEUE_OPERATION, OverseerAction.UPDATESHARDSTATE.toLower()); + propMap.put(sliceId, Slice.State.CONSTRUCTION.toString()); + propMap.put(ZkStateReader.COLLECTION_PROP, collectionName); + ZkNodeProps m = new ZkNodeProps(propMap); + inQueue.offer(Utils.toJSON(m)); + } + ShardHandler shardHandler = ocmh.shardHandlerFactory.getShardHandler(); String asyncId = message.getStr(ASYNC);