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 2020/02/06 07:41:15 UTC

[GitHub] [incubator-shardingsphere] KomachiSion opened a new issue #4182: Sharding-proxy 4.0.0 can query columns for table

KomachiSion opened a new issue #4182: Sharding-proxy 4.0.0 can query columns for table
URL: https://github.com/apache/incubator-shardingsphere/issues/4182
 
 
   ## Bug Report
   
   When query columns of sharding table by `getColumns` method of JDBC, sharding-proxy will throw exception:
   ```
   Exception in thread "main" java.sql.SQLException: 2Unknown exception: [Cannot find table rule and default data source with logic table: '%']
   	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
   	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
   	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
   	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
   	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2828)
   	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2777)
   	at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1651)
   	at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2711)
   	at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2598)
   	at com.mysql.jdbc.IterateBlock.doForAll(IterateBlock.java:50)
   	at com.mysql.jdbc.DatabaseMetaData.getColumns(DatabaseMetaData.java:2597)
   	at jdbc.JDBCUtil.main(JDBCUtil.java:38)
   ```
   
   But I used sharding-proxy 4.0.0-RC2, It can work well.
   
   ### Which version of ShardingSphere did you use?
   
   4.0.0
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   
   Sharding-Proxy
   
   ### Expected behavior
   
   get Column info from Result Set.
   
   ### Actual behavior
   
   Throw exception.
   
   ### Reason analyze (If you can)
   
   the method `getColumn` should map to SQL `SHOW FULL COLUMNS ...`
   
   So I think there are some error in `parse` or `extractor`.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ```yaml
   schemaName: sharding_db
   
   dataSources:
    ds_0:
      url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
      username: root
      password:
      connectionTimeoutMilliseconds: 30000
      idleTimeoutMilliseconds: 60000
      maxLifetimeMilliseconds: 1800000
      maxPoolSize: 50
    ds_1:
      url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
      username: root
      password:
      connectionTimeoutMilliseconds: 30000
      idleTimeoutMilliseconds: 60000
      maxLifetimeMilliseconds: 1800000
      maxPoolSize: 50
   
   shardingRule:
    tables:
      t_order:
        actualDataNodes: ds_${0..1}.t_order_${0..1}
        tableStrategy:
          inline:
            shardingColumn: order_id
            algorithmExpression: t_order_${order_id % 2}
        keyGenerator:
          type: SNOWFLAKE
          column: order_id
      t_order_item:
        actualDataNodes: ds_${0..1}.t_order_item_${0..1}
        tableStrategy:
          inline:
            shardingColumn: order_id
            algorithmExpression: t_order_item_${order_id % 2}
        keyGenerator:
          type: SNOWFLAKE
          column: order_item_id
    bindingTables:
      - t_order,t_order_item
    defaultDatabaseStrategy:
      inline:
        shardingColumn: user_id
        algorithmExpression: ds_${user_id % 2}
    defaultTableStrategy:
      none:
   
   ```
   
   ### Example codes for reproduce this issue (such as a github link).
   
   ```java
           Class.forName("com.mysql.jdbc.Driver");
           try (Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3307/sharding_db", "root", "root");
               Statement statement = connection.createStatement()) {
               ResultSet rs = metaData.getColumns("sharding_db", null, "t_order", "%");
          }
   ```
   

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

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #4182: Sharding-proxy 4.0.0 can query columns for table

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #4182: Sharding-proxy 4.0.0 can query columns for table
URL: https://github.com/apache/incubator-shardingsphere/issues/4182#issuecomment-582779991
 
 
   ```
   [INFO ] 15:27:04.980 [ShardingSphere-Command-4] ShardingSphere-SQL - Rule Type: sharding
   [INFO ] 15:27:04.981 [ShardingSphere-Command-4] ShardingSphere-SQL - Logic SQL: SHOW FULL TABLES FROM `sharding_db` LIKE 't_order'
   [INFO ] 15:27:04.981 [ShardingSphere-Command-4] ShardingSphere-SQL - SQLStatement: CommonSQLStatementContext(sqlStatement=org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.mysql.ShowTablesStatement@7d8a9fd6, tablesContext=TablesContext(tables=[Table(name=t_order, alias=Optional.absent())], schema=Optional.absent()))
   [INFO ] 15:27:04.981 [ShardingSphere-Command-4] ShardingSphere-SQL - Actual SQL: ds_0 ::: SHOW FULL TABLES  LIKE 't_order_0'
   [ERROR] 15:27:04.993 [ShardingSphere-Command-5] o.a.s.s.f.c.CommandExecutorTask - Exception occur: 
   org.apache.shardingsphere.core.config.ShardingConfigurationException: Cannot find table rule and default data source with logic table: '%'
   	at org.apache.shardingsphere.core.rule.ShardingRule.getTableRule(ShardingRule.java:191)
   	at org.apache.shardingsphere.core.route.type.unicast.UnicastRoutingEngine.route(UnicastRoutingEngine.java:78)
   	at org.apache.shardingsphere.core.route.router.sharding.ShardingRouter.route(ShardingRouter.java:113)
   	at org.apache.shardingsphere.core.route.StatementRoutingEngine.route(StatementRoutingEngine.java:54)
   	at org.apache.shardingsphere.core.SimpleQueryShardingEngine.route(SimpleQueryShardingEngine.java:58)
   	at org.apache.shardingsphere.core.BaseShardingEngine.executeRoute(BaseShardingEngine.java:85)
   	at org.apache.shardingsphere.core.BaseShardingEngine.shard(BaseShardingEngine.java:68)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.wrapper.StatementExecutorWrapper.doShardingRoute(StatementExecutorWrapper.java:79)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.wrapper.StatementExecutorWrapper.route(StatementExecutorWrapper.java:65)
   	at org.apache.shardingsphere.shardingproxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:83)
   	at org.apache.shardingsphere.shardingproxy.backend.text.admin.UnicastBackendHandler.execute(UnicastBackendHandler.java:57)
   	at org.apache.shardingsphere.shardingproxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:73)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:92)
   	at org.apache.shardingsphere.shardingproxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:72)
   	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)
   ```

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

