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 2022/10/10 06:32:40 UTC

[GitHub] [shardingsphere] FlyingZC opened a new issue, #20452: Can't add resouce in read write splitting rule by DistSQL

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

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   proxy
   
   ### Expected behavior
   Can add resource successful in read write splitting rule.
   
   ### Actual behavior
   Report error.
   ```
   java.lang.IllegalStateException: Write data source name `write_ds` not in database `readwrite_splitting_db`.
   	at com.google.common.base.Preconditions.checkState(Preconditions.java:824)
   	at org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.checkWriteDataSourceNames(AbstractReadwriteSplittingRuleConfigurationChecker.java:83)
   	at org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.checkStaticStrategy(AbstractReadwriteSplittingRuleConfigurationChecker.java:74)
   	at org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.lambda$checkDataSources$0(AbstractReadwriteSplittingRuleConfigurationChecker.java:65)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.checkDataSources(AbstractReadwriteSplittingRuleConfigurationChecker.java:65)
   	at org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.check(AbstractReadwriteSplittingRuleConfigurationChecker.java:54)
   	at org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.lambda$build$0(DatabaseRulesBuilder.java:57)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.build(DatabaseRulesBuilder.java:57)
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:88)
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:51)
   	at org.apache.shardingsphere.mode.manager.ContextManager.createChangedDatabases(ContextManager.java:320)
   	at org.apache.shardingsphere.mode.manager.ContextManager.updateResources(ContextManager.java:214)
   	at org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.resource.AddResourceBackendHandler.execute(AddResourceBackendHandler.java:66)
   	at org.apache.shardingsphere.proxy.backend.handler.distsql.rdl.resource.AddResourceBackendHandler.execute(AddResourceBackendHandler.java:46)
   	at org.apache.shardingsphere.proxy.backend.handler.DatabaseRequiredBackendHandler.execute(DatabaseRequiredBackendHandler.java:51)
   	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:94)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:112)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:78)
   	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:750)
   ```
   
   ### Reason analyze (If you can)
   We needn't check the write data source name when add resource.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   1.configure read write splitting rule
   ```yaml
   databaseName: readwrite_splitting_db
   
   dataSources:
     write_ds:
       url: jdbc:mysql://127.0.0.1:3306/demo_write_ds?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
       username: root
       password: xx
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
     read_ds_0:
       url: jdbc:mysql://127.0.0.1:3306/demo_read_ds_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
       username: root
       password: xx
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
     read_ds_1:
       url: jdbc:mysql://127.0.0.1:3306/demo_read_ds_1?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
       username: root
       password: xx
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
       minPoolSize: 1
   
   rules:
   - !READWRITE_SPLITTING
     dataSources:
       readwrite_ds:
         staticStrategy:
           writeDataSourceName: write_ds
           readDataSourceNames:
             - read_ds_0
             - read_ds_1
         loadBalancerName: random
     loadBalancers:
       random:
         type: RANDOM
   ```
   
   2.add resouce by distsql
   ```sql
   ADD RESOURCE demo_ds_2 (
       HOST='127.0.0.1',
       PORT=3306,
       DB='demo_ds_2',
       USER='root',
       PASSWORD='xxx'
   );
   ```
   
   then the error happened.
   
   <img width="791" alt="image" src="https://user-images.githubusercontent.com/19788130/186106008-dd7d8f02-dc1a-46a2-ba44-0682b3597e75.png">
   
   
   ### 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.

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] RaigorJiang commented on issue #20452: Can't add resouce in read write splitting rule by DistSQL

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #20452:
URL: https://github.com/apache/shardingsphere/issues/20452#issuecomment-1407639027

   @FlyingZC 
   This issue has been fixed in the master branch, please try the latest version, thank you!
   
   <img width="1093" alt="image" src="https://user-images.githubusercontent.com/5668787/215323474-ef90e8e0-499e-4b7d-99a7-00f4d3b62bad.png">
   


-- 
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 closed issue #20452: Can't add resouce in read write splitting rule by DistSQL

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #20452: Can't add resouce in read write splitting rule by DistSQL
URL: https://github.com/apache/shardingsphere/issues/20452


-- 
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] github-actions[bot] closed issue #20452: Can't add resouce in read write splitting rule by DistSQL

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #20452: Can't add resouce in read write splitting rule by DistSQL
URL: https://github.com/apache/shardingsphere/issues/20452


-- 
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] github-actions[bot] commented on issue #20452: Can't add resouce in read write splitting rule by DistSQL

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #20452:
URL: https://github.com/apache/shardingsphere/issues/20452#issuecomment-1272348752

   Hello , this issue has not received a reply for several days.
   This issue is supposed to be closed.


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