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/11/09 11:41:20 UTC

[GitHub] [shardingsphere] kimmking opened a new issue #8099: Selecting data lead NPE when two datasources have duplicated tables

kimmking opened a new issue #8099:
URL: https://github.com/apache/shardingsphere/issues/8099


   Hi, there are two db named test0&test1, 
   test0 have some tables: account, person, test0{0-2}
   test1 have some tables: account, test0{0-2}
   
   then we config a logic schema to make test as a logic sharding table test in a proxy.
   and then we use mysql command to access proxy, selecting data from test will work well, and from account/person will be NPE.
   ```
   mysql> select * from test;
   +--------------------+------+---------------------+
   | id                 | name | created             |
   +--------------------+------+---------------------+
   |                  6 | KK06 | 2020-10-13 15:06:03 |
   |                 12 | KK12 | 2020-10-13 15:06:27 |
   |                120 | KK00 | 2020-10-14 12:18:11 |
   +--------------------+------+---------------------+
   3 rows in set (0.19 sec)
   
   mysql> select * from account;
   ERROR 10002 (C1000): 2Unknown exception: [null]
   mysql> select * from person;
   ERROR 10002 (C1000): 2Unknown exception: [null]
   ```
   
   Configurations:
   ```
   schemaName: testproxy
   
   dataSources:
     test0:
       url: jdbc:mysql://127.0.0.1:3306/test0?serverTimezone=UTC&useSSL=false
       username: root
       password: 
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     test1:
       url: jdbc:mysql://127.0.0.1:3306/test1?serverTimezone=UTC&useSSL=false
       username: root
       password: 
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
   
   rules:
   - !SHARDING
     tables:
       test:
         actualDataNodes: test${0..1}.test0${0..2}
         tableStrategy:
           standard:
             shardingColumn: id
             shardingAlgorithmName: test_inline
         keyGenerateStrategy:
             column: id
             keyGeneratorName: snowflake
     defaultDatabaseStrategy:
       standard:
         shardingColumn: id
         shardingAlgorithmName: database_inline
     defaultTableStrategy:
       none:
   
     shardingAlgorithms:
       database_inline:
         type: INLINE
         props:
           algorithm-expression: test${id % 2}
       test_inline:
         type: INLINE
         props:
           algorithm-expression: test0${id % 3}
   
     keyGenerators:
         snowflake:
           type: SNOWFLAKE
           props:
               worker-id: 123
   
   ```
   ![image](https://user-images.githubusercontent.com/807508/98536287-8547b100-22c2-11eb-9961-4cbed9620ba5.png)
   
   
   Selecting data from test will work well, and from account/person will be NPE.
   
   ```
   [ERROR] 19:27:07.803 [ShardingSphere-Command-4] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
   java.util.NoSuchElementException: null
   	at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:721)
   	at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:742)
   	at org.apache.shardingsphere.sharding.route.engine.type.single.SingleTableRoutingEngine.findDataSourceName(SingleTableRoutingEngine.java:64)
   	at org.apache.shardingsphere.sharding.route.engine.type.single.SingleTableRoutingEngine.route(SingleTableRoutingEngine.java:52)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:70)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:55)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:59)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:57)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:52)
   	at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:77)
   	at org.apache.shardingsphere.proxy.backend.text.query.QueryBackendHandler.execute(QueryBackendHandler.java:61)
   	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:62)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:100)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:76)
   	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)
   ```
   ![image](https://user-images.githubusercontent.com/807508/98536263-79f48580-22c2-11eb-8eb5-701645fb9f10.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.

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



[GitHub] [shardingsphere] huanghao495430759 commented on issue #8099: Selecting data lead NPE when two datasources have duplicated tables

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


   @kimmking I think you should add person and account to broadcast-tables, Such as the following:
   
   `spring.shardingsphere.sharding.broadcast-tables=person,account`
   
   or add default database name :
   `spring.shardingsphere.sharding.default-data-source-name=XXX`


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



[GitHub] [shardingsphere] kimmking edited a comment on issue #8099: Selecting data lead NPE when two datasources have duplicated tables

Posted by GitBox <gi...@apache.org>.
kimmking edited a comment on issue #8099:
URL: https://github.com/apache/shardingsphere/issues/8099#issuecomment-726748362


   > @kimmking I think you should add person and account to broadcast-tables, Such as the following:
   > 
   > `spring.shardingsphere.sharding.broadcast-tables=person,account`
   > 
   > or add default database name :
   > `spring.shardingsphere.sharding.default-data-source-name=XXX`
   
   It doesn't matter in 5.x.


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



[GitHub] [shardingsphere] kimmking closed issue #8099: Selecting data lead NPE when two datasources have duplicated tables

Posted by GitBox <gi...@apache.org>.
kimmking closed issue #8099:
URL: https://github.com/apache/shardingsphere/issues/8099


   


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



[GitHub] [shardingsphere] kimmking commented on issue #8099: Selecting data lead NPE when two datasources have duplicated tables

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


   remove duplicated table, there will be normal.


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



[GitHub] [shardingsphere] kimmking commented on issue #8099: Selecting data lead NPE when two datasources have duplicated tables

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


   > @kimmking I think you should add person and account to broadcast-tables, Such as the following:
   > 
   > `spring.shardingsphere.sharding.broadcast-tables=person,account`
   > 
   > or add default database name :
   > `spring.shardingsphere.sharding.default-data-source-name=XXX`
   
   It doesn't matter.


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