maytasm opened a new pull request #10120:
URL: https://github.com/apache/druid/pull/10120


   Fix Stack overflow with infinite loop in ReduceExpressionsRule of HepProgram
   
   ### Description
   
   This fix https://github.com/apache/druid/issues/9906
   
   Due to Calcite bug (CALCITE-3845), ReduceExpressionsRule can considered 
expression which is the same as the previous input expression as reduced. 
Basically, the expression is actually not reduced but is still considered as 
reduced. Hence, this resulted in an infinite loop of Calcite trying to reducing 
the same expression over and over in ReduceExpressionsRule. Calcite 1.23.0 
fixes this issue by not consider expression as reduced if this case happens. 
However, while we are still using Calcite 1.21.0, a workaround is to limit the 
number of pattern matches to avoid infinite loop in ReduceExpressionsRule of 
the HepProgram. One example of this case is the query `SELECT ARRAY ['Hello', 
NULL]`
   
   The matchLimit value of 1200 is chosen with the suggestion by a Calcite 
committer.
   
   This PR has:
   - [x] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to