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:44:01 UTC

[GitHub] [shardingsphere] NOLouser opened a new issue, #10283: In one transaction, two same logic sqls do not work correctly by using hint strategy

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

   ## 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!
   
   ### Which version of ShardingSphere did you use?
   build.gradle:
   `compile group: 'org.apache.shardingsphere', name: 'shardingsphere-jdbc-core-spring-boot-starter', version: "5.0.0-alpha"`
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   In one transaction, I'm trying to execute two same logic sqls with different hint. I think that it will execute two actual sql in different sharding table .
   ```
   @Transactional
   public Object hello(){
       try (HintManager hintManager=HintManager.getInstance();){
           // 指定查询的分表
           hintManager.addTableShardingValue("t_order_hint","40");
           TOrderExtend tOrder=tOrderExtendMapper.selectOne(Wrappers.<TOrderExtend>lambdaQuery().eq(TOrderExtend::getUserId,9));
           LOGGER.info(tOrder.toString());
       }
   
       try (HintManager hintManager=HintManager.getInstance();){
           // 指定查询的分表
           hintManager.addTableShardingValue("t_order_hint","39");
           TOrderExtend tOrder=tOrderExtendMapper.selectOne(Wrappers.<TOrderExtend>lambdaQuery().eq(TOrderExtend::getUserId,9));
           LOGGER.info(tOrder.toString());
       }
   
       Map<String,String> result=new HashMap<>();
       result.put("word","hello, world!");
   
       return result;
   }
   ```
   
   ### Actual behavior
   ```
   [INFO] 2021-05-08 15:59:26.977 http-nio-9014-exec-2 org.apache.shardingsphere.infra.executor.sql.log.SQLLogger:74 - Logic SQL: SELECT  order_id,user_id,address_id,status,datetime  FROM t_order_hint 
    
    WHERE (user_id = ?)
   [INFO] 2021-05-08 15:59:26.978 http-nio-9014-exec-2 org.apache.shardingsphere.infra.executor.sql.log.SQLLogger:74 - SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty)
   [INFO] 2021-05-08 15:59:26.978 http-nio-9014-exec-2 org.apache.shardingsphere.infra.executor.sql.log.SQLLogger:74 - Actual SQL: ds ::: SELECT  order_id,user_id,address_id,status,datetime  FROM t_order_40 
    
    WHERE (user_id = ?) ::: [9]
   [INFO] 2021-05-08 15:59:27.010 http-nio-9014-exec-2 com.nolouser.demo.service.impl.TOrderServiceImpl:42 - TOrder{orderId=548438947156963329, userId=9, addressId=9, status=INSERT_TEST, datetime=2020-12-23 09:40:34}
   [INFO] 2021-05-08 15:59:27.011 http-nio-9014-exec-2 com.nolouser.demo.service.impl.TOrderServiceImpl:49 - TOrder{orderId=548438947156963329, userId=9, addressId=9, status=INSERT_TEST, datetime=2020-12-23 09:40:34}
   ```
   From log, we could see that it only executed the first logic sql.
   
   ### Reason analyze (If you can)
   In the way of executing two same sqls in one transaction, mybatis-plus  will actually execute the first one, and gets result of the second one from  cache, so ShardingSphere will not work for the second logic sql.
   ![the first logic sql](https://user-images.githubusercontent.com/40658641/117532036-169ca380-b018-11eb-96de-48eae5825b4d.png)
   ![the second logic sql](https://user-images.githubusercontent.com/40658641/117532124-86129300-b018-11eb-9e89-aa05d3e401f7.png)
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   
   ### Example codes for reproduce this issue (such as a github link).
   [example codes](https://github.com/NOLouser/shardingsphere-demo)
   com.nolouser.demo.service.impl.TOrderServiceImpl#hello
   org.apache.ibatis.executor.BaseExecutor#query(org.apache.ibatis.mapping.MappedStatement, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.session.ResultHandler, org.apache.ibatis.cache.CacheKey, org.apache.ibatis.mapping.BoundSql)


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


Re: [I] In one transaction, two same logic sqls do not work correctly by using hint strategy [shardingsphere]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #10283:
URL: https://github.com/apache/shardingsphere/issues/10283#issuecomment-2026023136

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
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 #10283: In one transaction, two same logic sqls do not work correctly by using hint strategy

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

   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


[GitHub] [shardingsphere] github-actions[bot] closed issue #10283: In one transaction, two same logic sqls do not work correctly by using hint strategy

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #10283: In one transaction, two same logic sqls do not work correctly by using hint strategy
URL: https://github.com/apache/shardingsphere/issues/10283


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