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

Prevent date_histogram from OOMing #72081

Merged
merged 5 commits into from
Apr 27, 2021

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Apr 22, 2021

This prevents the date_histogram from running out of memory allocating
empty buckets when you set the interval to something tiny like seconds
and aggregate over a very wide date range. Without this change we'd
allocate memory very quickly and throw and out of memory error, taking
down the node. With it we instead throw the standard "too many buckets"
error.

Relates to #71758

@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Apr 22, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@nik9000
Copy link
Member Author

nik9000 commented Apr 22, 2021

Like #71758 this one has been here for a while, seems fairly rare, but has a fairly bad effect.

This prevents the `date_histogram` from running out of memory allocating
empty buckets when you set the interval to something tiny like `seconds`
and aggregate over a very wide date range. Without this change we'd
allocate memory very quickly and throw and out of memory error, taking
down the node. With it we instead throw the standard "too many buckets"
error.

Relates to elastic#71758
@nik9000
Copy link
Member Author

nik9000 commented Apr 22, 2021

Ouch, checkstyle.

Copy link
Member

@not-napoleon not-napoleon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM.

"Tiny tiny tiny date_range":
- skip:
version: " - 7.99.99"
reason: fixed in 8.0 and being backported to 7.13.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably too late for 7.13.0 now

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, probably.

* this quickly in pathological cases and plenty large to keep the
* overhead minimal.
*/
int reportEmptyEvery = 10000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably. I stuck it here so the comment above it could describe why it has the value it does. I'm not sure the right way to do that if its a constant without making it harder to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you at least make it final? My first reaction was "Why and where is he changing it?".

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure!

@nik9000 nik9000 merged commit 5f281ce into elastic:master Apr 27, 2021
nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Apr 27, 2021
This prevents the `date_histogram` from running out of memory allocating
empty buckets when you set the interval to something tiny like `seconds`
and aggregate over a very wide date range. Without this change we'd
allocate memory very quickly and throw and out of memory error, taking
down the node. With it we instead throw the standard "too many buckets"
error.

Relates to elastic#71758
nik9000 added a commit that referenced this pull request Apr 28, 2021
This prevents the `date_histogram` from running out of memory allocating
empty buckets when you set the interval to something tiny like `seconds`
and aggregate over a very wide date range. Without this change we'd
allocate memory very quickly and throw and out of memory error, taking
down the node. With it we instead throw the standard "too many buckets"
error.

Relates to #71758
nik9000 added a commit to nik9000/elasticsearch that referenced this pull request Apr 28, 2021
Now that elastic#72081 has landed in the 7.x branch we can run its test in the
backwards compatibility test suite.
nik9000 added a commit that referenced this pull request Apr 28, 2021
Now that #72081 has landed in the 7.x branch we can run its test in the
backwards compatibility test suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.14.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants