Famezyy opened a new issue, #31715: URL: https://github.com/apache/shardingsphere/issues/31715
I'm using version 5.5.0, but when incorporating seata it is not working as expected. I fist created two services: consumer and provider, and the provider service is been called in consumer service. Then checked the [official documentation](https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/seata/) and disabled the auto data proxy of seata. Also refered to #22356 and #30146 and added the following interceptor in the provider service: ```java @Configuration public class MySeataConfigure implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new ShardingSphereInterceptor()); } static class ShardingSphereInterceptor implements HandlerInterceptor { public boolean preHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler) throws TransactionException { String xid = RootContext.getXID(); if (xid == null) { xid = request.getHeader(RootContext.KEY_XID); } if (!StringUtils.isBlank(xid) && SeataTransactionHolder.get() == null) { RootContext.bind(xid); SeataTransactionHolder.set(GlobalTransactionContext.getCurrentOrCreate()); } return true; } } } ``` but when error occured in consumer service after calling provider service, rollback only happened in consumer service. *consumer log* ```bash 2024-06-16T15:41:02.472+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.c.rpc.netty.TmNettyRemotingClient : register TM success. client version:2.0.0, server version:2.0.0,channel:[id: 0xe2b99d58, L:/127.0.0.1:2059 - R:/127.0.0.1:18091] 2024-06-16T15:41:02.480+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.core.rpc.netty.NettyPoolableFactory : register success, cost 81 ms, version:2.0.0,role:TMROLE,channel:[id: 0xe2b99d58, L:/127.0.0.1:2059 - R:/127.0.0.1:18091] 2024-06-16T15:41:02.498+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] io.seata.rm.datasource.AsyncWorker : Async Commit Buffer Limit: 10000 2024-06-16T15:41:02.499+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.rm.datasource.xa.ResourceManagerXA : ResourceManagerXA init ... 2024-06-16T15:41:02.508+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.core.rpc.netty.NettyClientBootstrap : NettyClientBootstrap has started 2024-06-16T15:41:02.618+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.c.r.netty.NettyClientChannelManager : will connect to 127.0.0.1:18091 2024-06-16T15:41:02.619+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.c.rpc.netty.RmNettyRemotingClient : RM will register :jdbc:mysql://localhost:3306/seata 2024-06-16T15:41:02.619+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.core.rpc.netty.NettyPoolableFactory : NettyPool create channel to transactionRole:RMROLE,address:127.0.0.1:18091,msg:< RegisterRMRequest{resourceIds='jdbc:mysql://localhost:3306/seata', version='2.0.0', applicationId='seata-consumer', transactionServiceGroup='default_tx_group', extraData='null'} > 2024-06-16T15:41:02.627+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.c.rpc.netty.RmNettyRemotingClient : register RM success. client version:2.0.0, server version:2.0.0,channel:[id: 0x2c919b71, L:/127.0.0.1:2060 - R:/127.0.0.1:18091] 2024-06-16T15:41:02.627+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.s.core.rpc.netty.NettyPoolableFactory : register success, cost 5 ms, version:2.0.0,role:RMROLE,channel:[id: 0x2c919b71, L:/127.0.0.1:2060 - R:/127.0.0.1:18091] 2024-06-16T15:41:07.253+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (getNetworkTimeout) 2024-06-16T15:41:07.255+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection@68fbdbee 2024-06-16T15:41:07.256+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2024-06-16T15:41:07.270+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] io.seata.tm.TransactionManagerHolder : TransactionManager Singleton io.seata.tm.DefaultTransactionManager@674367bf 2024-06-16T15:41:07.277+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.seata.tm.api.DefaultGlobalTransaction : Begin new global transaction [192.168.13.1:18091:3477311730122375224] 2024-06-16T15:41:08.348+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] ShardingSphere-SQL : Logic SQL: UPDATE account SET money=money+200 WHERE (id = ?) 2024-06-16T15:41:08.348+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] ShardingSphere-SQL : Actual SQL: db ::: UPDATE account SET money=money+200 WHERE (id = ?) ::: [1] 2024-06-16T15:41:08.813+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] io.seata.rm.AbstractResourceManager : branch register success, xid:192.168.13.1:18091:3477311730122375224, branchId:3477311730122375225, lockKeys:account:1 2024-06-16T15:41:08.833+09:00 WARN 20652 --- [seata-consumer] [nio-8080-exec-1] ServiceLoader$InnerEnhancedServiceLoader : Load [io.seata.rm.datasource.undo.parser.ProtostuffUndoLogParser] class fail: io/protostuff/runtime/IdStrategy 2024-06-16T15:41:18.951+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.seata.tm.api.DefaultGlobalTransaction : transaction 192.168.13.1:18091:3477311730122375224 will be rollback 2024-06-16T15:41:18.957+09:00 INFO 20652 --- [seata-consumer] [h_RMROLE_1_1_24] i.s.c.r.p.c.RmBranchRollbackProcessor : rm handle branch rollback process:BranchRollbackRequest{xid='192.168.13.1:18091:3477311730122375224', branchId=3477311730122375225, branchType=AT, resourceId='jdbc:mysql://localhost:3306/seata', applicationData='null'} 2024-06-16T15:41:18.959+09:00 INFO 20652 --- [seata-consumer] [h_RMROLE_1_1_24] io.seata.rm.AbstractRMHandler : Branch Rollbacking: 192.168.13.1:18091:3477311730122375224 3477311730122375225 jdbc:mysql://localhost:3306/seata 2024-06-16T15:41:19.061+09:00 INFO 20652 --- [seata-consumer] [h_RMROLE_1_1_24] i.s.r.d.undo.AbstractUndoLogManager : xid 192.168.13.1:18091:3477311730122375224 branch 3477311730122375225, undo_log deleted with GlobalFinished 2024-06-16T15:41:19.063+09:00 INFO 20652 --- [seata-consumer] [h_RMROLE_1_1_24] i.seata.rm.datasource.DataSourceManager : branch rollback success, xid:192.168.13.1:18091:3477311730122375224, branchId:3477311730122375225 2024-06-16T15:41:19.064+09:00 INFO 20652 --- [seata-consumer] [h_RMROLE_1_1_24] io.seata.rm.AbstractRMHandler : Branch Rollbacked result: PhaseTwo_Rollbacked 2024-06-16T15:41:19.069+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.seata.tm.api.DefaultGlobalTransaction : transaction end, xid = 192.168.13.1:18091:3477311730122375224 2024-06-16T15:41:19.069+09:00 INFO 20652 --- [seata-consumer] [nio-8080-exec-1] i.seata.tm.api.DefaultGlobalTransaction : [192.168.13.1:18091:3477311730122375224] rollback status: Rollbacked 2024-06-16T15:41:19.075+09:00 ERROR 20652 --- [seata-consumer] [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.ArithmeticException: / by zero] with root cause ``` *provider service* ```bash 2024-06-16T15:26:08.571+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.c.rpc.netty.TmNettyRemotingClient : register TM success. client version:2.0.0, server version:2.0.0,channel:[id: 0xdc135f0a, L:/127.0.0.1:13771 - R:/127.0.0.1:18091] 2024-06-16T15:26:08.578+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.core.rpc.netty.NettyPoolableFactory : register success, cost 74 ms, version:2.0.0,role:TMROLE,channel:[id: 0xdc135f0a, L:/127.0.0.1:13771 - R:/127.0.0.1:18091] 2024-06-16T15:26:08.596+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] io.seata.rm.datasource.AsyncWorker : Async Commit Buffer Limit: 10000 2024-06-16T15:26:08.597+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.rm.datasource.xa.ResourceManagerXA : ResourceManagerXA init ... 2024-06-16T15:26:08.605+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.core.rpc.netty.NettyClientBootstrap : NettyClientBootstrap has started 2024-06-16T15:26:08.705+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.c.r.netty.NettyClientChannelManager : will connect to 127.0.0.1:18091 2024-06-16T15:26:08.706+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.c.rpc.netty.RmNettyRemotingClient : RM will register :jdbc:mysql://localhost:3307/seata 2024-06-16T15:26:08.706+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.core.rpc.netty.NettyPoolableFactory : NettyPool create channel to transactionRole:RMROLE,address:127.0.0.1:18091,msg:< RegisterRMRequest{resourceIds='jdbc:mysql://localhost:3307/seata', version='2.0.0', applicationId='seata-provider', transactionServiceGroup='default_tx_group', extraData='null'} > 2024-06-16T15:26:08.713+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.c.rpc.netty.RmNettyRemotingClient : register RM success. client version:2.0.0, server version:2.0.0,channel:[id: 0xb9c2ceb6, L:/127.0.0.1:13772 - R:/127.0.0.1:18091] 2024-06-16T15:26:08.713+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] i.s.core.rpc.netty.NettyPoolableFactory : register success, cost 5 ms, version:2.0.0,role:RMROLE,channel:[id: 0xb9c2ceb6, L:/127.0.0.1:13772 - R:/127.0.0.1:18091] 2024-06-16T15:26:13.232+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (getNetworkTimeout) 2024-06-16T15:26:13.234+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection@3656315 2024-06-16T15:26:13.235+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2024-06-16T15:26:14.296+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] ShardingSphere-SQL : Logic SQL: UPDATE account SET money=money+200 WHERE (id = ?) 2024-06-16T15:26:14.296+09:00 INFO 10320 --- [seata-provider] [nio-8081-exec-1] ShardingSphere-SQL : Actual SQL: db ::: UPDATE account SET money=money+200 WHERE (id = ?) ::: [2] ``` Not sure if it is correct but in provider service it was also registering TM and RM, and **there was no any branch transaction been registered**. When debugging it, I found that in provider service, it is entering the `commit()` method of `DefaultGlobalTransaction` from `SeataATShardingSphereTransactionManager` as the `transaction role` is `Participant`, and it is doing nothing:  but I'm expecting it can register a branch transaction but not to commit the global transaction directly. you can find the example code in the below repo. https://github.com/Famezyy/code-repo/tree/master could you please tell me how to fix it? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
