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-12217: Support shards.preference for individual shard requests #984

Merged
merged 8 commits into from Dec 9, 2019

Conversation

HoustonPutman
Copy link
Contributor

@HoustonPutman HoustonPutman commented Oct 30, 2019

Description

Use shard preference rules when choosing replicas to send individual shard requests. This includes requests from SolrJ as well as requests sent via streaming expressions.

Solution

How routing preferences are determined:

For Streaming Expressions, it will use the preferences from the following sources, in order of preference (defaults last):

  1. The params given in the stream source
  2. The URL params sent in the streaming request
  3. The DEFAULT_SHARD_PREFERENCES set in cluster properties

For SolrJ, it will use the preferences from the params of the request it is sending.

Tests

Current tests pass.

TODO Add tests for routing functionality

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 am authorized to contribute this code to the ASF and have removed any code I do not have a license to distribute.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the master branch.
  • I have run ant precommit and the appropriate test suite.
  • I have added tests for my changes.
  • I have added documentation for the Ref Guide (for Solr changes only).

Copy link
Member

@tflobbe tflobbe left a comment

Choose a reason for hiding this comment

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

Looks good. I don't know much about the streaming part, maybe @joel-bernstein can take a look, but in general, LGTM other than the comments.

@@ -651,6 +659,13 @@ protected RouteException getRouteException(SolrException.ErrorCode serverError,
}
}
}

// Sort the non-leader replicas according to the request parameters
replicaListTransformer.transform(urls);
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary for updates? are you trying to keep consistency only or do you have some use case in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mainly for consistency. I guess it's mostly a no-op, since the leader is always going to be first anyways (if a leader exists).

Copy link
Member

@tflobbe tflobbe left a comment

Choose a reason for hiding this comment

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

LGTM. I'm running tests and there are some failures, most probably unrelated but want to make sure

@HoustonPutman
Copy link
Contributor Author

Want to hear your opinion @tflobbe .

So I changed the logic for non-update/admin/v2 request routing to use core URLs instead of collection URLs, unless the request is querying multiple collections. In this way, if there are certain replicas on a host that you want to target you can make that distinction. However that does change the default behavior in a non-trivial way.

The only place where I see this breaks any test is weirdly enough in the Hadoop auth tests for sending a commit request. It seems that since the commit request is sent directly to a core, instead of the collection url, it is missing an additional count of unauthenticated requests.

@HoustonPutman
Copy link
Contributor Author

I've decided to be conservative and revert that logic. So for non-update requests, SolrJ will send the request to the collection URL, not the replica URL. All tests pass on my end now.

Copy link
Member

@tflobbe tflobbe left a comment

Choose a reason for hiding this comment

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

Changes LGTM @HoustonPutman. You don't need me for merging now :)

@HoustonPutman HoustonPutman merged commit 1c78d2c into apache:master Dec 9, 2019
@HoustonPutman HoustonPutman deleted the single-shard-routing branch December 9, 2019 22:12
hossman pushed a commit to lucidworks/lucene-solr that referenced this pull request May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants