You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/03/25 02:24:07 UTC

[GitHub] [incubator-shardingsphere] FleyX opened a new issue #2076: node sharding table dql did not use default data source

FleyX opened a new issue #2076: node sharding table dql did not use default data source
URL: https://github.com/apache/incubator-shardingsphere/issues/2076
 
 
   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
   - Read documentation: [ShardingSphere Doc](http://shardingsphere.io/document/current/en/overview/).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   3.1.0
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   ### Expected behavior
   no sharding tables  use default-data-source
   ### Actual behavior
   no sharding tables's select actions did not use default-data-source(ds2) but use ds0.
   But update,insert and delete actions use ds2
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   config:
   ```yaml
   sharding:
     jdbc:
       datasource:
         names: ds0,ds1,ds2
         ds0:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.jdbc.Driver
           url: jdbc:mysql://10.82.27.177:3306/ds0
           username: root
           password: 123456
         ds1:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.jdbc.Driver
           url: jdbc:mysql://10.82.27.177:3306/ds1
           username: root
           password: 123456
         ds2:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.jdbc.Driver
           url: jdbc:mysql://10.82.27.177:3306/ds2
           username: root
           password: 123456
       config:
         sharding:
           # 默认数据源,可以将不分库分表的数据表放在这里
           default-data-source-name: ds2
           default-database-strategy:
             inline:
               sharding-column: uId
               algorithm-expression: ds$->{uId % 2}
           tables:
             order:
               key-generator-column-name: orderId
               actual-data-nodes: ds$->{0..1}.order$->{0..1}
               table-strategy:
                 inline:
                   sharding-column: orderId
                   algorithm-expression: order$->{orderId%2}
             order_item:
               key-generator-column-name: orderItemId
               actual-data-nodes: ds$->{0..1}.order_item$->{0..1}
               table-strategy:
                 inline:
                   sharding-column: orderId
                   algorithm-expression: orderItemId$->{orderId%2}
         props:
           sql.show: true
   ```
   
   test sql
   ```java
   try (
           try (
                   Connection conn = dataSource.getConnection();
                   Statement statement = conn.createStatement();
           ) {
               statement.execute("insert into user(name,age) value('2012-12-12 12:12:12',1212)");
               statement.execute("select * from user");
           }
   ```
   
   log:
   ```log
    ShardingSphere-SQL                       : Rule Type: sharding
   ShardingSphere-SQL                       : Logic SQL: insert into user(name,age) value('2012-12-12 12:12:12',1212)
    ShardingSphere-SQL                       : SQLStatement: InsertStatement(super=DMLStatement(super=io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement@33215ffb), columns=[Column(name=name, tableName=user), Column(name=age, tableName=user)], generatedKeyConditions=[], insertValues=InsertValues(insertValues=[InsertValue(type=VALUES, expression=('2012-12-12 12:12:12',1212), parametersCount=0)]), columnsListLastPosition=25, generateKeyColumnIndex=-1, insertValuesListLastPosition=60)
    ShardingSphere-SQL                       : Actual SQL: ds2 ::: insert into user(name,age) value('2012-12-12 12:12:12',1212)
    ShardingSphere-SQL                       : Rule Type: sharding
    ShardingSphere-SQL                       : Logic SQL: select * from user
    ShardingSphere-SQL                       : SQLStatement: SelectStatement(super=DQLStatement(super=io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement@12548f9a), containStar=true, firstSelectItemStartPosition=7, selectListLastPosition=9, groupByLastPosition=0, items=[StarSelectItem(owner=Optional.absent())], groupByItems=[], orderByItems=[], limit=null, subQueryStatement=null, subQueryStatements=[], subQueryConditions=[])
   
    ShardingSphere-SQL                       : Actual SQL: ds0 ::: select * from user
   ```
   
   ### 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:
users@infra.apache.org


With regards,
Apache Git Services