Skip to content

SOLR-18336: bin/solr.cmd start should wait only for the started Solr instance - #4710

Open
janhoy wants to merge 5 commits into
apache:mainfrom
janhoy:fix-windows-start-wait-all-pids
Open

SOLR-18336: bin/solr.cmd start should wait only for the started Solr instance#4710
janhoy wants to merge 5 commits into
apache:mainfrom
janhoy:fix-windows-start-wait-all-pids

Conversation

@janhoy

@janhoy janhoy commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes https://issues.apache.org/jira/browse/SOLR-18336

The Windows start script now passes -p <port> to SolrCLI status, so the start wait targets only the newly started instance instead of every PID file found.

The status tool resolves the instance's URL from the running process's own command line: it prefers -Dsolr.host.advertise when set, falls back to a non-loopback -Dsolr.host.bind, and maps loopback/wildcard binds to localhost. Since the process may not be visible in the process table immediately after launch, the tool re-scans until the --max-wait-secs deadline instead of failing on the first miss.

This gives the same behavior as 9.x, which built --solr-url from SOLR_HOST (the advertised host) when set, else localhost: the wait connects to the advertised name — so SSL hostname verification against certificates issued for that name keeps working — and non-loopback binds (SOLR_HOST_BIND=10.0.x.x) no longer fail with a localhost connection error. As a bonus, bin/solr status now prints reachable URLs for such nodes too.

PS: The Linux start script does not use SolrCLI for waiting for Solr, thus it was never affected. With these hardenings, we are perhaps soon ready to migrate the linux start script over to StatusTool as well.

On Windows, 'solr.cmd start' invoked 'status --max-wait-secs' without
identifying the instance just started, causing the status tool to scan
the PID directory and wait for every running Solr instance. Pass the
port so only the newly started instance is waited for, matching the
behavior of bin/solr on Linux. The status tool resolves the URL scheme
(http/https) from the running process itself.
@janhoy
janhoy marked this pull request as draft August 4, 2026 23:25
@epugh

epugh commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Seems reasonable.. and I guess a bats test woudn't have caught this since it's windows only...

janhoy added 4 commits August 5, 2026 10:42
With SOLR_HOST_BIND set to a non-loopback address, Jetty does not listen
on localhost, so the status tool could not reach the instance when
waiting for startup. Parse the bind host from the process command line
(like port and SSL already are) and use it in the local URL. Wildcard
and loopback bind addresses still map to localhost, preserving existing
URLs for default installs and keeping SSL hostname verification working
with certificates issued for localhost.
The status tool's -p wait now re-scans for the process until the deadline
instead of failing if the newly started process is not yet visible.
The local URL for a process now prefers -Dsolr.host.advertise when set,
falling back to the bind host, matching pre-10 behavior for non-loopback
binds with SSL certificates issued for the advertised hostname.
…Port

Collapse three near-identical sysprop-parsing pipelines into one helper,
dropping the unreachable -Dsolr.jetty.host fallback (10.x scripts always
translate the deprecated name to solr.host.bind before launch). Move the
process wait loop into SolrProcessManager.waitForProcessOnPort, reusing
the TimeOut utility. Start mock test processes in parallel.
@janhoy janhoy changed the title Fix bin/solr.cmd start waiting for all running Solr instances SOLR-18336: bin/solr.cmd start should wait only for the started Solr instance Aug 5, 2026
@janhoy
janhoy marked this pull request as ready for review August 5, 2026 15:11
@github-actions github-actions Bot added the tests label Aug 5, 2026
@janhoy
janhoy requested a review from epugh August 5, 2026 15:17

@epugh epugh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks great. I think my one problem is that we're solving windows issues in our java code, but we don't have great testing in our windows path... I'd love, if we believe this is viable code, and it appears to be, to apply this to the linux path as well, that way if bugs crop up, the theory is we'll see and fix them tjhat much sooner. For example, we could use a bats test if we wanted...

Comment thread solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java
Comment thread solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java
Comment thread solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java
Comment thread solr/core/src/java/org/apache/solr/cli/StatusTool.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants