Skip to content

fix(solr): detect version mismatch at startup + add make check-solr#12795

Open
mekarpeles wants to merge 2 commits into
masterfrom
12792/solr-version-mismatch-detection
Open

fix(solr): detect version mismatch at startup + add make check-solr#12795
mekarpeles wants to merge 2 commits into
masterfrom
12792/solr-version-mismatch-detection

Conversation

@mekarpeles
Copy link
Copy Markdown
Member

Summary

After the Solr 9 → 10 upgrade (#12786), developers with existing data volumes hit silent search failures. The root cause: ol-local-solr-start.sh tries to start Solr on a temp port to count documents before wiping the core — if Solr 10 can't read Solr 9 data, that step hangs indefinitely with no output.

This PR makes the failure fast and visible, and adds a runtime check for developers who haven't restarted yet.

Changes

docker/ol-local-solr-start.sh — wrap the temp Solr start in timeout 60:

  • If Solr starts OK within 60s → existing delete+recreate logic runs as before
  • If it times out → print the Solr version, a clear explanation, and the exact fix command, then exit 1

Makefile — add make check-solr:

  • Queries http://localhost:8983/solr/admin/info/system (running version)
  • Compares against the image: solr:X.Y.Z line in compose.yaml (expected version)
  • Prints a warning with the fix command if major versions differ
  • Covers the "already running" case that the startup script can't reach

Example output

After a major version bump, docker compose logs solr will show:

[ol-local-solr-start] ERROR: Solr 10.0.0 failed to start with the existing data volume.
[ol-local-solr-start] This usually means the data volume was written by an older Solr major version.
[ol-local-solr-start] Action required: docker compose down -v && docker compose up -d
[ol-local-solr-start] See: https://docs.openlibrary.org/advanced/solr.html#making-changes-to-solr-config

And make check-solr while already running:

⚠️  Solr version mismatch:
   Running:  9.9.0
   Expected: 10.0.0 (from compose.yaml)
   Fix: docker compose down -v && docker compose up -d

Testing

The timeout path is hard to trigger without a stale volume, but the happy path (schema unchanged, or schema changed + Solr starts fine) is unaffected — only the error branch is new code.

make check-solr can be tested locally with Solr running: it should print ✓ Solr version OK (X.Y.Z).

Closes #12792

Adds a 60s timeout around the temp Solr start in ol-local-solr-start.sh
so the container fails fast with an actionable message instead of hanging
when the data volume is incompatible with the current Solr major version
(e.g. after the Solr 9 -> 10 upgrade in #12786).

Also adds `make check-solr` to detect the mismatch while containers are
already running, by comparing the live Solr version API against the image
tag in compose.yaml.

Closes #12792
Copilot AI review requested due to automatic review settings May 23, 2026 01:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves local developer experience around Solr major-version upgrades by making Solr volume incompatibility failures fast and actionable, and by adding a helper command to detect a running-version mismatch against the repository’s expected Solr image version.

Changes:

  • Add a 60s timeout + clearer error messaging around the temporary Solr start used during schema-change core recreation.
  • Add make check-solr to compare the running Solr major version (via the admin API) against the expected version in compose.yaml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Makefile Adds check-solr target to detect major-version mismatches between a running Solr and the expected Docker image tag.
docker/ol-local-solr-start.sh Wraps the temp Solr startup/readiness wait in timeout 60 and prints an actionable error if it can’t come up (e.g., stale/incompatible volume).

Comment thread Makefile Outdated
Comment thread Makefile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infra/DX: Detect Solr version mismatch at container start and warn developer to rebuild

3 participants