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

[Weighted Routing] Allow Search with preference parameter in weighed in nodes #6296

Conversation

anshu1106
Copy link
Contributor

@anshu1106 anshu1106 commented Feb 13, 2023

Signed-off-by: Anshu Agarwal [email protected]

Description

This PR adds support to allow searches with preference parameter when strict weighted routing is enabled.

Issues Resolved

#6297

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Anshu Agarwal <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@andrross
Copy link
Member

Does this effectively revert #5874? Is there a top level issue somewhere the fully describes the behavior of weighted routing that can help me understand this?

* round-robin scheduling policy. Uses the passed seed to shuffle the shards.
*
*/
public ShardIterator activeInitializingShardsSimpleWeightedIt(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be package private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests won't compile

Copy link
Collaborator

@Bukhtawar Bukhtawar left a comment

Choose a reason for hiding this comment

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

Might need exhaustive tests for this

@Bukhtawar
Copy link
Collaborator

Does this effectively revert #5874? Is there a top level issue somewhere the fully describes the behavior of weighted routing that can help me understand this?

No the previous change was strict, this change relaxes the checks to allow the search preference parameter if preference isn't hard(like ONLY_NODES) when those nodes are weighed away.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Anshu Agarwal <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@anshu1106
Copy link
Contributor Author

Might need exhaustive tests for this

@Bukhtawar added tests for all the preference parameter

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

Codecov Report

Merging #6296 (648f068) into main (49d9a90) will decrease coverage by 0.19%.
The diff coverage is 9.30%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main    #6296      +/-   ##
============================================
- Coverage     70.78%   70.59%   -0.19%     
+ Complexity    59062    58951     -111     
============================================
  Files          4800     4800              
  Lines        282420   282496      +76     
  Branches      40718    40735      +17     
============================================
- Hits         199908   199442     -466     
- Misses        66126    66658     +532     
- Partials      16386    16396      +10     
Impacted Files Coverage Δ
...g/opensearch/cluster/routing/OperationRouting.java 71.17% <0.00%> (-11.59%) ⬇️
...search/cluster/routing/IndexShardRoutingTable.java 78.39% <13.79%> (-10.30%) ⬇️
...search/indices/recovery/RecoveryTargetHandler.java 0.00% <0.00%> (-100.00%) ⬇️
...adonly/AddIndexBlockClusterStateUpdateRequest.java 0.00% <0.00%> (-75.00%) ⬇️
...a/org/opensearch/client/cluster/SniffModeInfo.java 0.00% <0.00%> (-58.83%) ⬇️
...readonly/TransportVerifyShardIndexBlockAction.java 9.75% <0.00%> (-58.54%) ⬇️
...cluster/coordination/PendingClusterStateStats.java 20.00% <0.00%> (-48.00%) ⬇️
...indices/readonly/TransportAddIndexBlockAction.java 20.68% <0.00%> (-37.94%) ⬇️
...cluster/coordination/PublishClusterStateStats.java 33.33% <0.00%> (-37.51%) ⬇️
.../indices/readonly/AddIndexBlockRequestBuilder.java 0.00% <0.00%> (-33.34%) ⬇️
... and 460 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines 376 to 409
final Set<String> nodesIds = Arrays.stream(preference.substring(Preference.PREFER_NODES.type().length() + 1).split(","))
.collect(Collectors.toSet());
return indexShard.preferNodeActiveInitializingShardsWeightedIt(
nodesIds,
nodes,
weightedRoutingMetadata.getWeightedRouting(),
getWeightedRoutingDefaultWeight()
);
case LOCAL:
return indexShard.preferNodeActiveInitializingShardsWeightedIt(
Collections.singleton(localNodeId),
nodes,
weightedRoutingMetadata.getWeightedRouting(),
getWeightedRoutingDefaultWeight()
);
case ONLY_LOCAL:
if (!indexShard.isNodeWeighedAway(
weightedRoutingMetadata.getWeightedRouting(),
nodes,
localNodeId,
getWeightedRoutingDefaultWeight()
)) return indexShard.onlyNodeActiveInitializingShardsIt(localNodeId);
else {
throw new PreferenceBasedSearchNotAllowedException(
"Preference based routing not allowed on weigh away node with strict weighted shard routing enabled"
);
}
case ONLY_NODES:
String nodeAttributes = preference.substring(Preference.ONLY_NODES.type().length() + 1);
return indexShard.onlyNodeSelectorActiveInitializingWeightedShardsIt(
nodeAttributes.split(","),
nodes,
weightedRoutingMetadata.getWeightedRouting(),
getWeightedRoutingDefaultWeight()
Copy link
Collaborator

Choose a reason for hiding this comment

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

There could be multiple cases for each of these cases. Lets add comments on the behavioural change. We might also want to document the same

Anshu Agarwal added 2 commits February 15, 2023 19:13
Signed-off-by: Anshu Agarwal <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

.routingTable(routingTable)
.build();

threadPool = new TestThreadPool("testThatOnlyNodesSupport");
Copy link
Member

Choose a reason for hiding this comment

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

Copy/paste error on "testThatOnlyNodesSupport"? Also can probably move this assignment up and skip assigning null to threadPool.

@@ -112,6 +112,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Cluster health call to throw decommissioned exception for local decommissioned node([#6008](https://github.com/opensearch-project/OpenSearch/pull/6008))
- [Refactor] core.common to new opensearch-common library ([#5976](https://github.com/opensearch-project/OpenSearch/pull/5976))
- Cluster local health call to throw exception if node is decommissioned or weighed away ([#6198](https://github.com/opensearch-project/OpenSearch/pull/6198))
- Allow search with preference parameter when strict weighted shard routing is enabled ([#6296](https://github.com/opensearch-project/OpenSearch/pull/6296))
Copy link
Member

Choose a reason for hiding this comment

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

We now have the following two entries to go in the next release notes:

  • Add support to disallow search request with preference parameter with strict weighted shard routing
  • Allow search with preference parameter when strict weighted shard routing is enabled

I find these two statements confusing! Since the second change is just modifying a subtle behavior of the first change (which is still unreleased), maybe we don't need the second entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will modify the first entry itself

@anshu1106 anshu1106 closed this Feb 16, 2023
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.

4 participants