lwtdev opened a new issue #7548:
URL: https://github.com/apache/shardingsphere/issues/7548


   ## Throw NPE at ExecutionContextBuilder.getPrimaryKeyColumns when execute sql
   
   ### Which version of ShardingSphere did you use?
   5.0.0-RC1-SNAPSHOT
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy
   
   ### Expected behavior
   
   
   ### Actual behavior
   ```sql
   mysql> select * from customer where id = 3;
   ERROR 10002 (C1000): 2Unknown exception: [null]
   ```
   log
   ```
   java.lang.NullPointerException: null
           at 
org.apache.shardingsphere.infra.executor.sql.context.ExecutionContextBuilder.getPrimaryKeyColumns(ExecutionContextBuilder.java:129)
           at 
org.apache.shardingsphere.infra.executor.sql.context.ExecutionContextBuilder.getSQLRuntimeContext(ExecutionContextBuilder.java:81)
           at 
org.apache.shardingsphere.infra.executor.sql.context.ExecutionContextBuilder.build(ExecutionContextBuilder.java:71)
           at 
org.apache.shardingsphere.infra.executor.sql.context.ExecutionContextBuilder.build(ExecutionContextBuilder.java:57)
           at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:53)
           at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:67)
           at 
org.apache.shardingsphere.proxy.backend.text.query.QueryBackendHandler.execute(QueryBackendHandler.java:64)
           at 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:62)
           at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:100)
           at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:76)
           at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
           at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
           at java.lang.Thread.run(Thread.java:748)
   ```
   
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   - prepare sql
   ```sql
   create database spsqltest_sharding_00;
   create database spsqltest_sharding_01;
   ```
   
   - ```config-test.yaml```
   ```yaml
   schemaName: test
   #
   dataSourceCommon:
     username: root
     password: root135
     connectionTimeoutMilliseconds: 30000
     idleTimeoutMilliseconds: 60000
     maxLifetimeMilliseconds: 1800000
     maxPoolSize: 50
     minPoolSize: 1
     maintenanceIntervalMilliseconds: 30000
   #
   dataSources:
     ds_00:
       url: 
jdbc:mysql://127.0.0.1:3306/spsqltest_sharding_00?serverTimezone=UTC&useSSL=false
     ds_01:
       url: 
jdbc:mysql://127.0.0.1:3306/spsqltest_sharding_01?serverTimezone=UTC&useSSL=false
   #
   rules:
   - !SHARDING
     tables:
       customer:
         actualDataNodes: ds_00.customer_000${0..1},ds_01.customer_000${2..3}
         databaseStrategy:
           standard:
             shardingColumn: id
             shardingAlgorithmName: database_inline
         tableStrategy:
           standard:
             shardingColumn: id
             shardingAlgorithmName: customer_inline
       customer_email:
         actualDataNodes: 
ds_00.customer_email_000${0..1},ds_01.customer_email_000${2..3}
         databaseStrategy:
           standard:
             shardingColumn: id
             shardingAlgorithmName: database_inline
         tableStrategy:
           standard:
             shardingColumn: id
             shardingAlgorithmName: customer_email_inline
     bindingTables:
       - customer,customer_email
     defaultDatabaseStrategy:
       none:
     defaultTableStrategy:
       none:
   
     shardingAlgorithms:
       database_inline:
         type: INLINE
         props:
           algorithm-expression: ds_0${id % 2}
       customer_inline:
         type: INLINE
         props:
           algorithm-expression: customer_000${id % 4}
       customer_email_inline:
         type: INLINE
         props:
           algorithm-expression: customer_email_000${id % 4}
   ```
   
   - execute sql
   ```sql
   select * from customer where id = 3;
   ```
   
   ### Example codes for reproduce this issue (such as a github link).
   


----------------------------------------------------------------
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:
[email protected]


Reply via email to