-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix: catch stack overflow error when parsing/preparing statements #6727
fix: catch stack overflow error when parsing/preparing statements #6727
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests to verify this?
accumulator.visit(parseTree); | ||
return accumulator.getSources(); | ||
} catch (StackOverflowError e) { | ||
throw new KsqlException("Error processing statement: Statement is too large to parse."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: might make sense to include the GH ticket in the error message so that users can understand which part and what to do about it (namely, make the nested parenthesis less nested)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the error messages to suggest that nested expressions could be causing the error.
41ff83c
to
5b53318
Compare
5b53318
to
45e7efe
Compare
For some reason, I couldn't get the QTT test to pass on the PR builder even though it passes locally, it'd fail with another stack overflow error
So I moved the test to KsqlResourceTest |
Description
#5882
There were two possible places throwing the stack overflow error, while parsing/preparing.
One suggestion was to limit the Where clause size, but I don't think that's an optimal since it's possible to have a large where clause and not hit this issue. The error is being thrown when recursively trying to evaluate the boolean expression that's part of the Where clause, and the number of nested parentheses expressions is causing the deep recursion tree, but if the boolean expression was something like `Where ITM.ITEM_ID = '61151234123412345......(very long id)....12341234123412341', there wouldn't be the overflow, but the expression would have a large size.
So I just ended up catching the stack overflow error and throwing a more helpful exception.
Testing done
I Issued large where clause statement and verifying both error messages were returned.
Reviewer checklist