From 21ed14f6ad23a03261c5f59198024c06554ac7e2 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Mon, 17 Feb 2014 18:30:38 +0000 Subject: [PATCH] SOLR-5739: Sub-shards created by shard splitting have their update log set to buffering mode on restarts git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1569072 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../core/src/java/org/apache/solr/cloud/Overseer.java | 4 ++++ .../solr/cloud/OverseerCollectionProcessor.java | 11 +++++++++++ solr/core/src/java/org/apache/solr/core/SolrCore.java | 11 ++++++----- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 26820d88c47..50bfcdb7606 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -340,6 +340,9 @@ Bug Fixes * SOLR-5727: LBHttpSolrServer should only retry on Connection exceptions when sending updates. Affects CloudSolrServer. (Mark Miller) +* SOLR-5739: Sub-shards created by shard splitting have their update log set + to buffering mode on restarts. (Günther Ruck, shalin) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java index 1c3c5efd630..26484975b0f 100644 --- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java +++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java @@ -379,8 +379,12 @@ public class Overseer { Map sliceProps = new HashMap(); String shardRange = message.getStr(ZkStateReader.SHARD_RANGE_PROP); String shardState = message.getStr(ZkStateReader.SHARD_STATE_PROP); + String shardParent = message.getStr(ZkStateReader.SHARD_PARENT_PROP); sliceProps.put(Slice.RANGE, shardRange); sliceProps.put(Slice.STATE, shardState); + if (shardParent != null) { + sliceProps.put(Slice.PARENT, shardParent); + } slice = new Slice(shardId, replicas, sliceProps); clusterState = updateSlice(clusterState, collection, slice); } else { diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java index 7cc349ebe0b..7dc66033fd5 100644 --- a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java +++ b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java @@ -949,6 +949,17 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { + subSlice + " of collection " + collectionName + " on " + nodeName); + Map propMap = new HashMap(); + propMap.put(Overseer.QUEUE_OPERATION, "createshard"); + propMap.put(ZkStateReader.SHARD_ID_PROP, subSlice); + propMap.put(ZkStateReader.COLLECTION_PROP, collectionName); + propMap.put(ZkStateReader.SHARD_RANGE_PROP, subRange.toString()); + propMap.put(ZkStateReader.SHARD_STATE_PROP, Slice.CONSTRUCTION); + propMap.put(ZkStateReader.SHARD_PARENT_PROP, parentSlice.getName()); + ZkNodeProps m = new ZkNodeProps(propMap); + DistributedQueue inQueue = Overseer.getInQueue(zkStateReader.getZkClient()); + inQueue.offer(ZkStateReader.toJSON(m)); + ModifiableSolrParams params = new ModifiableSolrParams(); params.set(CoreAdminParams.ACTION, CoreAdminAction.CREATE.toString()); diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index 44d0cb218d5..1800c54178d 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -64,6 +64,7 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.LockObtainFailedException; import org.apache.solr.cloud.CloudDescriptor; import org.apache.solr.common.SolrException; +import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams.EchoParamStyle; @@ -866,13 +867,13 @@ public final class SolrCore implements SolrInfoMBean { "SolrCloud will always use full index replication instead of the more efficient PeerSync method."); } - if (Slice.CONSTRUCTION.equals(cd.getCloudDescriptor().getShardState())) { + // ZK pre-Register would have already happened so we read slice properties now + ClusterState clusterState = cc.getZkController().getClusterState(); + Slice slice = clusterState.getSlice(cd.getCloudDescriptor().getCollectionName(), + cd.getCloudDescriptor().getShardId()); + if (Slice.CONSTRUCTION.equals(slice.getState())) { // set update log to buffer before publishing the core getUpdateHandler().getUpdateLog().bufferUpdates(); - - cd.getCloudDescriptor().setShardState(null); - cd.getCloudDescriptor().setShardRange(null); - cd.getCloudDescriptor().setShardParent(null); } } // For debugging