apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.79k stars 6.7k forks source link

java.lang.OutOfMemoryError: GC overhead limit exceeded #24439

Closed 794086163 closed 3 months ago

794086163 commented 1 year ago

Which version of ShardingSphere did you use?

5.2.1

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

SQL executed correctly

Actual behavior

java.lang.OutOfMemoryError

Reason analyze (If you can)

When parsing SQL, there is an endless loop!!

image

at org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtil.extractAndPredicates(java.util.Collection, org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment) (line: 67)
at org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtil.getAndPredicates(org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment) (line: 50)
at org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtil.extractAndPredicates(java.util.Collection, org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment) (line: 66)
at org.apache.shardingsphere.sql.parser.sql.common.util.ExpressionExtractUtil.getAndPredicates(org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment) (line: 50)
at org.apache.shardingsphere.sql.parser.sql.common.util.ColumnExtractor.extractColumnSegments(java.util.Collection, java.util.Collection) (line: 72)
at org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext.<init>(java.util.Map, java.util.List, org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement, java.lang.String) (line: 110)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.getDMLStatementContext(java.util.Map, java.util.List, org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DMLStatement, java.lang.String) (line: 163)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(java.util.Map, java.util.List, org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement, java.lang.String) (line: 146)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(java.util.Map, org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement, java.lang.String) (line: 131)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection, java.lang.String, int, int, int, boolean, java.lang.String[ ]) (line: 196)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection, java.lang.String) (line: 160)
at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(java.lang.String) (line: 91)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(java.sql.Connection) (line: 86)
at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(java.sql.Connection, java.lang.Integer) (line: 88)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(java.sql.Connection, java.lang.Integer) (line: 59)
at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.prepareStatement(org.apache.ibatis.executor.statement.StatementHandler, org.apache.ibatis.logging.Log, boolean) (line: 94)
at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(org.apache.ibatis.mapping.MappedStatement, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.session.ResultHandler, org.apache.ibatis.mapping.BoundSql) (line: 68)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(org.apache.ibatis.mapping.MappedStatement, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.session.ResultHandler, org.apache.ibatis.cache.CacheKey, org.apache.ibatis.mapping.BoundSql) (line: 325)
at org.apache.ibatis.executor.BaseExecutor.query(org.apache.ibatis.mapping.MappedStatement, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.session.ResultHandler, org.apache.ibatis.cache.CacheKey, org.apache.ibatis.mapping.BoundSql) (line: 156)
at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(org.apache.ibatis.mapping.MappedStatement, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.session.ResultHandler, org.apache.ibatis.cache.CacheKey, org.apache.ibatis.mapping.BoundSql) (line: 165)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

SQL:

select * from test where (id = 1 or id =2) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) and (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 ) AND (id=3 or id =4 )

FlyingZC commented 1 year ago

@794086163 hi,would you want to fix this issue.

794086163 commented 1 year ago

extractAndPredicates

I don't know why SQL parses like this!! image

RoySunnySean007 commented 8 months ago

@794086163 thanks for fixing this issue, do we have the ETA to merge ur pr?

github-actions[bot] commented 6 months ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.