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
Fix early termination of aggregators that run with breadth-first mode #44963
Conversation
This commit fixes a bug when a deferred aggregator tries to early terminate the collection. In such case the CollectionTerminatedException is not caught and the search fails on the shard. This change makes sure that we catch the exception in order to continue the deferred collection on the next leaf. Fixes elastic#44909
Pinging @elastic/es-analytics-geo |
.setTrackTotalHits(false) | ||
.setQuery(matchAllQuery()) | ||
.addAggregation(max("max").field("values")) | ||
.addAggregation(count("count").field("values")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unrelated question: is the count
agg required here to check for correctness? It looks like count
doesn't use the early termination optimization, so wasn't sure if that is being used as a proxy to make sure that other aggs are unaffected, or something?
Asking because @csoulios is converting the max IT to unit tests, and we were discussing the other early termination test last week. I wasn't quite sure the purpose of count
here, or if it was included because why not :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is used to check if a sibling is not affected by an aggregation that terminates early. So the fact that we don't collect any hits for the max
aggregation should not impact the count
one which needs to see all hits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks. So if we embedded this inside a filter
agg with match_all
it should be functionally the same, right?
AggregatorTestCase
currently assumes a single top-level agg for simplicity, so when converting these IT over to unit tests we weren't sure how to handle it. We could also just leave the early termination tests as IT too.
(Note: not for this PR, just discussion regarding the changes we're making to tests in a separate PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we embedded this inside a filter agg with match_all it should be functionally the same, right?
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Shame we have to use exceptions for control flow, but last time I looked at all of this it definitely seemed like the path of least resistance :)
@elasticmachine run elasticsearch-ci/2 |
This commit fixes a bug when a deferred aggregator tries to early terminate the collection. In such case the CollectionTerminatedException is not caught and the search fails on the shard. This change makes sure that we catch the exception in order to continue the deferred collection on the next leaf. Fixes #44909
This commit fixes a bug when a deferred aggregator tries to early terminate the collection. In such case the CollectionTerminatedException is not caught and the search fails on the shard. This change makes sure that we catch the exception in order to continue the deferred collection on the next leaf. Fixes #44909
This commit fixes a bug when a deferred aggregator tries to early terminate the collection. In such case the CollectionTerminatedException is not caught and the search fails on the shard. This change makes sure that we catch the exception in order to continue the deferred collection on the next leaf. Fixes #44909
This commit fixes a bug when a deferred aggregator tries to early terminate the collection. In such case the CollectionTerminatedException is not caught and the search fails on the shard. This change makes sure that we catch the exception in order to continue the deferred collection on the next leaf. Fixes #44909
This commit fixes a bug when a deferred aggregator tries to early terminate the collection. In such case the CollectionTerminatedException is not caught and
the search fails on the shard. This change makes sure that we catch the exception in order to continue the deferred collection on the next leaf.
Fixes #44909