You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Colvin Cowie <co...@gmail.com> on 2019/07/24 14:35:19 UTC

The waitForZk (SOLR_WAIT_FOR_ZK) setting does not work

Hello, I didn't see an existing issue for this in Jira:

The system property *waitForZk* was added in
https://issues.apache.org/jira/browse/SOLR-5129 and is supposed to increase
the timeout for an initial connection to Solr at startup, From the
solr.in.sh:


*# By default Solr will try to connect to Zookeeper with 30 seconds in
timeout; override the timeout if needed#SOLR_WAIT_FOR_ZK="30"*

However, no matter what value you set, timeout still occurs after 30
seconds if Zookeeper is not available, leaving Solr down (*CoreContainer is
either not initialized or shutting down*).

That's because the SolrDispatchFilter does this



*        int startUpZkTimeOut = Integer.getInteger("waitForZk", 30);
startUpZkTimeOut *= 1000;        try (SolrZkClient zkClient = new
SolrZkClient(zkHost, startUpZkTimeOut)) {*

SolrZkClient has a number of different constructors, and makes a
distinction between the general client timeout and the connection timeout,
e.g.


*public SolrZkClient(String zkServerAddress, int zkClientTimeout) {...}
     public SolrZkClient(String zkServerAddress, int zkClientTimeout, int
zkClientConnectTimeout) {...}*

The first of which uses DEFAULT_CLIENT_CONNECT_TIMEOUT (30 seconds) as
the *connection
*timeout.

So in SolrDispatchFilter *new SolrZkClient(zkHost, startUpZkTimeOut) *should
be something more like *new SolrZkClient(zkHost, 30000, startUpZkTimeOut).*

This is on Solr 8.1.1, and AFAIK is present since waitForZk was added in
SOLR-5129.

Thanks
Colvin