You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2019/02/21 08:25:32 UTC

[lucene-solr] branch branch_7x updated (658fbc0 -> a5113ac)

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

ishan pushed a change to branch branch_7x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from 658fbc0  Fix TestPullReplica.testKillLeader
     new 3c6d1ba  SOLR-13248: Autoscaling based replica placement is broken out of the box.
     new a5113ac  SOLR-13248: Adding upgrade notes which explain the problem and the mitigation as well as steps to revert to the old behavior

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 solr/CHANGES.txt                                   | 24 ++++++++++++++++++++++
 .../apache/solr/cloud/api/collections/Assign.java  |  4 ++--
 .../solr/cloud/api/collections/AssignTest.java     | 21 +++++++++++++++----
 .../hadoop/TestSolrCloudWithHadoopAuthPlugin.java  |  1 +
 .../solr/common/cloud/ClusterProperties.java       |  4 ++--
 .../apache/solr/common/cloud/ZkStateReader.java    |  4 +++-
 .../client/solrj/cloud/autoscaling/TestPolicy.java |  6 ++++++
 .../org/apache/solr/cloud/SolrCloudTestCase.java   | 19 +++++++++++++++--
 8 files changed, 72 insertions(+), 11 deletions(-)


[lucene-solr] 02/02: SOLR-13248: Adding upgrade notes which explain the problem and the mitigation as well as steps to revert to the old behavior

Posted by is...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a5113ac1b3859e40424b509737fc1a01467c14b6
Author: shalinmangar <sh...@apache.org>
AuthorDate: Mon Feb 18 13:56:24 2019 -0800

    SOLR-13248: Adding upgrade notes which explain the problem and the mitigation as well as steps to revert to the old behavior
---
 solr/CHANGES.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d1d8271..7bac0c7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -43,6 +43,25 @@ Velocity 1.7 and Velocity Tools 2.0
 Apache ZooKeeper 3.4.13
 Jetty 9.4.14.v20181114
 
+Upgrade Notes
+----------------------
+
+ * SOLR-13248: The default replica placement strategy used in Solr has been reverted to the 'legacy' policy used by Solr
+   7.4 and previous versions. This is due to multiple bugs in the autoscaling based replica placement strategy that was
+   made default in Solr 7.5 which causes multiple replicas of the same shard to be placed on the same node in addition
+   to the maxShardsPerNode and createNodeSet parameters being ignored. Although the default has changed, autoscaling
+   will continue to be used if a cluster policy or preference is specified or a collection level policy is in use.
+   The default replica placement strategy can be changed to use autoscaling again by setting a cluster property:
+   curl -X POST -H 'Content-type:application/json' --data-binary '
+   {
+     "set-obj-property": {
+       "defaults" : {
+         "cluster": {
+           "useLegacyReplicaAssignment":false
+         }
+       }
+     }
+   }' http://$SOLR_HOST:$SOLR_PORT/api/cluster
 
 Bug Fixes
 ----------------------


[lucene-solr] 01/02: SOLR-13248: Autoscaling based replica placement is broken out of the box.

Posted by is...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3c6d1bad756d68bf007edaa0c8e08ff3d5c39147
Author: shalinmangar <sh...@apache.org>
AuthorDate: Mon Feb 18 13:46:05 2019 -0800

    SOLR-13248: Autoscaling based replica placement is broken out of the box.
    
    Solr 7.5 enabled autoscaling based replica placement by default but in the absence of default cluster policies, autoscaling can place more than 1 replica of the  same shard on the same node. Also, the maxShardsPerNode and createNodeSet was not respected. Due to these reasons,  this issue reverts the default replica placement policy to the 'legacy' assignment policy that was the default until Solr 7.4.
---
 solr/CHANGES.txt                                    |  5 +++++
 .../apache/solr/cloud/api/collections/Assign.java   |  4 ++--
 .../solr/cloud/api/collections/AssignTest.java      | 21 +++++++++++++++++----
 .../hadoop/TestSolrCloudWithHadoopAuthPlugin.java   |  1 +
 .../apache/solr/common/cloud/ClusterProperties.java |  4 ++--
 .../org/apache/solr/common/cloud/ZkStateReader.java |  4 +++-
 .../client/solrj/cloud/autoscaling/TestPolicy.java  |  6 ++++++
 .../org/apache/solr/cloud/SolrCloudTestCase.java    | 19 +++++++++++++++++--
 8 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f8b7e10..d1d8271 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -50,6 +50,11 @@ Bug Fixes
 * SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression
   in release 7.7 (noble)
 
