[ 
https://issues.apache.org/jira/browse/SOLR-18138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132712#comment-18132712
 ] 

Nick Shanin commented on SOLR-18138:
------------------------------------

[~epugh] The command in the ticket does not go through 
{{CLIUtils.getSolrZkClient}}. {{bin/solr zk ls}} builds its own client in 
[ZkLsTool.java:111-115|https://github.com/apache/solr/blob/e59ce3c97ddbe030eafadf0623fdcd80c4529c31/solr/core/src/java/org/apache/solr/cli/ZkLsTool.java#L111-L115],
 and 11 other CLI and package-manager sites build clients the same way. A 
change in the shared helper would not change your output.

Two places produce what you saw:

 * The connect timeout is raised in 
[SolrZkClient.java:201-216|https://github.com/apache/solr/blob/e59ce3c97ddbe030eafadf0623fdcd80c4529c31/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/SolrZkClient.java#L201-L216]
 as a {{SolrException}} wrapping {{TimeoutException("Timeout while waiting for 
Zookeeper Client to connect: N ms")}}.
 * Each ZooKeeper tool logs the full exception at ERROR before rethrowing 
([ZkLsTool.java:119|https://github.com/apache/solr/blob/e59ce3c97ddbe030eafadf0623fdcd80c4529c31/solr/core/src/java/org/apache/solr/cli/ZkLsTool.java#L119]).
 That log line is where the stack trace in the ticket comes from. The shared 
error handler in 
[ToolBase.java:157-165|https://github.com/apache/solr/blob/e59ce3c97ddbe030eafadf0623fdcd80c4529c31/solr/core/src/java/org/apache/solr/cli/ToolBase.java#L157-L165]
 prints only the message unless {{--verbose}} is set.

A clearer message needs a change to the message text and to the per-tool log 
line.

Is a clearer CLI message what you want for this ticket?

Possible states for the ticket:

 * Close after a CLI message fix that covers every ZooKeeper tool. There are 
two ways to build it:
 ## Handle it once in {{ToolBase}}. Catch the connect timeout in the shared 
error path, print a message that says ZooKeeper did not answer within the 
configured timeout and that the server it points at may be down, and skip the 
per-tool ERROR trace for that case. The message cannot name the host, because 
{{ToolBase}} does not hold it.
 ## Route all 12 direct client builders through the {{CLIUtils}} helper, which 
takes the host and catches the timeout there, and remove the per-tool trace. 
The message can name the host. This touches 11 files.
 * Keep open for the server-side text. The {{KeeperErrorCode = ConnectionLoss 
for /live_nodes}} from {{bin/solr zk ls -s}} and the {{/aliases.json}} error 
from LISTALIASES are raw ZooKeeper text passed through the admin API. Changing 
them is a separate change to the server's error handling.
 * Split the server-side text into its own ticket.

Recommendation: close after option 1. It is one change in one place, it covers 
every ZooKeeper command, and the host is already on the command line the user 
typed.

🤖 _AI text above_ 🤖 _(reviewed by Nick Shanin)_


> Handle in CLI when Solr hosting ZK is not reachable
> ---------------------------------------------------
>
>                 Key: SOLR-18138
>                 URL: https://issues.apache.org/jira/browse/SOLR-18138
>             Project: Solr
>          Issue Type: Sub-task
>          Components: cli
>            Reporter: Eric Pugh
>            Priority: Minor
>
> I ran bin/solr start -e cloud and was playing around with adding/removing 
> nodes.   It was all working until I stopped the very first solr node I 
> started....   I finally figured out that was because it was the node that was 
> hosting the ZooKeeper!   So, with no ZooKeeper, then lots of things do not 
> work.
> In the admin UI I 
> [http://localhost:9004/solr/admin/collections?_=1772130089267&action=LISTALIASES&wt=json]
>  for example fails.   Though interestingly 
> [http://localhost:9004/solr/admin/collections?_=1772130089267&action=LIST&wt=json]
>  works, because I guess it doesn't consult ZooKeeper?  
>  
> Then I tried 
> bin/solr zk ls -z 127.0.0.1:9983 /
>  
> and got 
> ERROR - 2026-02-26 13:25:45.030; org.apache.solr.cli.ZkLsTool; Could not 
> complete ls operation for reason:  =>org.apache.solr.common.SolrException: 
> java.util.concurrent.TimeoutException: Timeout while waiting for Zookeeper 
> Client to connect: 15000 ms
> at org.apache.solr.common.cloud.SolrZkClient.<init>(SolrZkClient.java:213)
>  
> Using the solr end point is't better:
> bin/solr zk ls -s [http://localhost:9004|http://localhost:9004/] /
>  
> ERROR: Error from server at 
> [http://localhost:9004/solr/admin/collections?action=CLUSTERSTATUS&wt=javabin:]
>  org.apache.zookeeper.KeeperException$ConnectionLossException: 
> KeeperErrorCode = ConnectionLoss for /live_nodes
>  
> I think we could provide a better error message to the user in the CLI.  And, 
> maybe on the LISTALIAS we ought to return a better error than 
> "KeeperErrorCode = ConnectionLoss for /aliases.json"???
>  
>  
> Restarting the first node brings things back to life!
> "bin/solr" start -p 8983 --solr-home "example/cloud/node1/solr" --server-dir 
> "/Users/epugh/Documents/projects/solr/solr/packaging/build/dev/server"
>  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to