[GitHub] [incubator-shardingsphere] tuohai666 commented on issue #4182: Sharding-proxy 4.0.0 can query columns for table

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #4182: Sharding-proxy 4.0.0 can query columns for table
URL: https://github.com/apache/incubator-shardingsphere/issues/4182#issuecomment-582779147
 
 
   @KomachiSion Can you provide logs with sql.show : true ? I want to see logic and actual SQLs.

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

[GitHub] [incubator-shardingsphere] terrymanu closed issue #4182: Sharding-proxy 4.0.0 can query columns for table

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #4182: Sharding-proxy 4.0.0 can query columns for table
URL: https://github.com/apache/incubator-shardingsphere/issues/4182
 
 
   

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

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #4182: Sharding-proxy 4.0.0 can query columns for table

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #4182: Sharding-proxy 4.0.0 can query columns for table
URL: https://github.com/apache/incubator-shardingsphere/issues/4182#issuecomment-582780361
 
 
   This is 4.0.0-RC2's log
   
   ```
   [INFO ] 15:23:26.941 [ShardingSphere-Command-4] ShardingSphere-SQL - Rule Type: sharding
   [INFO ] 15:23:26.941 [ShardingSphere-Command-4] ShardingSphere-SQL - Logic SQL: SHOW FULL TABLES FROM `sharding_db` LIKE 't_order'
   [INFO ] 15:23:26.941 [ShardingSphere-Command-4] ShardingSphere-SQL - SQLStatement: ShowTablesStatement(super=DALStatement(super=AbstractSQLStatement(sqlSegments=[org.apache.shardingsphere.core.parse.sql.segment.dal.FromSchemaSegment@5a10eea1, org.apache.shardingsphere.core.parse.sql.segment.dal.ShowLikeSegment@4bed4aa7], tables=Tables(tables=[Table(name=t_order, alias=Optional.absent())]), logicSQL=SHOW FULL TABLES FROM `sharding_db` LIKE 't_order', parametersCount=0)))
   [INFO ] 15:23:26.941 [ShardingSphere-Command-4] ShardingSphere-SQL - Actual SQL: ds_0 ::: SHOW FULL TABLES  LIKE 't_order_0'
   [INFO ] 15:23:26.955 [ShardingSphere-Command-5] ShardingSphere-SQL - Rule Type: sharding
   [INFO ] 15:23:26.955 [ShardingSphere-Command-5] ShardingSphere-SQL - Logic SQL: SHOW FULL COLUMNS FROM `t_order` FROM `sharding_db` LIKE '%'
   [INFO ] 15:23:26.955 [ShardingSphere-Command-5] ShardingSphere-SQL - SQLStatement: ShowColumnsStatement(super=DALStatement(super=AbstractSQLStatement(sqlSegments=[TableSegment(startIndex=23, stopIndex=31, name=t_order, quoteCharacter=BACK_QUOTE, owner=Optional.absent(), alias=Optional.absent()), org.apache.shardingsphere.core.parse.sql.segment.dal.FromSchemaSegment@591e40c6, org.apache.shardingsphere.core.parse.sql.segment.dal.ShowLikeSegment@4fa5a5b4], tables=Tables(tables=[Table(name=t_order, alias=Optional.absent())]), logicSQL=SHOW FULL COLUMNS FROM `t_order` FROM `sharding_db` LIKE '%', parametersCount=0)))
   [INFO ] 15:23:26.955 [ShardingSphere-Command-5] ShardingSphere-SQL - Actual SQL: ds_0 ::: SHOW FULL COLUMNS FROM `t_order_0`  LIKE '%'
   ```

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