You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "gavenpeng (via GitHub)" <gi...@apache.org> on 2023/02/15 03:04:00 UTC

[GitHub] [shardingsphere] gavenpeng opened a new issue, #24169: Shardingsphere sharding rule use error in two shardingsphere datasource and different sharding rule

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

   ## 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/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   Version:Shardingsphere5.0.0
   Project:ShardingSphere-JDBC
   
   Expected behavior
   we config two shardingsphere datasoure with different sharding rule
   
   Actual behavior
   the one shardingsphere datasource using the another  sharding rule of datasoure while route sql, the business use mybatis plus
   
   
   ### Reason analyze (If you can)
   
   Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   1 business use two datasource:
   
      <bean id="commentDataSource" class="com.ximalaya.social.universal.ArenaDataSourceFactory">
           <constructor-arg value="universal-comment-service:social-universal-comment-db:mysql"/>
       </bean>
   
     this data source sharding rule is follow:
   ```
   rules:
     - !SHARDING
       tables:
         tb_comment:
           actualDataNodes: ds0.tb_comment${0..999}
           tableStrategy:
             standard:
               shardingColumn: id
               shardingAlgorithmName: commentrule
         tb_user_comment:
           actualDataNodes: ds0.tb_user_comment${0..999}
           tableStrategy:
             standard:
               shardingColumn: uid
               shardingAlgorithmName: userCommentrule      
         tb_biz_comment:
           actualDataNodes: ds0.tb_biz_comment${0..999}
           tableStrategy:
             standard:
               shardingColumn: biz_id
   ```
   
       <bean id="likeDataSource" class="com.ximalaya.social.universal.ArenaDataSourceFactory">
           <constructor-arg value="universal-comment-service:social-universal-like-db:mysql"/>
       </bean>
   
   this data source sharding rule is follow:
   ```rules:
     - !SHARDING
       tables:
         tb_like:
           actualDataNodes: ds0.tb_like${0..99}
           tableStrategy:
             standard:
               shardingColumn: biz_id
               shardingAlgorithmName: likerule
       shardingAlgorithms:
         likerule:
           type: HASH_MOD
           props:
             sharding-count: 100
   ```
   
   2 error:
   2023-02-14 23:25:27.536 [ConsumeMessageThread_6] ERROR c.x.a.a.j.s.s.XPaaShardingSpherePreparedStatement - ShardingSphere for source id universal-comment-service:social-universal-like-db:mysql create execution context failed:
   org.apache.shardingsphere.infra.exception.ShardingSphereException: `tb_like` single table does not exist sharding rule [tb_comment,tb_user_comment,tb_biz_comment] .
   	at org.apache.shardingsphere.sharding.route.engine.type.single.SingleTablesRoutingEngine.fillRouteContext(SingleTablesRoutingEngine.java:88)
   	at org.apache.shardingsphere.sharding.route.engine.type.single.SingleTablesRoutingEngine.route(SingleTablesRoutingEngine.java:59)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:61)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:62)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:52)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:54)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:46)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:363)
   	at com.ximalaya.architecture.arena.jdbc.sharding.statement.XPaaShardingSpherePreparedStatement.createExecutionContext(XPaaShardingSpherePreparedStatement.java:41)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:271)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
   	at sun.reflect.GeneratedMethodAccessor164.invoke(Unknown Source)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
   	at com.sun.proxy.$Proxy214.update(Unknown Source)
   	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
   	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
   	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
   	at sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
   	at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)
   	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
   	at com.sun.proxy.$Proxy213.update(Unknown Source)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:181)
   	at sun.reflect.GeneratedMethodAccessor261.invoke(Unknown Source)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
   	at com.sun.proxy.$Proxy185.insert(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
   	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
   	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
   	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
   	at com.sun.proxy.$Proxy189.insert(Unknown Source)
   	at com.ximalaya.social.universal.like.LikeService.hate(LikeService.java:112)
   	at com.ximalaya.social.universal.like.sync.TrackCommentHateCreatedSyncProcessor.handle(TrackCommentHateCreatedSyncProcessor.java:27)
   	at com.ximalaya.social.universal.like.sync.AbstractTrackCommentLikeSyncProcessor.onMessage(AbstractTrackCommentLikeSyncProcessor.java:40)
   	at com.ximalaya.danube.core.consumer.rocket.RocketListener.onMessage(RocketListener.java:15)
   	at com.ximalaya.danube.core.consumer.rocket.RocketMessageListenerContainer$2.consumeMessage(RocketMessageListenerContainer.java:254)
   	at org.apache.rocketmq.client.impl.consumer.ConsumeMessageConcurrentlyService$ConsumeRequest.run(ConsumeMessageConcurrentlyService.java:412)
   	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   	at com.alibaba.ttl.TtlRunnable.run(TtlRunnable.java:59)
   	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)
   
   and the sourceid config is follows:
   ![image](https://user-images.githubusercontent.com/2044082/218916031-cd8485fa-a596-4c6f-8824-0c061808feca.png)
   
   this datasource sharding rule  logic table is 'tb_like ', but shardingsphere using the anthor data source sharding rule
   
   ### 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] gavenpeng commented on issue #24169: Shardingsphere sharding rule use error in two shardingsphere datasource and different sharding rule

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

   i looked the router code,found the routers  of PartialSQLRouteExecutor init maybe exist problem,the code is follow:
   
   ```
   public PartialSQLRouteExecutor(final Collection<ShardingSphereRule> rules, final ConfigurationProperties props) {
           this.props = props;
           routers = OrderedSPIRegistry.getRegisteredServices(rules, SQLRouter.class);
       }
   ```
   the last invoked the follow code:
   
   ```
   public static <K, V extends OrderedSPI<?>> void cacheServices(final Collection<K> types, final Class<V> orderedSPIClass, final Map<K, V> services) {
           CACHED_SERVICES.put(orderedSPIClass, new CachedOrderedServices(types, services));
       }
   ```
   the CACHED_SERVICES is concurrenthashmap,  the **orderedSPIClass** is sqlRouter classes, when exist multi sharding rule, the **CACHED_SERVICES** only cache the one rule, i see 5.20  modidyed the key contain rules


-- 
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] tuichenchuxin commented on issue #24169: Shardingsphere sharding rule use error in two shardingsphere datasource and different sharding rule

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

   > yes,is mistakes some times ,not happend every one
   
   Thank you. But I can't reproduce this error. Can you offer a demo?
   


-- 
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] tuichenchuxin commented on issue #24169: Shardingsphere sharding rule use error in two shardingsphere datasource and different sharding rule

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

   The information is not enough, the multiple logical data sources of ShardingSphere are isolated. Are you saying that you have created two sets of configurations and used the two data sources separately, but there will be mistakes?


-- 
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] gavenpeng commented on issue #24169: Shardingsphere sharding rule use error in two shardingsphere datasource and different sharding rule

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

   we project use shardingsphere config is pulled from paas platform, give me not work if not deploy paas, Can you create a demo by me provider the config? thanks


-- 
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] gavenpeng commented on issue #24169: Shardingsphere sharding rule use error in two shardingsphere datasource and different sharding rule

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

   yes,is mistakes some times ,not happend every one


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