You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2023/01/13 12:09:56 UTC

[GitHub] [shardingsphere] vikiuvb opened a new issue, #23548: ALTER STORAGE UNIT causes NPE

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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

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


[GitHub] [shardingsphere] vikiuvb commented on issue #23548: ALTER STORAGE UNIT causes NPE

Posted by GitBox <gi...@apache.org>.
vikiuvb commented on issue #23548:
URL: https://github.com/apache/shardingsphere/issues/23548#issuecomment-1382318081

   @RaigorJiang The purpose of the breakpoint is to simulate the data race in live traffic. This scenario will occur when the ShardingSphere proxy is serving live traffic and a storage unit configuration is altered. Since we are publishing a half baked data into the `metaData` context, it will cause a momentary disruption in the traffic. 


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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


[GitHub] [shardingsphere] RaigorJiang commented on issue #23548: ALTER STORAGE UNIT causes NPE

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #23548:
URL: https://github.com/apache/shardingsphere/issues/23548#issuecomment-1383162257

   @vikiuvb I agree with you.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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


[GitHub] [shardingsphere] RaigorJiang commented on issue #23548: ALTER STORAGE UNIT causes NPE

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #23548:
URL: https://github.com/apache/shardingsphere/issues/23548#issuecomment-1383162611

   Metadata management, especially refreshing, is a relatively complicated job, and I think more design is needed.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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


Re: [I] ALTER STORAGE UNIT causes NPE [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #23548: ALTER STORAGE UNIT causes NPE
URL: https://github.com/apache/shardingsphere/issues/23548


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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


[GitHub] [shardingsphere] RaigorJiang commented on issue #23548: ALTER STORAGE UNIT causes NPE

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #23548:
URL: https://github.com/apache/shardingsphere/issues/23548#issuecomment-1382105370

   Hi @vikiuvb ,
   Thanks for your feedback, does it work properly without breakpoint?
   By the way, your way of testing is interesting :)


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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