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

epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 65e7bced3cb SOLR-18630: Default wait for ZooKeeper at node startup is 
30000 seconds instead of 30 (#5313)
65e7bced3cb is described below

commit 65e7bced3cb5bb0a93039ebe0017e3338af50ebc
Author: Julian Chandra Sutadi <[email protected]>
AuthorDate: Sun Nov 22 06:16:43 2026 +0700

    SOLR-18630: Default wait for ZooKeeper at node startup is 30000 seconds 
instead of 30 (#5313)
---
 changelog/unreleased/SOLR-18630-wait-for-zk.yml        | 10 ++++++++++
 solr/bin/solr.in.cmd                                   |  5 +----
 solr/bin/solr.in.sh                                    |  5 +----
 .../core/src/java/org/apache/solr/core/NodeConfig.java | 14 ++++----------
 .../src/test/org/apache/solr/cloud/ZkFailoverTest.java | 10 ++--------
 .../src/test/org/apache/solr/core/TestSolrXml.java     | 18 ++++++++++++++++++
 .../modules/cross-dc/src/test-files/mirroring-solr.xml |  2 +-
 solr/modules/cuvs/src/test-files/solr/solr.xml         |  2 +-
 solr/server/solr/solr.xml                              |  2 +-
 .../pages/configuring-solr-xml.adoc                    |  2 +-
 .../configuration-guide/pages/solr-properties.adoc     |  4 +---
 .../DeprecatedSystemPropertyMappings.properties        |  1 -
 .../test/org/apache/solr/common/util/EnvUtilsTest.java |  8 ++++++++
 13 files changed, 49 insertions(+), 34 deletions(-)

diff --git a/changelog/unreleased/SOLR-18630-wait-for-zk.yml 
b/changelog/unreleased/SOLR-18630-wait-for-zk.yml
new file mode 100644
index 00000000000..11c00f53e8d
--- /dev/null
+++ b/changelog/unreleased/SOLR-18630-wait-for-zk.yml
@@ -0,0 +1,10 @@
+title: >-
+  Fix the default ZooKeeper startup timeout to use milliseconds and make the
+  shipped solr.xml honor solr.zookeeper.client.timeout.
+type: fixed
+authors:
+  - name: Julian Chandra Sutadi
+    nick: julianchandras
+links:
+  - name: SOLR-18630
+    url: https://issues.apache.org/jira/browse/SOLR-18630
diff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmd
index cc488390828..8f8fcaac72b 100755
--- a/solr/bin/solr.in.cmd
+++ b/solr/bin/solr.in.cmd
@@ -61,16 +61,13 @@ REM set ZK_HOST=
 REM Set to true if your ZK host has a chroot path, and you want to create it 
automatically.
 REM set ZK_CREATE_CHROOT=true
 
-REM Set the ZooKeeper client timeout (for SolrCloud mode)
+REM Set the ZooKeeper client timeout in milliseconds
 REM set ZK_CLIENT_TIMEOUT=30000
 
 REM By default the start script uses "localhost"; override the hostname here
 REM for production SolrCloud environments to control the hostname exposed to 
cluster state
 REM set SOLR_HOST_ADVERTISE=192.168.1.1
 
-REM By default Solr will try to connect to Zookeeper with 30 seconds in 
timeout; override the timeout if needed
-REM set SOLR_CLOUD_WAIT_FOR_ZK_SECONDS=30
-
 REM By default Solr will log a warning for cores that are not registered in 
Zookeeper at startup
 REM but otherwise ignore them. This protects against misconfiguration (e.g. 
connecting to the
 REM wrong Zookeeper instance or chroot), however you need to manually delete 
the cores if
diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.sh
index 569066fede4..672329015c3 100644
--- a/solr/bin/solr.in.sh
+++ b/solr/bin/solr.in.sh
@@ -67,16 +67,13 @@
 # Set to true if your ZK host has a chroot path, and you want to create it 
automatically.
 #ZK_CREATE_CHROOT=true
 
-# Set the ZooKeeper client timeout (for SolrCloud mode)
+# Set the ZooKeeper client timeout in milliseconds
 #ZK_CLIENT_TIMEOUT="30000"
 
 # By default the start script uses "localhost"; override the hostname here
 # for production SolrCloud environments to control the hostname exposed to 
cluster state
 #SOLR_HOST_ADVERTISE="192.168.1.1"
 
-# By default Solr will try to connect to Zookeeper with 30 seconds in timeout; 
override the timeout if needed
-#SOLR_CLOUD_WAIT_FOR_ZK_SECONDS="30"
-
 # By default Solr will log a warning for cores that are not registered in 
Zookeeper at startup
 # but otherwise ignore them. This protects against misconfiguration (e.g. 
connecting to the
 # wrong Zookeeper instance or chroot), however you need to manually delete the 
cores if
diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java 
b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
index bde3d6932d1..a477339a4a2 100644
--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java
@@ -35,7 +35,6 @@ import org.apache.lucene.search.IndexSearcher;
 import org.apache.solr.api.ClusterPluginsSource;
 import org.apache.solr.api.ContainerPluginsRegistry;
 import org.apache.solr.api.NodeConfigClusterPluginsSource;
-import org.apache.solr.client.solrj.impl.SolrZkClientTimeout;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.cloud.SolrZkClient;
@@ -239,21 +238,16 @@ public class NodeConfig {
     initModules(loader, null);
     nodeProperties = 
SolrXmlConfig.wrapAndSetZkHostFromSysPropIfNeeded(nodeProperties);
 
-    // TODO: Only job of this block is to
-    //  delay starting a solr core to satisfy
-    //  ZkFailoverTest test case...
     String zkHost = nodeProperties.getProperty(SolrXmlConfig.ZK_HOST);
     if (StrUtils.isNotNullOrEmpty(zkHost)) {
-      int startUpZkTimeOut =
-          1000
-              * Integer.getInteger(
-                  "solr.cloud.wait.for.zk.seconds", 
SolrZkClientTimeout.DEFAULT_ZK_CLIENT_TIMEOUT);
+      int startUpZkTimeOutMillis =
+          EnvUtils.getPropertyAsInteger("solr.zookeeper.client.timeout", 
30_000);
 
       try (SolrZkClient zkClient =
           new SolrZkClient.Builder()
               .withUrl(zkHost)
-              .withTimeout(startUpZkTimeOut, TimeUnit.MILLISECONDS)
-              .withConnTimeOut(startUpZkTimeOut, TimeUnit.MILLISECONDS)
+              .withTimeout(startUpZkTimeOutMillis, TimeUnit.MILLISECONDS)
+              .withConnTimeOut(startUpZkTimeOutMillis, TimeUnit.MILLISECONDS)
               .withSolrClassLoader(loader)
               .build()) {
         zkClient.exists("/configs");
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkFailoverTest.java 
b/solr/core/src/test/org/apache/solr/cloud/ZkFailoverTest.java
index 36febd0495c..5fbbac46bf6 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkFailoverTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkFailoverTest.java
@@ -24,7 +24,6 @@ import org.apache.solr.client.solrj.request.SolrQuery;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.embedded.JettySolrRunner;
-import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,11 +42,6 @@ public class ZkFailoverTest extends SolrCloudTestCase {
         .configure();
   }
 
-  @AfterClass
-  public static void resetWaitForZk() {
-    System.setProperty("solr.cloud.wait.for.zk.seconds", "30");
-  }
-
   public void testRestartZkWhenClusterDown() throws Exception {
     String coll = "coll1";
     CollectionAdminRequest.createCollection(coll, 2, 
1).process(cluster.getSolrClient());
@@ -56,12 +50,12 @@ public class ZkFailoverTest extends SolrCloudTestCase {
     zkTestServer = cluster.getZkServer();
 
     // This attempt will fail since it will time out after 1 second
-    System.setProperty("solr.cloud.wait.for.zk.seconds", "1");
+    System.setProperty("solr.zookeeper.client.timeout", "1000");
     restartSolrAndZk();
     waitForState("Timeout waiting for 0 live nodes", coll, (liveNodes, c) -> 
liveNodes.isEmpty());
 
     // This attempt will succeed since there will be enough time to connect
-    System.setProperty("solr.cloud.wait.for.zk.seconds", "20");
+    System.setProperty("solr.zookeeper.client.timeout", "20000");
     restartSolrAndZk();
     waitForState(
         "Timeout waiting for all nodes to come up",
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 8aa23659c7f..3607d3d8880 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
@@ -34,12 +34,14 @@ import org.apache.solr.api.ContainerPluginsRegistry;
 import org.apache.solr.cloud.ClusterSingleton;
 import org.apache.solr.cluster.placement.plugins.AffinityPlacementFactory;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.EnvUtils;
 import org.apache.solr.search.CacheConfig;
 import org.apache.solr.search.CaffeineCache;
 import org.apache.solr.search.SolrCache;
 import org.apache.solr.search.TestThinCache;
 import org.apache.solr.search.ThinCache;
 import org.apache.solr.update.UpdateShardHandlerConfig;
+import org.apache.solr.util.ExternalPaths;
 import org.junit.Before;
 import org.junit.Ignore;
 
@@ -181,6 +183,22 @@ public class TestSolrXml extends SolrTestCaseJ4 {
     assertFalse("schema cache", cfg.hasSchemaCache());
   }
 
+  public void testShippedSolrXmlUsesZkClientTimeoutProperty() {
+    EnvUtils.setProperty("solr.zookeeper.client.timeout", "45000");
+    NodeConfig cfg =
+        SolrXmlConfig.fromFile(
+            solrHome, ExternalPaths.SERVER_HOME.resolve("solr.xml"), new 
Properties());
+    assertEquals(45000, cfg.getCloudConfig().getZkClientTimeout());
+  }
+
+  public void testShippedSolrXmlZkClientTimeoutDefault() {
+    System.clearProperty("solr.zookeeper.client.timeout");
+    NodeConfig cfg =
+        SolrXmlConfig.fromFile(
+            solrHome, ExternalPaths.SERVER_HOME.resolve("solr.xml"), new 
Properties());
+    assertEquals(30000, cfg.getCloudConfig().getZkClientTimeout());
+  }
+
   public void testNodeLevelCache() {
     NodeConfig cfg =
         SolrXmlConfig.fromString(createTempDir(), 
TestThinCache.SOLR_NODE_LEVEL_CACHE_XML);
diff --git a/solr/modules/cross-dc/src/test-files/mirroring-solr.xml 
b/solr/modules/cross-dc/src/test-files/mirroring-solr.xml
index 68355872852..b577094dc6a 100644
--- a/solr/modules/cross-dc/src/test-files/mirroring-solr.xml
+++ b/solr/modules/cross-dc/src/test-files/mirroring-solr.xml
@@ -21,7 +21,7 @@
     <solrcloud>
         <str name="host">${solr.host.advertise:}</str>
         <int name="hostPort">${solr.port.advertise:0}</int>
-        <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
+        <int 
name="zkClientTimeout">${solr.zookeeper.client.timeout:30000}</int>
         <int 
name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
         <int 
name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
         <str 
name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
diff --git a/solr/modules/cuvs/src/test-files/solr/solr.xml 
b/solr/modules/cuvs/src/test-files/solr/solr.xml
index 6a7a1ff36c2..bea3624ec6f 100644
--- a/solr/modules/cuvs/src/test-files/solr/solr.xml
+++ b/solr/modules/cuvs/src/test-files/solr/solr.xml
@@ -30,7 +30,7 @@
   <solrcloud>
     <str name="host">127.0.0.1</str>
     <int name="hostPort">${hostPort:8983}</int>
-    <int name="zkClientTimeout">${solr.zkclienttimeout:30000}</int>
+    <int name="zkClientTimeout">${solr.zookeeper.client.timeout:30000}</int>
     <int name="leaderVoteWait">${leaderVoteWait:10000}</int>
     <int 
name="distribUpdateConnTimeout">${distribUpdateConnTimeout:45000}</int>
     <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:340000}</int>
diff --git a/solr/server/solr/solr.xml b/solr/server/solr/solr.xml
index bfc74a30156..4dcac14e2b1 100644
--- a/solr/server/solr/solr.xml
+++ b/solr/server/solr/solr.xml
@@ -42,7 +42,7 @@
     <str name="host">${solr.host.advertise:}</str>
     <int name="hostPort">${solr.port.advertise:0}</int>
 
-    <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
+    <int name="zkClientTimeout">${solr.zookeeper.client.timeout:30000}</int>
     <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
     <int 
name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
     <str 
name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
diff --git 
a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc
 
b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc
index bc22a2ed2f5..90b945f0e0f 100644
--- 
a/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc
+++ 
b/solr/solr-ref-guide/modules/configuration-guide/pages/configuring-solr-xml.adoc
@@ -45,7 +45,7 @@ The default `solr.xml` file is found in 
`$SOLR_TIP/server/solr/solr.xml` and loo
     <str name="host">${solr.host.advertise:}</str>
     <int name="hostPort">${solr.port.advertise:0}</int>
 
-    <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
+    <int name="zkClientTimeout">${solr.zookeeper.client.timeout:30000}</int>
     <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
     <int 
name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
     <str 
name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
diff --git 
a/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc 
b/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc
index 20fbfc09fb3..877821cb954 100644
--- a/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc
+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc
@@ -46,8 +46,6 @@ NOTE: Properties marked with "!" indicate inverted meaning 
between pre Solr 10 a
 
 |solr.cloud.delete.unknown.cores.enabled| |false|Controls deletion of 
preexisting core data when a core is created in SolrCloud mode.
 
-|solr.cloud.wait.for.zk.seconds|waitForZk|30|Specifies the number of seconds 
to wait for ZooKeeper connection in SolrCloud mode.
-
 |solr.configset.bootstrap.confdir|bootstrap_confdir||Defines the directory of 
a configuration to be loaded as a configset when starting Solr. Often ends in 
`/conf`.
 
 |solr.configset.bootstrap.config.name|collection.configName||Specifies the 
configuration name for the bootstrapped configset. Use with 
"solr.configset.bootstrap.confdir".
@@ -124,7 +122,7 @@ NOTE: Properties marked with "!" indicate inverted meaning 
between pre Solr 10 a
 
 |solr.zookeeper.client.connect.timeout|zkConnectTimeout|15 seconds.|How long 
before timing out opening connection to ZooKeeper.
 
-|solr.zookeeper.client.timeout|zkClientTimeout|30 seconds.|How long before 
timing out connection to ZooKeeper.
+|solr.zookeeper.client.timeout|zkClientTimeout|30000 milliseconds.|Default 
ZooKeeper client session timeout. Also sets the connection and session timeouts 
for the ZooKeeper check during node startup.
 
 |solr.zookeeper.chroot.create|createZkChroot|false|Controls whether a 
ZooKeeper chroot is created if it doesn't exist.
 
diff --git 
a/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties 
b/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties
index 67d443be564..3603b0651d1 100644
--- a/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties
+++ b/solr/solrj/src/resources/DeprecatedSystemPropertyMappings.properties
@@ -20,7 +20,6 @@ 
solr.cloud.shardsplit.checkdiskspace.enabled=solr.shard.split.check.disk.space.e
 
solr.cloud.prep.recovery.read.timeout.additional.ms=prep.recovery.read.timeout.extra.wait
 solr.cloud.prs.enabled=solr.prs.default
 solr.cloud.startup.delete.unknown.cores.enabled=solr.delete.unknown.cores
-solr.cloud.wait.for.zk.seconds=solr.wait.for.zk
 
 solr.configset.bootstrap.confdir=bootstrap_confdir
 solr.configset.bootstrap.config.name=collection.configName
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java 
b/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java
index 2d425c5fe18..a1b15a270c4 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java
@@ -118,6 +118,14 @@ public class EnvUtilsTest extends SolrTestCase {
     assertEquals("xml,json,jar", 
EnvUtils.getProperty("solr.configset.forbidden.file.types"));
   }
 
+  @Test
+  public void deprecatedZkClientTimeoutIsMigratedToCurrentName() {
+    Properties sysprops = new Properties();
+    sysprops.setProperty("zkClientTimeout", "45000");
+    EnvUtils.init(false, Map.of(), sysprops);
+    assertEquals("45000", 
EnvUtils.getProperty("solr.zookeeper.client.timeout"));
+  }
+
   @Test
   public void deprecatedCamelCaseSystemPropertyIsMigratedToCurrentName() {
     Properties sysprops = new Properties();

Reply via email to