You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2021/02/03 05:51:00 UTC
[lucene-solr] branch reference_impl_dev updated: @1315 Tweaks
around leader vote wait (now zkshardterms).
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl_dev by this push:
new 3817f75 @1315 Tweaks around leader vote wait (now zkshardterms).
3817f75 is described below
commit 3817f75942f792d7932312c30b5c09fe49fd3dcd
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Feb 2 23:47:23 2021 -0600
@1315 Tweaks around leader vote wait (now zkshardterms).
---
.../java/org/apache/solr/cloud/ShardLeaderElectionContext.java | 10 +++++-----
solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java | 5 +++++
solr/core/src/java/org/apache/solr/core/CloudConfig.java | 2 +-
solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java | 2 +-
solr/core/src/test/org/apache/solr/core/TestSolrXml.java | 2 +-
.../src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java | 4 ++--
6 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
index 2527512..dab1314 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
@@ -290,7 +290,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
return true;
}
if (replicasWithHigherTermParticipated(zkShardTerms, coreNodeName)) {
- log.info("Can't become leader, other replicas with higher term participated in leader election");
+ log.info("Can't become leader, other replicas with higher term participated in leader election {}", zkShardTerms);
return false;
}
@@ -305,17 +305,17 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
*
* @return true if other replicas with higher term participated in the election, false if otherwise
*/
- private boolean replicasWithHigherTermParticipated(ZkShardTerms zkShardTerms, String coreNodeName) throws InterruptedException {
+ private boolean replicasWithHigherTermParticipated(ZkShardTerms zkShardTerms, String coreName) throws InterruptedException {
ClusterState clusterState = zkController.getClusterState();
DocCollection docCollection = clusterState.getCollectionOrNull(collection);
Slice slices = (docCollection == null) ? null : docCollection.getSlice(shardId);
if (slices == null) return false;
- long replicaTerm = zkShardTerms.getTerm(coreNodeName);
- boolean isRecovering = zkShardTerms.isRecovering(coreNodeName);
+ long replicaTerm = zkShardTerms.getTerm(coreName);
+ boolean isRecovering = zkShardTerms.isRecovering(coreName);
for (Replica replica : slices.getReplicas()) {
- if (replica.getName().equals(coreNodeName)) continue;
+ if (replica.getName().equals(coreName)) continue;
if (zkController.getZkStateReader().getLiveNodes().contains(replica.getNodeName())) {
long otherTerm = zkShardTerms.getTerm(replica.getName());
boolean isOtherReplicaRecovering = zkShardTerms.isRecovering(replica.getName());
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java b/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
index 17ec77e..4e340b4 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java
@@ -80,6 +80,11 @@ public class ZkShardTerms implements Closeable {
private final AtomicReference<ShardTerms> terms = new AtomicReference<>();
+ @Override
+ public String toString() {
+ return "ZkShardTerms{" + "terms=" + terms.get() + '}';
+ }
+
/**
* Listener of a core for shard's term change events
*/
diff --git a/solr/core/src/java/org/apache/solr/core/CloudConfig.java b/solr/core/src/java/org/apache/solr/core/CloudConfig.java
index 8fcbde0..06041e1 100644
--- a/solr/core/src/java/org/apache/solr/core/CloudConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/CloudConfig.java
@@ -133,7 +133,7 @@ public class CloudConfig {
private static final int DEFAULT_ZK_CLIENT_TIMEOUT = 45000;
private static final int DEFAULT_LEADER_VOTE_WAIT = 180000; // 3 minutes
- private static final int DEFAULT_LEADER_CONFLICT_RESOLVE_WAIT = 180000;
+ private static final int DEFAULT_LEADER_CONFLICT_RESOLVE_WAIT = 10000;
private final int DEFAULT_CREATE_COLLECTION_ACTIVE_WAIT = Integer.getInteger("solr.defaultCollectionActiveWait", 45); // 45 seconds
private static final boolean DEFAULT_CREATE_COLLECTION_CHECK_LEADER_ACTIVE = false;
diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
index d488e59..826a4f4 100644
--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
@@ -261,7 +261,7 @@ public class HttpSolrCall {
core = cores.getCore(origCorename);
- if (core == null && cores.isCoreLoading(origCorename)) {
+ if (core == null && !cores.isZooKeeperAware() && cores.isCoreLoading(origCorename)) {
cores.waitForLoadingCore(origCorename, 3000);
}
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
index 5f58416..9910d7c 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
@@ -140,7 +140,7 @@ public class TestSolrXml extends SolrTestCaseJ4 {
NodeConfig cfg = new SolrXmlConfig().fromString(solrHome, solrXml);
assertNull("maxBooleanClauses", cfg.getBooleanQueryMaxClauseCount()); // default is null
- assertEquals("leaderVoteWait", 180000, cfg.getCloudConfig().getLeaderVoteWait());
+ assertEquals("leaderVoteWait", 10000, cfg.getCloudConfig().getLeaderVoteWait());
}
public void testIntAsLongBad() {
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
index fc774f3..a2cfcd1 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
@@ -113,9 +113,9 @@ public class MiniSolrCloudCluster {
" <str name=\"host\">127.0.0.1</str>\n" +
" <int name=\"hostPort\">${hostPort:8983}</int>\n" +
" <str name=\"hostContext\">${hostContext:solr}</str>\n" +
- " <int name=\"zkClientTimeout\">${solr.zkclienttimeout:30000}</int>\n" +
+ " <int name=\"zkClientTimeout\">${solr.zkclienttimeout:15000}</int>\n" +
" <bool name=\"genericCoreNodeNames\">${genericCoreNodeNames:true}</bool>\n" +
- " <int name=\"leaderVoteWait\">${leaderVoteWait:10000}</int>\n" +
+ " <int name=\"leaderVoteWait\">${leaderVoteWait:5000}</int>\n" +
" <int name=\"distribUpdateConnTimeout\">${distribUpdateConnTimeout:45000}</int>\n" +
" <int name=\"distribUpdateSoTimeout\">${distribUpdateSoTimeout:340000}</int>\n" +
" <str name=\"zkCredentialsProvider\">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str> \n" +