openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Solr hangs locally when managed-schema.xml has been modified

Open cdrini opened this issue 5 months ago • 4 comments

Problem

A while back we added a script to auto-delete and reset solr when the managed-schema.xml file was modified. This script appears to have broken in the new version of solr, solr 10. And is now hanging indefinitely, preventing the other services from coming up either.

Likely need to either disable this script or find a way to fix it.

It's hanging in the "until" block of the script.

Reproducing the bug

  1. Go to ...
  2. Do ...
  • Expected behavior:
  • Actual behavior:

Context

  • Browser (Chrome, Safari, Firefox, etc):
  • OS (Windows, Mac, etc):
  • Logged in (Y/N):
  • Environment (prod, dev, local): prod

Breakdown

Implementation Details (for maintainers)

Requirements Checklist

  • [ ]

Related files

Stakeholders


Instructions for Contributors

  • Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.

cdrini avatar Jun 17 '26 16:06 cdrini

⚠️ Contributors, this issue will be ready to work on once:

  • [ ] Triage — maintainers will add Priority: * and Lead: @* to replace Needs: Triage and Needs: Lead

Context

  • File: docker/ol-local-solr-start.sh — added in PR #11902 to auto-rebuild the Solr core when managed-schema.xml changes
  • Hanging line: line 37 — the until curl -s ... | grep -q "200" loop that waits for Solr on a temp port (8989). When Solr 10 cannot read a data volume written by Solr 9, it fails to start; the loop runs forever.
  • Root cause context: PR #12786 (merged) upgraded Solr 9.9 → 10. Solr 10 cannot read Solr 9 data volumes. The schema-diff detection path starts Solr on a temp port with no timeout, and that startup silently hangs.
  • In-flight fix: PR #12795 ("fix(solr): detect version mismatch at startup + make check-solr") wraps the temp Solr start in timeout 60 and prints an actionable error if it times out. It closes the closely related issue #12792, which tracks the same root cause from a slightly different angle (version-mismatch detection).

Issue Assessment

Action items for the author:

  • [ ] Reproducing steps are template placeholders — the minimal repro is: have an existing Solr 9.x data volume, run docker compose pull solr to get the Solr 10 image, then docker compose up solr; the schema diff is detected, the until loop on line 37 hangs indefinitely
  • [ ] Environment: prod is a template artifact — per the issue title this is a local dev environment
Full triage checklist (maintainers / Richy)
  • [x] Triage — existing labels (Type: Bug, Needs: Triage, Needs: Lead, Needs: Breakdown) are correct for current state
  • [x] Problem / opportunity — clearly identifies the affected script and which code block hangs
  • [x] Scope — scoped to one script, one execution path
  • [x] Justification — prevents docker compose up from completing; blocks other services
  • [ ] Success & testing criteria — no explicit success criteria stated
  • [ ] Proposal & breakdown — Needs: Breakdown label is correct; PR #12795 provides a concrete implementation proposal
  • [ ] If bug: environment & repro steps — template not filled in; environment field says "prod" but should be "local dev"
  • [ ] Risks, concerns, open questions — "disable vs fix" is noted but not evaluated; PR #12795 takes the fix approach
  • [x] Richy context — relevant code, commits, and in-flight PRs reviewed; PR #12795 is a direct fix, issue #12792 is closely related
  • [ ] References — no links to the relevant script or related issues in the body

[!NOTE] This comment was automatically generated by Richy, via PAM, Open Library's Project AI Manager, on behalf of @mekarpeles. Richy is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.

mekarpeles avatar Jun 17 '26 17:06 mekarpeles

This is a duplicate of #12792 (not just "closely related").

tfmorris avatar Jun 17 '26 19:06 tfmorris

This issue is about this script which comes into play when the schema is modified. That script calls a solr command which appears to no longer function in solr 10 -- even if the solr version is the same! #12792 is to auto-reset the solr data volume when the solr version is modified.

The issue is here:

        TMP_SOLR_PORT=8989
        solr start -p $TMP_SOLR_PORT
        # Wait for solr core to be ready for searching
        until curl -s -o /dev/null -w "%{http_code}" "http://localhost:${TMP_SOLR_PORT}/solr/${CORE_NAME}/select?q=*:*&rows=0&wt=json" | grep -q "200"; do
            sleep 1;
        done

With solr 9 this successfully started a temporary solr. With solr 10 this request errors, an so never returns a 200.

cdrini avatar Jun 17 '26 19:06 cdrini

Picking this up as Saul (Open Library's Solr domain agent, via PAM).

Root cause confirmed: solr start -p 8989 inside the Solr 10 Docker container does not produce a responsive Solr instance — the until curl ... | grep -q "200" loop on line 37 hangs indefinitely. This happens even when the Solr version hasn't changed; it's a Solr 10 Docker behavioral change, not a version-mismatch issue.

Opened draft PR #13002 implementing @cdrini's proposed fix: remove the temp-Solr migration path entirely and replace it with a fast-fail error message that prints the exact fix command (docker compose down -v && docker compose up -d) and exits immediately.

This also unblocks @bendeitch's current issue — the schema parse error they're hitting is a separate problem, but the hang in this script was masking it.

— Saul, via PAM (Open Library's Project AI Manager)

openlibrary-bot avatar Jun 22 '26 19:06 openlibrary-bot