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-17066: Switch "LB" clients away from core URLs #2283

Merged

Conversation

gerlowskija
Copy link
Contributor

@gerlowskija gerlowskija commented Feb 19, 2024

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

Description

Bootstrapping Solr clients with core URLs has several downsides: it prevents the created client from making core-agnostic requests, it prevents the client from making both v1 and v2 requests, etc. For all these reasons, SOLR-17066 has been moving our client implementations away from using these "core URLs" and towards using a "default collection" instead.

Solr's "Load balancing" client is an interesting case though. A common (maybe even the primary?) use-case of the "LB" client is to round-robin requests across a set of replicas. Each replica in a set has a unique core name, and distinguishing between them is important to ensure uniform load distribution. So users can't rely on the "default collection" feature to meet their needs.

Any attempt to move the LBClients away from "core URLs" must also retain a way for them to specify a distinct set of replicas/cores.

Solution

This PR solves this problem by creating a new LBClient-specific abstraction called an "endpoint". Endpoints are thin wrappers around a Solr base URL and optional core name, and users now provide these "Endpoint" objects when creating their LBClient, instead of passing raw String URLs.

Using a strongly typed object instead of raw String URLs allows core-based clients to still make core-agnostic requests as needed, while still supporting the "target a set of distinct replicas" use case.

Tests

Changes to TestLBHttpSolrClient and TestLBHttp2SolrClient. New unit tests for the Endpoint class. Existing tests continue to pass.

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)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added Javadoc documentation

This acts out the first step of the 3 below that I've been considering
to make the LB changes a little more reasonably.

I _haven't_ actually switched any LB usage over to using base URLs or
anything either.  Just trying to match the existing behavior and usage,
with this 'Endpoint' abstraction jammed in.

1. Create 'Endpoint' class (in LBSolrCLient, or is this generally more
   useful?)
2. Change LBSolrClient.ServerWrapper to be an "EndpointWrapper"
3. Change internal LBSolrClient logic to use endpoint instead of Server
The whole idea of a **DEFAULT** collection doesn't make as much sense
for LB, since round-robining between various repicas is kindof the whole
reason LB exists.

What's the most coherent interface that I could come up with:
  1. Switch all LB builders and ctors to using "Endpoints"
  2. Document in Javadocs that all "endpoints" for a client should be of
     the same type (e.g. they all have a core, or none have a core)
    - maybe enforce this in ctors?
  3. Document in Javadocs that 'defaultCollection' is only used when
     "base" endpoints are provided

Committing this in interim state so that I can share across computers.
The LB client builders have been switched over to using 'Endpoint', and
a lot of the old methods have been removed.

Still TODO:
  - class level javadoc rework for the LB clients
  - audit use of Endpoint.toString()
  - look into Zombie Server alive-checking (causing
    TestLBHttp2SolrClient test failure I think)
  - The Big One: Switch LBSolrClient.Req over to using Endpoint
Still need to change Req usage to actually provide endpoints
@gerlowskija
Copy link
Contributor Author

Question Is this change worth the added complexity? I'm excited to move away from core URLs, but want to make sure the net effect is still positive given some of the complexity this pulls in. Curious what others think.

If we do go this route, this change should target main/10.0 only; I don't think 9.x is an option, since we still support arbitrary "context root"s on that branch. (Though of course, we'll need to make some sort of branch_9x change to deprecate the LBClient method signatures that this PR modifies)

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 20, 2024
@gerlowskija gerlowskija marked this pull request as ready for review February 20, 2024 17:22
@gerlowskija gerlowskija merged commit c5709bd into apache:main Feb 26, 2024
3 of 4 checks passed
@gerlowskija gerlowskija deleted the SOLR-17066-lbsolrclient-remove-core-urls branch February 26, 2024 15:45
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.

1 participant