Elasticsearch version 8.0.0-SNAPSHOT
Histogram aggregation run using a very small interval (found when using e-10 and lower) crashes Elasticsearch.
For example, with documents added to an index created with the following mappings:
PUT /histogram_test
{
"mappings": {
"properties" : {
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"approval" : {
"type" : "long"
}
}
}
And index 3 documents:
PUT /histogram_test/_doc/1?pretty
{
"name" : "Pete",
"approval": 87
}
PUT /histogram_test/_doc/2?pretty
{
"name" : "William",
"approval": 87
}
PUT /histogram_test/_doc/3?pretty
{
"name" : "Sue",
"approval": 88
}
Then try using the histogram aggregation with increasingly small interval values:
"interval":5e-2 : returns results correctly
GET histogram_test/_search
{
"query":{
"match_all":{
}
},
"aggs":{
"1185244739_histogram":{
"histogram":{
"field":"approval",
"interval":5e-2
}
}
},
"size":3
}
"interval":5e-7 : returns sensible error:
{
"error" : {
"root_cause" : [ ],
"type" : "search_phase_execution_exception",
"reason" : "",
"phase" : "fetch",
"grouped" : true,
"failed_shards" : [ ],
"caused_by" : {
"type" : "too_many_buckets_exception",
"reason" : "Trying to create too many buckets. Must be less than or equal to: [65536] but was [2000001]. This limit can be set by changing the [search.max_buckets] cluster level setting.",
"max_buckets" : 65536
}
},
"status" : 503
}
However when the interval is dropped to "interval":5e-10, Elasticsearch crashes with the following error:
Heap dump file created [1532782746 bytes in 4.312 secs]
[2021-04-15T14:08:29,995][INFO ][o.e.i.b.HierarchyCircuitBreakerService] [DESKTOP-3EDNC1M] attempting to trigger G1GC due to high heap usage [1021478296]
[2021-04-15T14:08:29,995][INFO ][o.e.i.b.HierarchyCircuitBreakerService] [DESKTOP-3EDNC1M] GC did not bring memory usage down, before [1021478296], after [1026921016], allocations [1], duration [0]
[2021-04-15T14:08:29,995][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [DESKTOP-3EDNC1M] fatal error in thread [elasticsearch[DESKTOP-3EDNC1M][search][T#4]], exiting
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3480) ~[?:?]
at java.util.ArrayList.grow(ArrayList.java:237) ~[?:?]
at java.util.ArrayList.grow(ArrayList.java:244) ~[?:?]
at java.util.ArrayList.add(ArrayList.java:486) ~[?:?]
at java.util.ArrayList$ListItr.add(ArrayList.java:1068) ~[?:?]
at org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.addEmptyBuckets(InternalHistogram.java:379) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.reduce(InternalHistogram.java:399) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:154) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.search.aggregations.InternalAggregations.topLevelReduce(InternalAggregations.java:103) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.action.search.SearchPhaseController.reduceAggs(SearchPhaseController.java:480) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.action.search.SearchPhaseController.reducedQueryPhase(SearchPhaseController.java:468) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.action.search.QueryPhaseResultConsumer.reduce(QueryPhaseResultConsumer.java:131) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.action.search.FetchSearchPhase.innerRun(FetchSearchPhase.java:98) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.action.search.FetchSearchPhase$1.doRun(FetchSearchPhase.java:84) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:728) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
at java.lang.Thread.run(Thread.java:831) [?:?]
fatal error in thread [elasticsearch[DESKTOP-3EDNC1M][search][T#4]], exiting
java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Arrays.java:3480)
at java.base/java.util.ArrayList.grow(ArrayList.java:237)
at java.base/java.util.ArrayList.grow(ArrayList.java:244)
at java.base/java.util.ArrayList.add(ArrayList.java:486)
at java.base/java.util.ArrayList$ListItr.add(ArrayList.java:1068)
at org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.addEmptyBuckets(InternalHistogram.java:379)
at org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram.reduce(InternalHistogram.java:399)
at org.elasticsearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:154)
at org.elasticsearch.search.aggregations.InternalAggregations.topLevelReduce(InternalAggregations.java:103)
at org.elasticsearch.action.search.SearchPhaseController.reduceAggs(SearchPhaseController.java:480)
at org.elasticsearch.action.search.SearchPhaseController.reducedQueryPhase(SearchPhaseController.java:468)
at org.elasticsearch.action.search.QueryPhaseResultConsumer.reduce(QueryPhaseResultConsumer.java:131)
at org.elasticsearch.action.search.FetchSearchPhase.innerRun(FetchSearchPhase.java:98)
at org.elasticsearch.action.search.FetchSearchPhase$1.doRun(FetchSearchPhase.java:84)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:728)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:831)
Ran into this issue with the data frame analytics results page in the ML Kibana plugin, which uses the histogram aggregation to plot histograms of the values of fields in the results data grid.
Elasticsearch version 8.0.0-SNAPSHOT
Histogram aggregation run using a very small
interval(found when usinge-10and lower) crashes Elasticsearch.For example, with documents added to an index created with the following mappings:
And index 3 documents:
Then try using the
histogramaggregation with increasingly smallintervalvalues:"interval":5e-2: returns results correctly"interval":5e-7: returns sensible error:However when the interval is dropped to
"interval":5e-10, Elasticsearch crashes with the following error:Ran into this issue with the data frame analytics results page in the ML Kibana plugin, which uses the
histogramaggregation to plot histograms of the values of fields in the results data grid.