nick-boss-tech commented on code in PR #5347:
URL: https://github.com/apache/solr/pull/5347#discussion_r4637773416
##########
solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc:
##########
@@ -63,6 +63,7 @@ NOTE: If you have defined `ZK_HOST` in
`solr.in.sh`/`solr.in.cmd` (see xref:zook
When starting Solr in SolrCloud mode, if you do not define `ZK_HOST` in
`solr.in.sh`/`solr.in.cmd` nor specify the `-z` option, then Solr will launch
an embedded ZooKeeper server listening on the Solr port + 1000.
For example, if Solr is running on port 8983, then the embedded ZooKeeper will
listen on port 9983.
+To use a different port, set `SOLR_ZOOKEEPER_EMBEDDED_PORT` in
`solr.in.sh`/`solr.in.cmd` (or the `-Dsolr.zookeeper.embedded.port` system
property).
Review Comment:
🤖 *AI text below* 🤖
Could we either support this specific `-D` option for `start -e secure` or
say that the secure example requires the environment-variable form? The
launcher forwards `-D` as an example argument, but `runSecureExample` rejects
all extra arguments before it gets to the port resolver. The same option works
on a plain start.
##########
solr/core/src/java/org/apache/solr/cli/RunExampleTool.java:
##########
@@ -1581,6 +1585,12 @@ Map<String, Object> startSolr(
if (zkHost != null) {
command.add("-z");
command.add(zkHost);
+ } else if (cloudMode) {
+ // this node starts the embedded ZooKeeper, so pass on an explicitly
configured port
+ Integer embeddedZkPort = SolrZkServer.getConfiguredClientPort();
+ if (embeddedZkPort != null) {
+ command.add("-D" + SolrZkServer.EMBEDDED_ZK_PORT_PROPERTY + "=" +
embeddedZkPort);
Review Comment:
🤖 *AI text below* 🤖
Could we check the effective ZooKeeper client port against the planned Solr
listeners before launching node 1? For the default two-node cloud example,
`7574` is accepted as an embedded ZooKeeper port, but it is also node 2’s HTTP
port. Node 1 can start and bind ZooKeeper there, then node 2 fails at the
port-conflict check, leaving node 1 running. A test should assert that an
overlap is rejected before any child starts. The secure example can do the same
check before resetting its example home.
##########
solr/bin/solr.cmd:
##########
@@ -973,8 +974,8 @@ IF "%SOLR_MODE%"=="solrcloud" (
IF NOT "%ZK_HOST%"=="" (
set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -DzkHost=%ZK_HOST%"
) ELSE (
- IF %SOLR_PORT_LISTEN% GTR 64535 (
- set "SCRIPT_ERROR=ZK_HOST is not set and Solr port is
%SOLR_PORT_LISTEN%, which would result in an invalid embedded Zookeeper port!"
+ IF %SOLR_PORT_LISTEN% GTR 64000 (
Review Comment:
🤖 *AI text below* 🤖
Could we validate the new port settings before a restart takes the old node
down? Both launchers run the stop phase before this new ceiling is checked. For
example, a previously valid embedded node on `64200` can be stopped during an
upgrade and then fail to come back, even with no new setting configured.
Retaining the old valid range would avoid that regression. Any remaining
start-only validation should run before the stop phase so a rejected restart
leaves the old node running.
##########
solr/core/src/java/org/apache/solr/cli/RunExampleTool.java:
##########
@@ -668,9 +670,11 @@ void runSecureExample(CloudExampleParams params, boolean
userManaged) throws Exc
+ serverDir.getParent().toAbsolutePath().normalize());
Path tls = home.resolve("tls");
Path include = tls.resolve("solr.in.sh");
- String zkHost = "localhost:" + (port + 1000);
+ int zkPort = SolrZkServer.resolveClientPort(port);
Review Comment:
🤖 *AI text below* 🤖
Could failure cleanup stop only Solr processes this run started?
`startSecureNodes` can start node 1, then fail when node 2’s port is already
owned by another Solr. The `finally` block then runs `stop -p` for both planned
ports. On Unix, when the example PID directory has no matching file, `stop -p`
falls back to a process-list lookup, so it can stop that other Solr instance.
Track the PIDs started here and clean up only those; a preflight check alone
still leaves a race.
##########
solr/core/src/java/org/apache/solr/cli/RunExampleTool.java:
##########
@@ -668,9 +670,11 @@ void runSecureExample(CloudExampleParams params, boolean
userManaged) throws Exc
+ serverDir.getParent().toAbsolutePath().normalize());
Path tls = home.resolve("tls");
Path include = tls.resolve("solr.in.sh");
- String zkHost = "localhost:" + (port + 1000);
+ int zkPort = SolrZkServer.resolveClientPort(port);
+ String zkHost = "localhost:" + zkPort;
Map<String, String> environment = new
HashMap<>(EnvironmentUtils.getProcEnvironment());
environment.put("SOLR_INCLUDE", include.toString());
+ environment.put("SOLR_ZOOKEEPER_EMBEDDED_PORT", Integer.toString(zkPort));
Review Comment:
🤖 *AI text below* 🤖
Could we persist the effective port in the generated `tls/solr.in.sh` (or
the generated ZooKeeper configuration) rather than only in these child
environments? If the example is started with a one-shot env or JVM override, a
later restart of node 1 using the generated include alone reverts to `Solr port
+ 1000`, while node 2 still has the original connection string.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]