+* SOLR-13248: Autoscaling based replica placement is broken out of the box. Solr 7.5 enabled autoscaling based replica
+  placement by default but in the absence of default cluster policies, autoscaling can place more than 1 replica of the
+  same shard on the same node. Also, the maxShardsPerNode and createNodeSet was not respected. Due to these reasons,
+  this issue reverts the default replica placement policy to the 'legacy' assignment policy that was the default until
+  Solr 7.4. (Gus Heck, Andrzej Bialecki, Bram Van Dam, shalin)
 
 ==================  7.7.0 ==================
 
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java
index 318cdf7..cf47ab4 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/Assign.java
@@ -278,12 +278,12 @@ public class Assign {
   }
 
   private static boolean usePolicyFramework(Optional<DocCollection> collection, SolrCloudManager cloudManager) throws IOException, InterruptedException {
-    boolean useLegacyAssignment = false;
+    boolean useLegacyAssignment = true;
     Map<String, Object> clusterProperties = cloudManager.getClusterStateProvider().getClusterProperties();
     if (clusterProperties.containsKey(CollectionAdminParams.DEFAULTS))  {
       Map<String, Object> defaults = (Map<String, Object>) clusterProperties.get(CollectionAdminParams.DEFAULTS);
       Map<String, Object> collectionDefaults = (Map<String, Object>) defaults.getOrDefault(CollectionAdminParams.CLUSTER, Collections.emptyMap());
-      useLegacyAssignment = (boolean) collectionDefaults.getOrDefault(CollectionAdminParams.USE_LEGACY_REPLICA_ASSIGNMENT, false);
+      useLegacyAssignment = Boolean.parseBoolean(collectionDefaults.getOrDefault(CollectionAdminParams.USE_LEGACY_REPLICA_ASSIGNMENT, "true").toString());
     }
 
     if (!useLegacyAssignment) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java
index 638496a..512a397 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java
@@ -158,22 +158,35 @@ public class AssignTest extends SolrTestCaseJ4 {
   }
 
   @Test
-  public void testUsePolicyByDefault() throws Exception {
+  public void testUseLegacyByDefault() throws Exception {
     assumeWorkingMockito();
 
     SolrCloudManager solrCloudManager = mock(SolrCloudManager.class);
     ClusterStateProvider clusterStateProvider = mock(ClusterStateProvider.class);
     when(solrCloudManager.getClusterStateProvider()).thenReturn(clusterStateProvider);
+    DistribStateManager distribStateManager = mock(DistribStateManager.class);
+    when(solrCloudManager.getDistribStateManager()).thenReturn(distribStateManager);
+    when(distribStateManager.getAutoScalingConfig()).thenReturn(new AutoScalingConfig(Collections.emptyMap()));
+
+    // first we don't set any cluster property and assert that legacy assignment is used
+    when(clusterStateProvider.getClusterProperties()).thenReturn(Collections.emptyMap());
+    // verify
+    boolean usePolicyFramework = Assign.usePolicyFramework(solrCloudManager);
+    assertFalse(usePolicyFramework);
+    // another sanity check
+    when(clusterStateProvider.getClusterProperties()).thenReturn(Utils.makeMap("defaults", Collections.emptyMap()));
+    // verify
+    usePolicyFramework = Assign.usePolicyFramework(solrCloudManager);
+    assertFalse(usePolicyFramework);
+
     // first we set useLegacyReplicaAssignment=false, so autoscaling should always be used
     when(clusterStateProvider.getClusterProperties()).thenReturn(Utils.makeMap("defaults", Utils.makeMap("cluster", Utils.makeMap("useLegacyReplicaAssignment", false))));
     // verify
-    boolean usePolicyFramework = Assign.usePolicyFramework(solrCloudManager);
+    usePolicyFramework = Assign.usePolicyFramework(solrCloudManager);
     assertTrue(usePolicyFramework);
 
     // now we set useLegacyReplicaAssignment=true, so autoscaling can only be used if an explicit policy or preference exists
     when(clusterStateProvider.getClusterProperties()).thenReturn(Utils.makeMap("defaults", Utils.makeMap("cluster", Utils.makeMap("useLegacyReplicaAssignment", true))));
-    DistribStateManager distribStateManager = mock(DistribStateManager.class);
-    when(solrCloudManager.getDistribStateManager()).thenReturn(distribStateManager);
     when(distribStateManager.getAutoScalingConfig()).thenReturn(new AutoScalingConfig(Collections.emptyMap()));
     assertFalse(Assign.usePolicyFramework(solrCloudManager));
 
diff --git a/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java b/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java
index 118dc47..08a79f2 100644
--- a/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java
+++ b/solr/core/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithHadoopAuthPlugin.java
@@ -50,6 +50,7 @@ public class TestSolrCloudWithHadoopAuthPlugin extends SolrCloudTestCase {
     configureCluster(NUM_SERVERS)// nodes
         .withSecurityJson(TEST_PATH().resolve("security").resolve("hadoop_kerberos_config.json"))
         .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
+        .withDefaultClusterProperty("useLegacyReplicaAssignment", "false")
         .configure();
   }
 
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
index 21d1298..96e5371 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
@@ -149,11 +149,11 @@ public class ClusterProperties {
    * This method sets a cluster property.
    *
    * @param propertyName  The property name to be set.
-   * @param propertyValue The value of the property.
+   * @param propertyValue The value of the property, could also be a nested structure.
    * @throws IOException if there is an error writing data to the cluster
    */
   @SuppressWarnings("unchecked")
-  public void setClusterProperty(String propertyName, String propertyValue) throws IOException {
+  public void setClusterProperty(String propertyName, Object propertyValue) throws IOException {
 
     validatePropertyName(propertyName);
 
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 1a26451..7a3f7d2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -50,6 +50,7 @@ import org.apache.solr.common.Callable;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.params.AutoScalingParams;
+import org.apache.solr.common.params.CollectionAdminParams;
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.util.ExecutorUtil;
 import org.apache.solr.common.util.ObjectReleaseTracker;
@@ -239,7 +240,8 @@ public class ZkStateReader implements Closeable {
       URL_SCHEME,
       AUTO_ADD_REPLICAS,
       CoreAdminParams.BACKUP_LOCATION,
-      MAX_CORES_PER_NODE)));
+      MAX_CORES_PER_NODE,
+      CollectionAdminParams.DEFAULTS)));
 
   /**
    * Returns config set name for collection.
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
index fc64b11..c46eadf 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
@@ -58,6 +58,7 @@ import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.ReplicaPosition;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.cloud.rule.ImplicitSnitch;
+import org.apache.solr.common.params.CollectionAdminParams;
 import org.apache.solr.common.params.CollectionParams;
 import org.apache.solr.common.params.CollectionParams.CollectionAction;
 import org.apache.solr.common.params.SolrParams;
@@ -2609,6 +2610,11 @@ public class TestPolicy extends SolrTestCaseJ4 {
           public ClusterState getClusterState() throws IOException {
             return ClusterState.load(0, clusterState, getLiveNodes(), ZkStateReader.getCollectionPath("c1"));
           }
+
+          @Override
+          public Map<String, Object> getClusterProperties() {
+            return Collections.singletonMap("defaults", Collections.singletonMap("cluster", Collections.singletonMap(CollectionAdminParams.USE_LEGACY_REPLICA_ASSIGNMENT, false)));
+          }
         };
       }
 
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
index 6e2f780..acb09be 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
@@ -52,6 +52,7 @@ import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.params.CollectionAdminParams;
 import org.apache.solr.common.util.NamedList;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -104,7 +105,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
     private Optional<String> securityJson = Optional.empty();
 
     private List<Config> configs = new ArrayList<>();
-    private Map<String, String> clusterProperties = new HashMap<>();
+    private Map<String, Object> clusterProperties = new HashMap<>();
 
     /**
      * Create a builder
@@ -211,13 +212,27 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
 
       if (clusterProperties.size() > 0) {
         ClusterProperties props = new ClusterProperties(cluster.getSolrClient().getZkStateReader().getZkClient());
-        for (Map.Entry<String, String> entry : clusterProperties.entrySet()) {
+        for (Map.Entry<String, Object> entry : clusterProperties.entrySet()) {
           props.setClusterProperty(entry.getKey(), entry.getValue());
         }
       }
       return cluster;
     }
 
+    public Builder withDefaultClusterProperty(String key, String value) {
+      HashMap<String,Object> defaults = (HashMap<String, Object>) this.clusterProperties.get(CollectionAdminParams.DEFAULTS);
+      if (defaults == null) {
+        defaults = new HashMap<>();
+        this.clusterProperties.put(CollectionAdminParams.DEFAULTS, defaults);
+      }
+      HashMap<String,Object> cluster = (HashMap<String, Object>) defaults.get(CollectionAdminParams.CLUSTER);
+      if (cluster == null) {
+        cluster = new HashMap<>();
+        defaults.put(CollectionAdminParams.CLUSTER, cluster);
+      }
+      cluster.put(key, value);
+      return this;
+    }
   }
 
   /** The cluster */