ElasticSearch失败,并显示OutOfMemoryError

时间:2019-04-22 12:12:42

标签: elasticsearch

我有3个节点的绿色ES群集。一切正常,但是最近有一些失败。

[2019-04-22T11:05:37,099][WARN ][o.e.t.OutboundHandler    ] [node_1] send message failed [channel: Netty4TcpChannel{localAddress=/172.0.0.1:9300, remoteAddress=/172.0.0.2:41674}]
java.nio.channels.ClosedChannelException: null
        at io.netty.channel.AbstractChannel$AbstractUnsafe.write(...)(Unknown Source) ~[?:?]
[2019-04-22T11:05:37,096][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node_1] fatal error in thread [elasticsearch[node_1][search][T#2]], exiting
java.lang.OutOfMemoryError: Java heap space
        at org.apache.lucene.util.ArrayUtil.growExact(ArrayUtil.java:302) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.ArrayUtil.grow(ArrayUtil.java:311) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.automaton.Automaton$Builder.addTransition(Automaton.java:715) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.automaton.UTF32ToUTF8.all(UTF32ToUTF8.java:247) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.automaton.UTF32ToUTF8.end(UTF32ToUTF8.java:231) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.automaton.UTF32ToUTF8.build(UTF32ToUTF8.java:194) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.automaton.UTF32ToUTF8.convertOneEdge(UTF32ToUTF8.java:137) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.automaton.UTF32ToUTF8.convert(UTF32ToUTF8.java:307) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.util.automaton.CompiledAutomaton.<init>(CompiledAutomaton.java:230) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.search.AutomatonQuery.<init>(AutomatonQuery.java:104) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.search.AutomatonQuery.<init>(AutomatonQuery.java:81) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.search.WildcardQuery.<init>(WildcardQuery.java:67) ~[lucene-core-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:16:28]
        at org.apache.lucene.queryparser.classic.QueryParserBase.newWildcardQuery(QueryParserBase.java:644) ~[lucene-queryparser-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:17:41]
        at org.apache.lucene.queryparser.classic.QueryParserBase.getWildcardQuery(QueryParserBase.java:703) ~[lucene-queryparser-7.7.0.jar:7.7.0 8c831daf4eb41153c25ddb152501ab5bae3ea3d5 - jimczi - 2019-02-04 23:17:41]
        at org.elasticsearch.index.search.QueryStringQueryParser.getWildcardQuerySingle(QueryStringQueryParser.java:682) ~[elasticsearch-6.7.1.jar:6.7.1]

还有一些问题:

  1. 正如您在日志中看到的那样,通配符查询是最后一次(两次),这是否意味着ES在通配符期间失败或仅仅是巧合?
  2. 如果是,失败的原因可能是什么?错误的搜索查询会导致这种错误吗?

1 个答案:

答案 0 :(得分:1)

正如lendrojmp所说,通配符会占用大量内存,尤其是如果它以*开头。

根据文档:

  

为了防止极慢的通配符查询,请使用通配符   不应以通配符*或?之一开头。通配符查询   映射到Lucene WildcardQuery。

https://www.elastic.co/guide/en/elasticsearch/reference/7.0/query-dsl-wildcard-query.html

您还可以检查日志目录中的gc.log.xx文件(默认为/ var / log / elasticsearch)。您可能有更多的见识,请同时查看慢查询日志。

还请检查以下信息:https://www.elastic.co/blog/found-crash-elasticsearch

您可能会由于其他原因耗尽资源,而通配符搜索会占用剩余的内存并导致服务器崩溃。