vikiuvb opened a new issue, #23548:
URL: https://github.com/apache/shardingsphere/issues/23548

   ## Bug Report
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   master branch, 
([f6ad3b2](https://github.com/apache/shardingsphere/commit/f6ad3b27f29e9e4c004322d2a6228fdbe52d7a4e))
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy
   
   ### Expected behavior
   The query is executed successfully
   
   ### Actual behavior
   ```ERROR 30000 (HY000) at line 1: Unknown exception: null```
   
   ### Reason analyze (If you can)
   When the meta data is refreshed, the ShardingSphereDatabase is pointing to 
an incorrect configuration. 
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   1) Register a storage unit in ShardingSphere **[ShardingSphere Session - 1]**
   ```
   REGISTER STORAGE UNIT ds_0 (
       HOST="127.0.0.1",
       PORT=3306,
       DB="db_1",
       USER="root",
       PASSWORD="root",
       PROPERTIES("maximumPoolSize"=10)
   );
   ```
   
   2) Create a table in MySQL in the `db_1` database  **[MySQL Session - 1]**
   ```
   CREATE TABLE t_table_test (
    id VARCHAR(100) NOT NULL PRIMARY KEY,
   user_id int NOT NULL
   )
   
   INSERT INTO db_1 SET id="hello", user_id=1;
   ```
   
   3) Run the query in the ShardingSphere  **[ShardingSphere Session - 1]**
   ```
   SELECT * FROM t_table_test; //Returns 1 record
   ```
   
   4) Put a breakpoint in the line 274 of the 
`[ContextManager.java](https://github.com/apache/shardingsphere/blob/master/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java#L274)`
   
   5) Alter the storage unit **[ShardingSphere Session - 1]**
   ```
   ALTER STORAGE UNIT ds_0 (
       HOST="127.0.0.1",
       PORT=3306,
       DB="db_1",
       USER="root",
       PASSWORD="root",
       PROPERTIES("maximumPoolSize"=50)
   );
   ```
   
   6) Run the query in the ShardingSphere **[ShardingSphere Session - 2]**
   ```
   SELECT * FROM t_table_test; //throw NPE
   ```
   
   The following exception is logged 
   
   ```
   java.lang.NullPointerException: null
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement.setFetchSize(JDBCBackendStatement.java:73)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement.createStorageResource(JDBCBackendStatement.java:45)
        at 
org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.JDBCBackendStatement.createStorageResource(JDBCBackendStatement.java:39)
        at 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.StatementExecutionUnitBuilder.createStatement(StatementExecutionUnitBuilder.java:45)
        at 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.StatementExecutionUnitBuilder.build(StatementExecutionUnitBuilder.java:40)
        at 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.builder.StatementExecutionUnitBuilder.build(StatementExecutionUnitBuilder.java:35)
        at 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine.createExecutionGroup(DriverExecutionPrepareEngine.java:100)
        at 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine.group(DriverExecutionPrepareEngine.java:91)
        at 
org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine.prepare(AbstractExecutionPrepareEngine.java:63)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.useDriverToExecute(ProxySQLExecutor.java:222)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.doExecute(ProxySQLExecutor.java:186)
        at 
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:151)
        at 
org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:176)
        at 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:92)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:110)
        at 
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:77)
        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)
   ```
   
   The `storageTypes` in the ShardingSphereResourceMetaData doesn't have an 
entry for the `ds_0` datasource.
   
   **Fix:**
   
   
   We need to ensure that only well-formed objects are published. 


-- 
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.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to