elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
993 stars 24.82k forks source link

ES crashes with OOM error when running fine-grained geotile_grid aggs on geo_shape #57847

Closed thomasneirynck closed 4 years ago

thomasneirynck commented 4 years ago

Elasticsearch crashes when running a fine-grained geotile_grid-agg on a geo_shape.

This seems to occur when zooming in on an area inside a large shape.

e.g. 1) Index the world-countries file from EMS: https://maps.elastic.co/v7.7/index.html#file/world_countries 2) The mapping would be something like:

{
   "world_countries_v1":{
      "mappings":{
         "properties":{
            "coordinates":{
               "type":"geo_shape"
            },
            "iso2":{
               "type":"text",
               "fields":{
                  "keyword":{
                     "type":"keyword",
                     "ignore_above":256
                  }
               }
            },
            "iso3":{
               "type":"text",
               "fields":{
                  "keyword":{
                     "type":"keyword",
                     "ignore_above":256
                  }
               }
            },
            "name":{
               "type":"text",
               "fields":{
                  "keyword":{
                     "type":"keyword",
                     "ignore_above":256
                  }
               }
            }
         }
      }
   }
}

3) Issue following query

{
  "size": 0,
  "aggs": {
    "gridSplit": {
      "geotile_grid": {
        "bounds": {
          "top_left": [
            -117.514295,
            44.54603
          ],
          "bottom_right": [
            -91.48767500000002,
            36.42819
          ]
        },
        "field": "coordinates",
        "precision": 11
      },
      "aggs": {
        "gridCentroid": {
          "geo_centroid": {
            "field": "coordinates"
          }
        }
      }
    }
  },
  "stored_fields": [
    "*"
  ],
  "script_fields": {},
  "docvalue_fields": [],
  "_source": {
    "excludes": []
  },
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "geo_shape": {
            "coordinates": {
              "shape": {
                "type": "Polygon",
                "coordinates": [
                  [
                    [
                      -117.59766,
                      44.59047
                    ],
                    [
                      -117.59766,
                      36.31513
                    ],
                    [
                      -91.40625,
                      36.31513
                    ],
                    [
                      -91.40625,
                      44.59047
                    ],
                    [
                      -117.59766,
                      44.59047
                    ]
                  ]
                ]
              },
              "relation": "INTERSECTS"
            }
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  }
}

Elasticzearch crashes with:

[2020-06-08T17:33:47,532][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [Thomass-MBP.attlocal.net] fatal error in thread [elasticsearch[Thomass-MBP.attlocal.net][search][T#9]], exiting
java.lang.OutOfMemoryError: Java heap space
    at org.apache.lucene.util.ArrayUtil.growExact(ArrayUtil.java:323) ~[lucene-core-8.6.0-snapshot-9d6c738ffce.jar:8.6.0-snapshot-9d6c738ffce 9d6c738ffce0c3164691f161ba8b92a615b1e062 - jenkins - 2020-05-20 09:52:47]
    at org.apache.lucene.util.ArrayUtil.grow(ArrayUtil.java:332) ~[lucene-core-8.6.0-snapshot-9d6c738ffce.jar:8.6.0-snapshot-9d6c738ffce 9d6c738ffce0c3164691f161ba8b92a615b1e062 - jenkins - 2020-05-20 09:52:47]
    at org.elasticsearch.index.fielddata.SortingNumericDocValues.resize(SortingNumericDocValues.java:62) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoShapeCellValues.resizeCell(GeoShapeCellValues.java:54) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:123) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValues(GeoTileGridTiler.java:69) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoShapeCellValues.advanceValue(GeoShapeCellValues.java:70) ~[?:?]
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoShapeCellValues.advanceExact(GeoShapeCellValues.java:34) ~[?:?]
    at org.elasticsearch.search.aggregations.bucket.geogrid.GeoGridAggregator$1.collect(GeoGridAggregator.java:78) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.search.aggregations.LeafBucketCollector.collect(LeafBucketCollector.java:107) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.apache.lucene.search.MultiCollector$MultiLeafCollector.collect(MultiCollector.java:188) ~[lucene-core-8.6.0-snapshot-9d6c738ffce.jar:8.6.0-snapshot-9d6c738ffce 9d6c738ffce0c3164691f161ba8b92a615b1e062 - jenkins - 2020-05-20 09:52:47]
    at org.apache.lucene.search.Weight$DefaultBulkScorer.scoreRange(Weight.java:242) ~[lucene-core-8.6.0-snapshot-9d6c738ffce.jar:8.6.0-snapshot-9d6c738ffce 9d6c738ffce0c3164691f161ba8b92a615b1e062 - jenkins - 2020-05-20 09:52:47]
    at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:229) ~[lucene-core-8.6.0-snapshot-9d6c738ffce.jar:8.6.0-snapshot-9d6c738ffce 9d6c738ffce0c3164691f161ba8b92a615b1e062 - jenkins - 2020-05-20 09:52:47]
    at org.elasticsearch.search.internal.CancellableBulkScorer.score(CancellableBulkScorer.java:56) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39) ~[lucene-core-8.6.0-snapshot-9d6c738ffce.jar:8.6.0-snapshot-9d6c738ffce 9d6c738ffce0c3164691f161ba8b92a615b1e062 - jenkins - 2020-05-20 09:52:47]
    at org.elasticsearch.search.internal.ContextIndexSearcher.searchLeaf(ContextIndexSearcher.java:213) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:186) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445) ~[lucene-core-8.6.0-snapshot-9d6c738ffce.jar:8.6.0-snapshot-9d6c738ffce 9d6c738ffce0c3164691f161ba8b92a615b1e062 - jenkins - 2020-05-20 09:52:47]
    at org.elasticsearch.search.query.QueryPhase.searchWithCollector(QueryPhase.java:348) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.search.query.QueryPhase.executeInternal(QueryPhase.java:299) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:151) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.indices.IndicesService.lambda$loadIntoContext$22(IndicesService.java:1382) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.indices.IndicesService$$Lambda$5361/0x0000000801b16840.accept(Unknown Source) ~[?:?]
    at org.elasticsearch.indices.IndicesService.lambda$cacheShardLevelResult$23(IndicesService.java:1434) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.indices.IndicesService$$Lambda$5363/0x0000000801b16040.get(Unknown Source) ~[?:?]
    at org.elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:178) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:161) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
    at org.elasticsearch.common.cache.Cache.computeIfAbsent(Cache.java:434) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
