mirror of https://github.com/apache/lucene.git
SOLR-12665: Autoscaling policy not being refreshed due to caching
This commit is contained in:
parent
f3339d14c9
commit
a059c944c1
|
@ -235,6 +235,8 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-12470: Search Rate Trigger multiple bug fixes, improvements and documentation updates. (ab)
|
* SOLR-12470: Search Rate Trigger multiple bug fixes, improvements and documentation updates. (ab)
|
||||||
|
|
||||||
|
* SOLR-12665: Autoscaling policy not being refreshed due to caching (noble)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,20 @@ public class TestPolicyCloud extends SolrCloudTestCase {
|
||||||
"{}".getBytes(StandardCharsets.UTF_8), true);
|
"{}".getBytes(StandardCharsets.UTF_8), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateCollection() throws Exception {
|
||||||
|
String commands = "{ set-cluster-policy: [ {cores: '0', node: '#ANY'} ] }"; // disallow replica placement anywhere
|
||||||
|
cluster.getSolrClient().request(createAutoScalingRequest(SolrRequest.METHOD.POST, commands));
|
||||||
|
String collectionName = "testCreateCollection";
|
||||||
|
expectThrows(HttpSolrClient.RemoteSolrException.class,
|
||||||
|
() -> CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1).process(cluster.getSolrClient()));
|
||||||
|
|
||||||
|
CollectionAdminRequest.deleteCollection(collectionName).processAndWait(cluster.getSolrClient(), 60);
|
||||||
|
|
||||||
|
commands = "{ set-cluster-policy: [ {cores: '<2', node: '#ANY'} ] }";
|
||||||
|
cluster.getSolrClient().request(createAutoScalingRequest(SolrRequest.METHOD.POST, commands));
|
||||||
|
CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1).process(cluster.getSolrClient());
|
||||||
|
}
|
||||||
|
|
||||||
public void testDataProviderPerReplicaDetails() throws Exception {
|
public void testDataProviderPerReplicaDetails() throws Exception {
|
||||||
CollectionAdminRequest.createCollection("perReplicaDataColl", "conf", 1, 5)
|
CollectionAdminRequest.createCollection("perReplicaDataColl", "conf", 1, 5)
|
||||||
.process(cluster.getSolrClient());
|
.process(cluster.getSolrClient());
|
||||||
|
|
|
@ -350,7 +350,7 @@ public class AutoScalingConfig implements MapWriter {
|
||||||
public Policy getPolicy() {
|
public Policy getPolicy() {
|
||||||
if (policy == null) {
|
if (policy == null) {
|
||||||
if (jsonMap != null) {
|
if (jsonMap != null) {
|
||||||
policy = new Policy(jsonMap);
|
policy = new Policy(jsonMap, zkVersion);
|
||||||
} else {
|
} else {
|
||||||
policy = new Policy();
|
policy = new Policy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,13 +93,18 @@ public class Policy implements MapWriter {
|
||||||
final List<Preference> clusterPreferences;
|
final List<Preference> clusterPreferences;
|
||||||
final List<Pair<String, Type>> params;
|
final List<Pair<String, Type>> params;
|
||||||
final List<String> perReplicaAttributes;
|
final List<String> perReplicaAttributes;
|
||||||
|
final int zkVersion;
|
||||||
|
|
||||||
public Policy() {
|
public Policy() {
|
||||||
this(Collections.emptyMap());
|
this(Collections.emptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public Policy(Map<String, Object> jsonMap) {
|
public Policy(Map<String, Object> jsonMap) {
|
||||||
|
this(jsonMap, 0);
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Policy(Map<String, Object> jsonMap, int version) {
|
||||||
|
this.zkVersion = version;
|
||||||
int[] idx = new int[1];
|
int[] idx = new int[1];
|
||||||
List<Preference> initialClusterPreferences = ((List<Map<String, Object>>) jsonMap.getOrDefault(CLUSTER_PREFERENCES, emptyList())).stream()
|
List<Preference> initialClusterPreferences = ((List<Map<String, Object>>) jsonMap.getOrDefault(CLUSTER_PREFERENCES, emptyList())).stream()
|
||||||
.map(m -> new Preference(m, idx[0]++))
|
.map(m -> new Preference(m, idx[0]++))
|
||||||
|
@ -150,7 +155,8 @@ public class Policy implements MapWriter {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Policy(Map<String, List<Clause>> policies, List<Clause> clusterPolicy, List<Preference> clusterPreferences) {
|
private Policy(Map<String, List<Clause>> policies, List<Clause> clusterPolicy, List<Preference> clusterPreferences, int version) {
|
||||||
|
this.zkVersion = version;
|
||||||
this.policies = policies != null ? Collections.unmodifiableMap(policies) : Collections.emptyMap();
|
this.policies = policies != null ? Collections.unmodifiableMap(policies) : Collections.emptyMap();
|
||||||
this.clusterPolicy = clusterPolicy != null ? Collections.unmodifiableList(clusterPolicy) : Collections.emptyList();
|
this.clusterPolicy = clusterPolicy != null ? Collections.unmodifiableList(clusterPolicy) : Collections.emptyList();
|
||||||
this.clusterPreferences = clusterPreferences != null ? Collections.unmodifiableList(clusterPreferences) : DEFAULT_PREFERENCES;
|
this.clusterPreferences = clusterPreferences != null ? Collections.unmodifiableList(clusterPreferences) : DEFAULT_PREFERENCES;
|
||||||
|
@ -177,19 +183,19 @@ public class Policy implements MapWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Policy withPolicies(Map<String, List<Clause>> policies) {
|
public Policy withPolicies(Map<String, List<Clause>> policies) {
|
||||||
return new Policy(policies, clusterPolicy, clusterPreferences);
|
return new Policy(policies, clusterPolicy, clusterPreferences, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Policy withClusterPreferences(List<Preference> clusterPreferences) {
|
public Policy withClusterPreferences(List<Preference> clusterPreferences) {
|
||||||
return new Policy(policies, clusterPolicy, clusterPreferences);
|
return new Policy(policies, clusterPolicy, clusterPreferences, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Policy withClusterPolicy(List<Clause> clusterPolicy) {
|
public Policy withClusterPolicy(List<Clause> clusterPolicy) {
|
||||||
return new Policy(policies, clusterPolicy, clusterPreferences);
|
return new Policy(policies, clusterPolicy, clusterPreferences, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Policy withParams(List<String> params) {
|
public Policy withParams(List<String> params) {
|
||||||
return new Policy(policies, clusterPolicy, clusterPreferences);
|
return new Policy(policies, clusterPolicy, clusterPreferences, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Clause> getClusterPolicy() {
|
public List<Clause> getClusterPolicy() {
|
||||||
|
|
|
@ -316,6 +316,7 @@ public class PolicyHelper {
|
||||||
TimeSource timeSource = cloudManager.getTimeSource();
|
TimeSource timeSource = cloudManager.getTimeSource();
|
||||||
synchronized (lockObj) {
|
synchronized (lockObj) {
|
||||||
if (sessionWrapper.status == Status.NULL ||
|
if (sessionWrapper.status == Status.NULL ||
|
||||||
|
sessionWrapper.zkVersion != cloudManager.getDistribStateManager().getAutoScalingConfig().getZkVersion() ||
|
||||||
TimeUnit.SECONDS.convert(timeSource.getTimeNs() - sessionWrapper.lastUpdateTime, TimeUnit.NANOSECONDS) > SESSION_EXPIRY) {
|
TimeUnit.SECONDS.convert(timeSource.getTimeNs() - sessionWrapper.lastUpdateTime, TimeUnit.NANOSECONDS) > SESSION_EXPIRY) {
|
||||||
//no session available or the session is expired
|
//no session available or the session is expired
|
||||||
return createSession(cloudManager);
|
return createSession(cloudManager);
|
||||||
|
@ -408,6 +409,7 @@ public class PolicyHelper {
|
||||||
public Status status;
|
public Status status;
|
||||||
private final SessionRef ref;
|
private final SessionRef ref;
|
||||||
private AtomicInteger refCount = new AtomicInteger();
|
private AtomicInteger refCount = new AtomicInteger();
|
||||||
|
public final long zkVersion;
|
||||||
|
|
||||||
public long getCreateTime() {
|
public long getCreateTime() {
|
||||||
return createTime;
|
return createTime;
|
||||||
|
@ -424,6 +426,9 @@ public class PolicyHelper {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.status = Status.UNUSED;
|
this.status = Status.UNUSED;
|
||||||
this.ref = ref;
|
this.ref = ref;
|
||||||
|
this.zkVersion = session == null ?
|
||||||
|
0 :
|
||||||
|
session.getPolicy().zkVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Policy.Session get() {
|
public Policy.Session get() {
|
||||||
|
|
Loading…
Reference in New Issue