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

Parse alias filters on the coordinating node #20916

Merged
merged 10 commits into from
Oct 14, 2016

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Oct 13, 2016

Today we don't parse alias filters on the coordinating node, we only forward
the alias patters to executing node and resolve it late. This has several problems
like requests that go through filtered aliases are never cached if they use date math,
since the parsing happens very late in the process even without rewriting. It also used
to be processed on every shard while we can only do it once per index on the coordinating node.
Another nice side effect is that we are never prone to cluster-state updates that change an alias,
all nodes will execute the exact same alias filter since they are process based on the same
cluster state.

Today we don't parse alias filters on the coordinating node, we only forward
the alias patters to executing node and resolve it late. This has several problems
like requests that go through filtered aliases are never cached if they use date math,
since the parsing happens very late in the process even without rewriting. It also used
to be processed on every shard while we can only do it once per index on the coordinating node.
Another nice sideeffect is that we are never prone to clusterstate updates that change an alias,
all nodes will execute the exact same alias filter since they are process based on the same
cluster state.
@s1monw s1monw added >enhancement review :Search/Search Search-related issues that do not fall into other categories v6.0.0-alpha1 v5.1.1 labels Oct 13, 2016
@s1monw
Copy link
Contributor Author

s1monw commented Oct 13, 2016

@colings86 can you take a look

Copy link
Contributor

@colings86 colings86 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 tiny comment but LGTM

// we need to bench here a bit, to see maybe it makes sense to use OrFilter
BoolQueryBuilder combined = new BoolQueryBuilder();
for (String aliasName : aliasNames) {
AliasMetaData alias = aliases.get(aliasName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there is an indentation issue here?

@colings86
Copy link
Contributor

Looks like org.elasticsearch.search.SearchServiceTests.testSearchWhileIndexDeleted failed in the PR build. Not sure if this failure is related to this change?

@s1monw
Copy link
Contributor Author

s1monw commented Oct 14, 2016

@colings86 I added additional testing can you take another look?

Copy link
Contributor

@colings86 colings86 left a comment

Choose a reason for hiding this comment

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

Left 2 nit pick comments but LGTM

final Map<String, AliasFilter> queryBuilderMap = new HashMap<>();
for (String index : concreteIndices) {
clusterState.blocks().indexBlockedRaiseException(ClusterBlockLevel.READ, index);
AliasFilter queryBuilder = searchService.buildAliasFilter(clusterState, index, request.indices());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should this be called aliasFilter?

}

private Map<String, AliasFilter> buildPerIndexAliasFilter(SearchRequest request, ClusterState clusterState, String...concreteIndices) {
final Map<String, AliasFilter> queryBuilderMap = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should this be called aliasFilterMap?

@s1monw s1monw merged commit cff5993 into elastic:master Oct 14, 2016
@s1monw s1monw deleted the parse_alias_filter_early branch October 14, 2016 14:26
s1monw added a commit that referenced this pull request Oct 14, 2016
Today we don't parse alias filters on the coordinating node, we only forward
the alias patters to executing node and resolve it late. This has several problems
like requests that go through filtered aliases are never cached if they use date math,
since the parsing happens very late in the process even without rewriting. It also used
to be processed on every shard while we can only do it once per index on the coordinating node.
Another nice side-effect is that we are never prone to cluster-state updates that change an alias,
all nodes will execute the exact same alias filter since they are process based on the same
cluster state.
@javanna
Copy link
Member

javanna commented Nov 15, 2016

@s1monw I think that we should add a bw comp layer on top of this change, which otherwise breaks backwards compatibility on the transport layer. Maybe our bw comp tests don't catch it because we have no REST tests that search, or validate query, or explain against a filtered alias?

@javanna
Copy link
Member

javanna commented Nov 15, 2016

@javanna you were wrong, this is fully bw compatible :)

@s1monw
Copy link
Contributor Author

s1monw commented Nov 15, 2016

@s1monw I think that we should add a bw comp layer on top of this change, which otherwise breaks backwards compatibility on the transport layer. Maybe our bw comp tests don't catch it because we have no REST tests that search, or validate query, or explain against a filtered alias?

the bwc layer is inside the new class... it's not very obvious from the high level but when you look closer you see that all kinds of BWC tests are present.

javanna added a commit to javanna/elasticsearch that referenced this pull request Nov 22, 2016
The search shards api returns info about which shards are going to be hit by executing a search with provided parameters: indices, routing, preference. Indices can also be aliases, which can also hold filters. The output includes an array of shards and a summary of all the nodes the shards are allocated on. This commit adds a new indices section to the search shards output that includes one entry per index, where each index can be associated with an optional filter in case the index was hit through a filtered alias.

This is relevant since we have moved parsing of alias filters to the coordinating node.

Relates to elastic#20916
javanna added a commit that referenced this pull request Nov 22, 2016
Add indices and filter information to search shards api output

The search shards api returns info about which shards are going to be hit by executing a search with provided parameters: indices, routing, preference. Indices can also be aliases, which can also hold filters. The output includes an array of shards and a summary of all the nodes the shards are allocated on. This commit adds a new indices section to the search shards output that includes one entry per index, where each index can be associated with an optional filter in case the index was hit through a filtered alias.

This is relevant since we have moved parsing of alias filters to the coordinating node.

Relates to #20916
javanna added a commit that referenced this pull request Nov 22, 2016
Add indices and filter information to search shards api output

The search shards api returns info about which shards are going to be hit by executing a search with provided parameters: indices, routing, preference. Indices can also be aliases, which can also hold filters. The output includes an array of shards and a summary of all the nodes the shards are allocated on. This commit adds a new indices section to the search shards output that includes one entry per index, where each index can be associated with an optional filter in case the index was hit through a filtered alias.

This is relevant since we have moved parsing of alias filters to the coordinating node.

Relates to #20916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v5.1.1 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants