Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-17582: Stream CLUSTERSTATUS API for SolrJ version >= 9.9 #3156

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mlbiscoc
Copy link
Contributor

@mlbiscoc mlbiscoc commented Feb 3, 2025

https://issues.apache.org/jira/browse/SOLR-17582

Description

Check for SolrJ version from a cluster status request user agent header to stream the response for any SolrJ clients >= 9.9 allowing for backwards compatibility.

Solution

Removed old Javabin check that didn't allow streaming for SolrJ and use the requests Solr version as the check instead for >= 9.9 to either stream or collect whole response in a SimpleOrderedMap

Tests

Created testClusterStateProviderBackwardCompatability to test backwards compatability

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@mlbiscoc
Copy link
Contributor Author

mlbiscoc commented Feb 3, 2025

Meant to put into draft. A few more things I need to add.

Copy link
Contributor Author

@mlbiscoc mlbiscoc left a comment

Choose a reason for hiding this comment

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

Should be good to review now. Forgot to add in a null check for solrVersion

Comment on lines -490 to +492
NamedList<?> collections = (NamedList<?>) cluster.get("collections");
Map<?, ?> collections = (Map<?, ?>) cluster.get("collections");
Copy link
Contributor

Choose a reason for hiding this comment

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

very minor: consider use of var in any place where we cast so we don't repeat the type. But again this is minor; feel free to just let this be and consider this advice to future changes.

@@ -975,7 +975,7 @@ public Map<String, Object> execute(
CLUSTERSTATUS,
(req, rsp, h) -> {
new ClusterStatus(h.coreContainer.getZkController().getZkStateReader(), req.getParams())
.getClusterStatus(rsp.getValues());
.getClusterStatus(rsp.getValues(), req.getHttpSolrCall().getUserAgentSolrVersion());
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm; I wonder if HttpSolrCall could be null. No; we don't use CollectionsHandler in SolrCloud with an EmbeddedSolrServer. I really wish Java had a null-safe navigation operator as used in Kotlin -- ?.. I suppose leave this be; not worth adding verbosity for an exotic / hypothetical case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate your thoroughness. I should merge this as-is.

But...

In an ideal world, you wouldn't have had any need to do this -- no time spent for you or an explicit test here to maintain in perpetuity. Solr is lacking backwards-compatibility test infrastructure. A hello-world SolrCloud would have caught this problem. Such a thing would nowadays almost certainly use Docker (to run old Solr versions) and use TestContainers in Java to arrange for that. We do this at work, albeit not for backwards-compatibility but more for realistic / production like testing. The comment thread in https://issues.apache.org/jira/browse/SOLR-14903 gets at this. I should create a JIRA issue to spell out this need more. Really should be on our roadmap. I'll do that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. Would you prefer I just remove these backwards compatibility tests I wrote?

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