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

Cross Cluster Search: propagate original indices per cluster #24328

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Apr 26, 2017

In case of a Cross Cluster Search, the coordinating node should split the original indices per cluster, and send over to each cluster only its own set of original indices, rather than set taken from the original search request which contains all the indices.

In fact, each remote cluster should not be aware of the indices belonging to other remote clusters.

@javanna javanna added :Search/Search Search-related issues that do not fall into other categories >bug review v5.3.3 v5.4.0 v6.0.0-alpha1 labels Apr 26, 2017
@javanna javanna requested a review from s1monw April 26, 2017 08:52
Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

i left some minors looks good man!

throws IOException {
IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex());
IndexShard indexShard = indexService.getShard(request.shardId().getId());
SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().getId(), indexShard.shardId());
SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().getId(), indexShard.shardId(), originalIndices);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this here at all lets pass always null here to the SearchShardTarget

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for bringing this up, I was not too sure about this.

@@ -30,14 +30,14 @@
* ShardsIterators are always returned in ascending order independently of their order at construction
* time. The incoming iterators are sorted to ensure consistent iteration behavior across Nodes / JVMs.
*/
public final class GroupShardsIterator implements Iterable<ShardIterator> {
public final class GroupShardsIterator<S extends ShardIterator> implements Iterable<S> {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/S/ShardIt

@@ -112,7 +112,7 @@ private void innerRun() throws IOException {
final IntArrayList[] docIdsToLoad = searchPhaseController.fillDocIdsToLoad(numShards, reducedQueryPhase.scoreDocs);
if (reducedQueryPhase.scoreDocs.length == 0) { // no docs to fetch -- sidestep everything and return
phaseResults.stream()
.map(e -> e.queryResult())
.map(SearchPhaseResult::queryResult)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

shards.add(shardIterator);
}
for (ShardIterator shardIterator : localShardsIterator) {
shards.add(shardIterator);
List<ShardRouting> shardRoutings = new ArrayList<>();
for (ShardRouting shardRouting : shardIterator.asUnordered()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate this copying here :) can we maybe do this:

  • make ShardsIterator extends Iterable<ShardRouting>
  • remove ShardsIterator#asUnordered()
  • add List<ShardRouting> ShardsIterator#getShardRoutings()

that way we can just reuse the list?

Copy link
Member Author

Choose a reason for hiding this comment

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

loving this plan. I don't like this copying either.

@javanna
Copy link
Member Author

javanna commented Apr 26, 2017

@s1monw I addressed your comments and added some tests. Can you have another look please?

@javanna javanna force-pushed the fix/cross_cluster_search_original_indices branch from 3f690a3 to 48e6430 Compare April 26, 2017 18:41
Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

left one suggestion LGTM otherwise. no need for another review. Thanks for the additional tests

@@ -74,7 +75,12 @@ public int sizeActive() {
}

@Override
public Iterable<ShardRouting> asUnordered() {
public List<ShardRouting> getShardRoutings() {
return shards;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe wrap it in an unmodifiable list in the ctor? I think we should not allow mutation here?

Copy link
Member Author

Choose a reason for hiding this comment

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

++ will do

@javanna javanna merged commit 149629f into elastic:master Apr 26, 2017
javanna added a commit that referenced this pull request Apr 26, 2017
In case of a Cross Cluster Search, the coordinating node should split the original indices per cluster, and send over to each cluster only its own set of original indices, rather than the set taken from the original search request which contains all the indices.

In fact, each remote cluster should not be aware of the indices belonging to other remote clusters.
javanna added a commit that referenced this pull request Apr 26, 2017
In case of a Cross Cluster Search, the coordinating node should split the original indices per cluster, and send over to each cluster only its own set of original indices, rather than the set taken from the original search request which contains all the indices.

In fact, each remote cluster should not be aware of the indices belonging to other remote clusters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v5.4.0 v5.5.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants