SOLR-18665: Make the start readiness wait work for TLS setups #5368
Automated PR readiness judgements (LLM-generated; may be wrong; not updated on later pushes).
<!-- Assessed commit 196f8e7bd912754731f42bf671c7c559ff041ddd -->
waitForSolrUp(pidUrl, maxWaitSecs) can exceed maxWaitSecs and still return true due to unconditional sleeps (2s polling sleep and 3s UNREACHABLE_GRACE_MS). With small maxWaitSecs values this violates the method’s implied contract (wait up to max, then return false if not up). Consider computing remaining time each loop and bounding sleeps to the remaining deadline; also ensure the 'unreachable => assume started' path only triggers if there is enough remaining time (or return based on the deadline rather than a fixed sleep).
The substring(a.indexOf('=') + 1) assumes an '=' is present. If an argument ever matches the startsWith filter unexpectedly (or the prefix changes), indexOf('=') could be -1, producing the full string as the 'host' (e.g., -Dsolr.host.advertise), which would later generate invalid URLs. Safer parsing would remove the known prefix via its length (or explicitly validate indexOf('=') >= 0 / contains('=')) before substring extraction.
This broad catch (Exception e) causes all non-auth exceptions to be retried until timeout, which can mask non-transient errors (e.g., malformed URL/URI parsing errors, misconfiguration) and turn them into a silent false return. Consider rethrowing immediately for clearly non-retryable exceptions (or only retrying for network/IO-category failures) so genuine configuration/usage errors fail fast instead of timing out.
[!WARNING]
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add acopilot-code-review.ymlfile specifying one with theruns-onattribute. See the docs for more details.
<!-- ccr-overview-v2 -->
Copilot review overview
<details open>
<summary><strong>3 open issues</strong></summary>
waitForSolrUp(pidUrl, maxWaitSecs) can exceed maxWaitSecs and still return true due to… · Newsubstring(a.indexOf('=') + 1) assumes an '=' is present. If an argument ever matches the… · Newcatch (Exception e) causes all non-auth exceptions to be retried until timeout,… · New</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Updates Solr CLI startup readiness checks to work correctly with TLS/SNI and certain mTLS setups by probing the node’s advertised host instead of localhost, and by treating “listening but unreachable” as started after a short grace period.
Changes:
SolrProcess to carry an advertised host and use it to build the local base URL.| File | Description |
| ---- | ----------- |
| solr/core/src/java/org/apache/solr/cli/StatusTool.java | Reworks waitForSolrUp polling logic; adds “listening but unreachable” handling and a grace wait. |
| solr/core/src/java/org/apache/solr/cli/SolrProcessManager.java | Parses -Dsolr.host.advertise from process args; extends SolrProcess with host and updates URL building. |
| solr/core/src/test/org/apache/solr/cli/StatusToolWaitTest.java | New tests for readiness wait when the port accepts connections but never returns HTTP, and for timeout when not listening. |
| solr/core/src/test/org/apache/solr/cli/SolrProcessManagerTest.java | Updates tests to validate advertised host propagation and IPv6 host formatting. |
| solr/bin/solr | Surfaces StatusTool WARNING lines from bin/solr start readiness check output. |
</details>
<sub>Review effort: Lite</sub>
I actually gave up on SNI support and left it as a todo on the pr to secure zookeeper! I didn't realize we had this seperate address from Localhost and the code was getting messier. I will reevaluate based on this work.
The overshoot is bounded to one poll interval plus the grace period, and the grace only applies once the port was seen listening before the deadline, so returning true there is intended.
This keeps the retry-on-any-non-auth-error behaviour of the existing waitToSeeSolrUp; during startup SolrJ's error types don't separate transient from permanent reliably enough to fail fast safely.
I have put both this and #4710 into Draft mode and backtrack a bit. Moving the readiness checks into Java seemed as a good idea in the beginning, as CMD had been doing it for a while. But then the TLS issue complicates things and adds quite a lot of intricate code to Process Manager, which I believe comes with a smell.
So I'm pausing this for a while, which unfortunately leaves things in a state where the startup is not correct when using TLS.
Trying a different approach in a new PR, where I combine this and #4710 (SOLR-18336) into one PR since they are overlapping, and keeping more of the logic in bin/solr[.cmd]. Please see #5389 for the new, simpler, slimmer attempt
Double points for moving back to DRAFT. Sometimes it just doesn't work!
janhoy
https://issues.apache.org/jira/browse/SOLR-18665
Follow-up to #5358. Its readiness wait polls
https://localhost:<port>, sobin/solr startfails after 180s on TLS nodes that refuse that request (CATSSslTestfailure on #5323).solr.host.advertiseinstead oflocalhost, so SNI host check passes.Verified with all
SslTestcases on bash, including the@AwaitsFixmTLS ones.