fatal error in thread [elasticsearch[Thomass-MBP.attlocal.net][search][T#9]], exiting
java.lang.OutOfMemoryError: Java heap space
    at org.apache.lucene.util.ArrayUtil.growExact(ArrayUtil.java:323)
    at org.apache.lucene.util.ArrayUtil.grow(ArrayUtil.java:332)
    at org.elasticsearch.index.fielddata.SortingNumericDocValues.resize(SortingNumericDocValues.java:62)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoShapeCellValues.resizeCell(GeoShapeCellValues.java:54)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:123)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValuesByRasterization(GeoTileGridTiler.java:131)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoTileGridTiler.setValues(GeoTileGridTiler.java:69)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoShapeCellValues.advanceValue(GeoShapeCellValues.java:70)
    at org.elasticsearch.xpack.spatial.search.aggregations.bucket.geogrid.GeoShapeCellValues.advanceExact(GeoShapeCellValues.java:34)
    at org.elasticsearch.search.aggregations.bucket.geogrid.GeoGridAggregator$1.collect(GeoGridAggregator.java:78)
    at org.elasticsearch.search.aggregations.LeafBucketCollector.collect(LeafBucketCollector.java:107)
    at org.apache.lucene.search.MultiCollector$MultiLeafCollector.collect(MultiCollector.java:188)
    at org.apache.lucene.search.Weight$DefaultBulkScorer.scoreRange(Weight.java:242)
    at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:229)
    at org.elasticsearch.search.internal.CancellableBulkScorer.score(CancellableBulkScorer.java:56)
    at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
    at org.elasticsearch.search.internal.ContextIndexSearcher.searchLeaf(ContextIndexSearcher.java:213)
    at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:186)
    at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:445)
    at org.elasticsearch.search.query.QueryPhase.searchWithCollector(QueryPhase.java:348)
    at org.elasticsearch.search.query.QueryPhase.executeInternal(QueryPhase.java:299)
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:151)
    at org.elasticsearch.indices.IndicesService.lambda$loadIntoContext$22(IndicesService.java:1382)
    at org.elasticsearch.indices.IndicesService$$Lambda$5361/0x0000000801b16840.accept(Unknown Source)
    at org.elasticsearch.indices.IndicesService.lambda$cacheShardLevelResult$23(IndicesService.java:1434)
    at org.elasticsearch.indices.IndicesService$$Lambda$5363/0x0000000801b16040.get(Unknown Source)
    at org.elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:178)
    at org.elasticsearch.indices.IndicesRequestCache$Loader.load(IndicesRequestCache.java:161)

cc @talevy @nknize

elasticmachine commented 4 years ago

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