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

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

Closed
AdiJurca opened this issue Aug 17, 2018 · 1 comment
Closed

Comments

@AdiJurca
Copy link

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) ~[?:?]

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

matriv added a commit to matriv/elasticsearch that referenced this issue Sep 20, 2018
Catch StackOverflowError exception and return a descriptive message
to the client. This prevents large statement from killing the cluster.

Fixes: elastic#32942
@matriv matriv self-assigned this Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants