Skip to content

Stack overflow during parsing of SQL causes elasticsearch service to crash #32942

@AdiJurca

Description

@AdiJurca

Elasticsearch version (bin/elasticsearch --version):
Version: 6.3.0, Build: default/rpm/424e937/2018-06-11T23:38:03.357887Z, JVM: 1.8.0_121

Plugins installed: []

JVM version (java -version):
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

OS version (uname -a if on a Unix-like system):
Linux se10tsnbe06.tclk.se.om.com 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Dec 28 14:23:39 EST 2017 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
Running a query that has many OR expressions(in lac of IN clause) through the JDBC driver causes a stack overflow while parsing the SQL which crashes the instance of elasticsearch.

It's probably not ok to have a query with so many OR expression, but in lack of an IN clause we did what we could. But we would expect that this does not to crash the entire node.

stack_overflow_crash_files.zip

Steps to reproduce:

  1. Create an index with given mapping (attached file: index_mapping.json)
  2. Perform given query through JDBC(attachd file: crashy.sql)
  3. Notice at least one node in the cluster goes down.

Provide logs (if relevant):
[2018-08-16T17:41:34,222][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [SDD-N3] fatal error in thread [Thread-18], exiting
java.lang.StackOverflowError: null
at org.elasticsearch.xpack.sql.parser.SqlBaseParser$LogicalBinaryContext.accept(SqlBaseParser.java:2742) ~[?:?]
at org.elasticsearch.xpack.sql.parser.AbstractBuilder.typedParsing(AbstractBuilder.java:40) ~[?:?]
at org.elasticsearch.xpack.sql.parser.ExpressionBuilder.expression(ExpressionBuilder.java:101) ~[?:?]
at org.elasticsearch.xpack.sql.parser.ExpressionBuilder.visitLogicalBinary(ExpressionBuilder.java:410) ~[?:?]
at org.elasticsearch.xpack.sql.parser.SqlBaseParser$LogicalBinaryContext.accept(SqlBaseParser.java:2742) ~[?:?]
at org.elasticsearch.xpack.sql.parser.AbstractBuilder.typedParsing(AbstractBuilder.java:40) ~[?:?]
at org.elasticsearch.xpack.sql.parser.ExpressionBuilder.expression(ExpressionBuilder.java:101) ~[?:?]
at org.elasticsearch.xpack.sql.parser.ExpressionBuilder.visitLogicalBinary(ExpressionBuilder.java:410) ~[?:?]
at org.elasticsearch.xpack.sql.parser.SqlBaseParser$LogicalBinaryContext.accept(SqlBaseParser.java:2742) ~[?:?]
at org.elasticsearch.xpack.sql.parser.AbstractBuilder.typedParsing(AbstractBuilder.java:40) ~[?:?]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions