You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2018/10/30 10:36:41 UTC
lucene-solr:branch_7x: SOLR-12023: Autoscaling policy engine shuffles
replicas needlessly
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x 788dd4fd3 -> 01c0172f4
SOLR-12023: Autoscaling policy engine shuffles replicas needlessly
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/01c0172f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/01c0172f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/01c0172f
Branch: refs/heads/branch_7x
Commit: 01c0172f40d43bfd2ea292069c385b1188ba5428
Parents: 788dd4f
Author: Noble Paul <no...@apache.org>
Authored: Tue Oct 30 21:35:38 2018 +1100
Committer: Noble Paul <no...@apache.org>
Committed: Tue Oct 30 21:36:23 2018 +1100
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../solrj/cloud/autoscaling/Suggester.java | 8 ++++---
.../org/apache/solr/common/NavigableObject.java | 2 +-
.../solrj/cloud/autoscaling/TestPolicy.java | 25 +++++++++++++-------
4 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/01c0172f/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index fa3f49f..be31fe7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -149,6 +149,8 @@ Bug Fixes
* SOLR-12875: fix ArrayIndexOutOfBoundsException when unique(field) or uniqueBlock(_root_) is
used with DVHASH method in json.facet. (Tim Underwood via Mikhail Khludnev)
+* SOLR-12023: Autoscaling policy engine shuffles replicas needlessly (noble)
+
Improvements
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/01c0172f/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Suggester.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Suggester.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Suggester.java
index bba5906..e4d297e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Suggester.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/autoscaling/Suggester.java
@@ -291,7 +291,11 @@ public abstract class Suggester implements MapWriter {
for (Map.Entry<String, List<ReplicaInfo>> shard : e.getValue().entrySet()) {
if (!isAllowed(new Pair<>(e.getKey(), shard.getKey()), Hint.COLL_SHARD)) continue;//todo fix
if (shard.getValue() == null || shard.getValue().isEmpty()) continue;
- replicaList.add(new Pair<>(shard.getValue().get(0), r));
+ for (ReplicaInfo replicaInfo : shard.getValue()) {
+ if (replicaInfo.getName().startsWith("SYNTHETIC.")) continue;
+ replicaList.add(new Pair<>(shard.getValue().get(0), r));
+ break;
+ }
}
}
}
@@ -303,10 +307,8 @@ public abstract class Suggester implements MapWriter {
List<Violation> errors = new ArrayList<>();
for (Clause clause : session.expandedClauses) {
Clause originalClause = clause.derivedFrom == null ? clause : clause.derivedFrom;
-// if (!executeInStrictMode && !clause.strict) {
if (this.deviations == null) this.deviations = new LinkedHashMap<>();
this.deviations.put(originalClause, new double[1]);
-// }
List<Violation> errs = clause.test(session, this.deviations == null ? null : this.deviations.get(originalClause));
if (!errs.isEmpty() &&
(executeInStrictMode || clause.strict)) errors.addAll(errs);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/01c0172f/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java b/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java
index be50a17..ccef7e2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java
+++ b/solr/solrj/src/java/org/apache/solr/common/NavigableObject.java
@@ -24,7 +24,7 @@ import org.apache.solr.common.util.Utils;
/**This class contains helper methods for navigating deeply nested Objects. Keep in mind that
* it may be expensive depending on the underlying implementation. each level needs an extra lookup
- * and the lookup may be as expensive as O(log(n)) to O(o) depending on the underlying impl
+ * and the lookup may be as expensive as O(log(n)) to O(n) depending on the underlying impl
*
*/
public interface NavigableObject {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/01c0172f/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
----------------------------------------------------------------------
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 7b32567..8dc0c24 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
@@ -1972,16 +1972,25 @@ public class TestPolicy extends SolrTestCaseJ4 {
public void testMoveReplicaSuggester() {
String autoScalingjson = " '{cluster-policy':[" +
- " { 'cores':'<10', 'node':'#ANY'}," +
- " { 'replica':'<2', 'shard':'#EACH', 'node':'#ANY'}," +
- " { 'nodeRole':'overseer','replica':0}]," +
- " 'cluster-preferences':[{'minimize':'cores'}]}";
+ "{'cores':'<10', 'node':'#ANY'}," +
+ "{'replica':'<2', 'shard':'#EACH','node':'#ANY'}]," +
+ "'cluster-preferences':[{'minimize':'cores'}]}";
Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
Policy.Session session = policy.createSession(cloudManagerWithData((Map) loadFromResource("testMoveReplicaSuggester.json")));
- Suggester suggester = session.getSuggester(MOVEREPLICA).hint(Hint.TARGET_NODE, "10.0.0.6:7574_solr");
+ Suggester suggester = session.getSuggester(MOVEREPLICA)
+ .hint(Hint.TARGET_NODE, "10.0.0.6:7574_solr");
SolrRequest op = suggester.getSuggestion();
assertNotNull(op);
- suggester = suggester.getSession().getSuggester(MOVEREPLICA).hint(Hint.TARGET_NODE, "10.0.0.6:7574_solr");
+ suggester = suggester.getSession()
+ .getSuggester(MOVEREPLICA)
+ .hint(Hint.TARGET_NODE, "10.0.0.6:7574_solr");
+ op = suggester.getSuggestion();
+ assertNull(op);
+
+ suggester = suggester.getSession()
+ .getSuggester(MOVEREPLICA)
+ .forceOperation(true)
+ .hint(Hint.TARGET_NODE, "10.0.0.6:8983_solr");
op = suggester.getSuggestion();
assertNull(op);
}
@@ -2183,7 +2192,7 @@ public class TestPolicy extends SolrTestCaseJ4 {
assertEquals(0, violations.get(0).getViolatingReplicas().size());
l = PolicyHelper.getSuggestions(cfg, cloudManagerWithData((Map) loadFromResource("testFreeDiskSuggestions.json")));
- assertEquals(4, l.size());
+ assertEquals(3, l.size());
assertEquals("r4", l.get(0)._get("operation/command/move-replica/replica", null));
assertEquals("node1", l.get(0)._get("operation/command/move-replica/targetNode", null));
@@ -2193,8 +2202,6 @@ public class TestPolicy extends SolrTestCaseJ4 {
assertEquals("r2", l.get(2)._get("operation/command/move-replica/replica", null));
assertEquals("node1", l.get(2)._get("operation/command/move-replica/targetNode", null));
- assertEquals("improvement", l.get(3)._get("type", null));
-
}