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

[GitHub] [shardingsphere] wangjiandahai opened a new issue, #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)

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

   ## Bug Report
   ### Actual behavior
   When use seata-at as base tansaction type .
   transaction config:
   ```yaml
     - !TRANSACTION
       defaultType: LOCAL
   ```
   
   spring boot datasource config:
   ```yaml
   spring:
     datasource:
       driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
       url: jdbc:shardingsphere:classpath:sharding.yaml
   ```
   use HikariDataSource。
   
   one businesss code use LOCAL, another businesss code use BASE like:
   ```java
       @PostMapping(value = "addLocal")
       public Result add(@RequestBody OrderAddReq req) {
           return ResultTools.ofSuccess(orderService.add(req));
       }
       @PostMapping(value = "addBase")
       public Result add(@RequestBody OrderAddReq req) {
           TransactionTypeHolder.set(TransactionType.BASE);
           return ResultTools.ofSuccess(orderService.add(req));
       }
   ```
   ```java
      @Transactional(rollbackFor = Exception.class)
       public boolean add(OrderAddReq req) {
           log.info("Seata全局事务id=================>{}", RootContext.getXID());
           OrderEntity order = new OrderEntity();
           order.setProductId(req.getProductId());
           order.setMoney(req.getMoney());
           order.setUserId(req.getUserId());
           order.setCount(req.getCount());
           order.setStatus(0);
           this.baseOrderService.save(order);
   
           AccountOpReq accountOpReq = new AccountOpReq();
           accountOpReq.setUserId(req.getUserId());
           accountOpReq.setMoney(req.getMoney());
           Result<?> result = accountApi.accountOp(accountOpReq);
           if(!result.success()){
               throw new BaseFlowException(result.getMsg());
           }
   
           if(req.getCount() == 10000){
               int i = 1/0;
           }
           return true;
       }
   ```
   
   When call local mode api first,use Local mode ,then call base mode api,it will use Local mode。
   
   ### Reason analyze (If you can)
   **5.3 use jdbc driver mode,HikariDataSource will pool ShardingSphereConnections. but Connection's Transaction manager is setted when Connection create,will not change。**


-- 
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] wangjiandahai closed issue #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)

Posted by "wangjiandahai (via GitHub)" <gi...@apache.org>.
wangjiandahai closed issue #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE) 
URL: https://github.com/apache/shardingsphere/issues/24898


-- 
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] wangjiandahai commented on issue #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)

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

   因为官方最新的文档中还提供了用TransactionTypeHolder指定的示例。也即意味着还支持混用。但实际到5.3不支持了。应该明确一下。-------- 原始邮件 --------发件人: Zheng Feng ***@***.***>日期: 2023年3月30日周四 中午11:52收件人: apache/shardingsphere ***@***.***>抄送: wangjiandahai ***@***.***>, Author ***@***.***>主    题: Re: [apache/shardingsphere] 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)  (Issue #24898)
   I think it is Transaction Design in shardingsphere. Why do you need the mixed transaction mode? Maybe you can try to use the different yaml config file.
   
   —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>


-- 
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] wangjiandahai commented on issue #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)

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

   文档链接https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/java-api/5.3 ***@***.***,仍保留了TransactionTypeHolder。5.3 sharding-jdbc变为驱动方式,当如下这样使用时:spring boot datasource config:spring:  datasource:    driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver    url: jdbc:shardingsphere:classpath:sharding.yamluse HikariDataSource。此时我们的业务代码中使用的是 HikariDataSource   而不是直接使用ShardingSphereDataSource。就不能混用事务管理模式了。HikariDataSource pool 会缓存 shardingSphereConnection,重复使用。连接的事务管理器在创建连接时根据当时情况已定了。


-- 
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] zhfeng commented on issue #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)

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

   Can you share the link about the example of `@TransactionTypeHolde` in documentation?


-- 
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] zhfeng commented on issue #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)

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

   Hmm, can you try to use 
   ```yaml
   - !TRANSACTION
       defaultType: BASE
   ```
   in the yaml config but `TransactionTypeHolder.set(TransactionType.LOCAL);` when you need local mode.


-- 
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] zhfeng commented on issue #24898: 5.3.1 Applications can only use one transaction management mode, and different businesses cannot use different methods (such as LOCAL and BASE)

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

   I think it is `Transaction Design` in shardingsphere. Why do you need the mixed transaction mode? Maybe you can try to use the different yaml config file.


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