You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2020/04/14 14:49:19 UTC

[lucene-solr] branch jira/solr-12847 updated: SOLR-12847: Improve checking for conflicting clauses.

This is an automated email from the ASF dual-hosted git repository.

ab pushed a commit to branch jira/solr-12847
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/jira/solr-12847 by this push:
     new ff74e1d  SOLR-12847: Improve checking for conflicting clauses.
ff74e1d is described below

commit ff74e1dd5831970b8f62a0f6a2301fab88edc9ec
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Tue Apr 14 16:48:40 2020 +0200

    SOLR-12847: Improve checking for conflicting clauses.
---
 .../solr/cloud/api/collections/CreateCollectionCmd.java       | 11 ++++++++++-
 .../org/apache/solr/common/params/CollectionAdminParams.java  |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
index 0ded334..3bb3b8c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
@@ -492,11 +492,18 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
   public static void maybeAddMaxReplicasRule(SolrCloudManager cloudManager, int maxReplicasPerNode, DocCollection docCollection,
                                                 AtomicReference<AutoScalingConfig> configToRestore) throws IOException, InterruptedException {
     AutoScalingConfig initialConfig = cloudManager.getDistribStateManager().getAutoScalingConfig();
+//    if (true) {
+//      return;
+//    }
     Policy policy = initialConfig.getPolicy();
     String policyName = docCollection.getPolicyName();
     if (policyName == null) {
       policyName = CollectionAdminParams.AUTO_PREFIX + docCollection.getName();
       docCollection.getProperties().put(Policy.POLICY, policyName);
+    } else if (policyName.startsWith(CollectionAdminParams.AUTO_PREFIX) && !policyName.endsWith(docCollection.getName())) {
+      // don't allow using auto-created policy belonging to a different collection
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Cannot reuse auto-created policy " + policyName +
+          " with a different collection " + docCollection.getName());
     }
     Map<String, List<Clause>> policies = policy.getPolicies();
     List<Clause> clauses = policies.get(policyName);
@@ -509,7 +516,9 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
           alreadyExists = true;
           break;
         }
-        if (clause.getReplica() != null) {
+        if (clause.getReplica() != null &&
+            clause.getReplica().getOperand().equals(c.getReplica().getOperand()) &&
+            clause.getReplica().getValue() != c.getReplica().getValue()) {
           throw new Assign.AssignmentException("Both an existing policy=" + policyName + " and " +
               MAX_SHARDS_PER_NODE + "=" + maxReplicasPerNode +
               " was specified, cannot determine the correct replica count in policy: " + clauses +
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java b/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
index 62d5c68..ba6abd6 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/CollectionAdminParams.java
@@ -129,6 +129,6 @@ public interface CollectionAdminParams {
   String FOLLOW_ALIASES = "followAliases";
 
   /** Prefix for automatically created config elements. */
-  String AUTO_PREFIX = ".auto_";
+  String AUTO_PREFIX = ".AUTOCREATED_";
 
 }