diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 53de9ba8ba3..22113c45492 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -291,6 +291,8 @@ Bug Fixes * SOLR-5019: spurious ConcurrentModificationException when spell check component was in use with filters. (yonik) +* SOLR-5018: The Overseer should avoid publishing the state for collections that do not + exist under the /collections zk node. (Mark Miller) 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 781cae49995..1aabf41bcf0 100644 --- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java +++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java @@ -28,6 +28,7 @@ import java.util.Map.Entry; import java.util.Set; import org.apache.solr.common.SolrException; +import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.cloud.ClosableThread; import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.DocCollection; @@ -269,6 +270,19 @@ public class Overseer { */ private ClusterState updateState(ClusterState state, final ZkNodeProps message) { final String collection = message.getStr(ZkStateReader.COLLECTION_PROP); + assert collection.length() > 0 : message; + + try { + if (!zkClient.exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection, true)) { + log.warn("Could not find collection node for " + collection + ", skipping publish state"); + } + } catch (KeeperException e) { + throw new SolrException(ErrorCode.SERVER_ERROR, e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new SolrException(ErrorCode.SERVER_ERROR, e); + } + String coreNodeName = message.getStr(ZkStateReader.CORE_NODE_NAME_PROP); if (coreNodeName == null) { coreNodeName = getAssignedCoreNodeName(state, message); 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 b046e7d4018..7e0682c91ad 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -990,6 +990,9 @@ public final class ZkController { numShards = Integer.getInteger(ZkStateReader.NUM_SHARDS_PROP); } + assert cd.getCloudDescriptor().getCollectionName() != null && cd.getCloudDescriptor() + .getCollectionName().length() > 0; + String coreNodeName = cd.getCloudDescriptor().getCoreNodeName(); //assert cd.getCloudDescriptor().getShardId() != null; ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, "state", diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSolrXmlOld.java b/solr/core/src/java/org/apache/solr/core/ConfigSolrXmlOld.java index 40c1a87fe14..fc9418a97a1 100644 --- a/solr/core/src/java/org/apache/solr/core/ConfigSolrXmlOld.java +++ b/solr/core/src/java/org/apache/solr/core/ConfigSolrXmlOld.java @@ -298,7 +298,7 @@ public class ConfigSolrXmlOld extends ConfigSolr { + ">\n" + " \n" + + "\" shard=\"${shard:}\" collection=\"${collection:collection1}\" instanceDir=\"collection1\" />\n" + " \n" + ""; @Override diff --git a/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java b/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java index 7bc0789c617..01d7b4404b1 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ClusterStateUpdateTest.java @@ -154,6 +154,10 @@ public class ClusterStateUpdateTest extends SolrTestCaseJ4 { "testcore"); dcore.setDataDir(dataDir4.getAbsolutePath()); + + CloudDescriptor cloudDesc = new CloudDescriptor(); + cloudDesc.setCollectionName("testcore"); + dcore.setCloudDescriptor(cloudDesc); if (container1.getZkController() != null) { container1.preRegisterInZk(dcore);