feign远程调用,事务回滚不生效
1. Bug Description
a服务调用b服务,b服务的事务抛异常,a服务的事务不会回滚
2. Environment:
- JDK version: 1.8
- OS: win7
- TX-LCN version: 5.0.2
- Others:
springboot:2.0.4.RELEASE springcloud: Finchley.SR1 注册中心:eureka
3. Exception Stacktrace
a服务调用b服务的方式是feign,b服务的日志输出如下:
2019-04-08 16:27:41.922 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tracing.Tracings [51] -| tracing apply group:154e4aad55f537, app map:e30=
2019-04-08 16:27:41.923 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.aspect.weave.DTXLogicWeaver [60] -| <---- TxLcn start ---->
2019-04-08 16:27:41.924 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.context.DefaultGlobalContext [150] -| Start TxContext[154e4aad55f537]
2019-04-08 16:27:41.924 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.DTXServiceExecutor [59] -| pre business code, unit type: lcn @group(154e4aad55f537)
2019-04-08 16:27:41.926 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.aspect.weave.DTXResourceWeaver [50] -| proxy a sql connection: com.codingapi.txlcn.tc.core.transaction.lcn.resource.LcnConnectionProxy@79cdd3f5.
2019-04-08 16:27:41.928 |-DEBUG [http-nio-9002-exec-3] com.test.service.e.mapper.ExUserMapper.addUserByXml [159] -| ==> Preparing: insert into user(name,age,score) values(?,?,?)
2019-04-08 16:27:41.929 |-DEBUG [http-nio-9002-exec-3] com.test.service.e.mapper.ExUserMapper.addUserByXml [159] -| ==> Parameters: 10(String), 10(Integer), null
2019-04-08 16:27:41.932 |-DEBUG [http-nio-9002-exec-3] com.test.service.e.mapper.ExUserMapper.addUserByXml [159] -| <== Updates: 1
2019-04-08 16:27:41.936 |-ERROR [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.DTXServiceExecutor [70] -| business code error @group(154e4aad55f537)
2019-04-08 16:27:41.944 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.template.TransactionCleanTemplate [59] -| clean transaction @group(154e4aad55f537)
2019-04-08 16:27:41.944 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.transaction.lcn.resource.LcnConnectionProxy [50] -| rollback transaction type[lcn] proxy connection:com.codingapi.txlcn.tc.core.transaction.lcn.resource.LcnConnectionProxy@79cdd3f5.
2019-04-08 16:27:41.949 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.transaction.lcn.resource.LcnConnectionProxy [54] -| transaction type[lcn] proxy connection:com.codingapi.txlcn.tc.core.transaction.lcn.resource.LcnConnectionProxy@79cdd3f5 closed.
2019-04-08 16:27:41.950 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.template.TransactionCleanTemplate [59] -| clean transaction over @group(154e4aad55f537)
2019-04-08 16:27:41.950 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.context.DefaultGlobalContext [162] -| Destroy TxContext[154e4aad55f537]
2019-04-08 16:27:41.951 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.core.DTXLocalContext [170] -| clean thread local[DTXLocalContext]: DTXLocalContext(transactionType=lcn, groupId=154e4aad55f537, unitId=63104376c261440a03d3308f64fa602f, resource=null, destroy=true, inGroup=false, attachment=null, sysTransactionState=1, userTransactionState=-1, proxy=true, justNow=false, proxyTmp=false)
2019-04-08 16:27:41.951 |-DEBUG [http-nio-9002-exec-3] com.codingapi.txlcn.tc.aspect.weave.DTXLogicWeaver [113] -| <---- TxLcn end ---->
2019-04-08 16:27:41.959 |-ERROR [http-nio-9002-exec-3] com.test.cloud.common.exception.GlobalExceptionHandler [33] -| / by zero
java.lang.ArithmeticException: / by zero
4. Tour Idea
我也遇到这个情况了 请问解决了吗
我是参与方报异常,调用方不回滚
我也有这个问题,参与方报错,调用方不回滚
参与方报错,调用方也要显示异常才会回滚.不然调用方不知道参与方异常了. 我是在调用方接收到参与方返回值后做判断.不符合预期就抛出异常.
参与方报错,调用方也要显示异常才会回滚.不然调用方不知道参与方异常了. 我是在调用方接收到参与方返回值后做判断.不符合预期就抛出异常.
这样就不需要分布式事务了
是的。现在我也是这样做的 监控异常就行
发自我的 iPhone
在 2019年7月11日,20:30,zhuangsheng [email protected] 写道:
参与方报错,调用方也要显示异常才会回滚.不然调用方不知道参与方异常了. 我是在调用方接收到参与方返回值后做判断.不符合预期就抛出异常.
这样就不需要分布式事务了
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
我也有这个问题,服务 a 调用服务 b,b 里出错,a 里不回滚。有人知道怎么解决吗
可以不用啊 使用feign的时候可以捕获到另一个服务的异常 两边同时回滚
| | 吴宇 | | 邮箱:[email protected] |
签名由 网易邮箱大师 定制
在2019年07月15日 17:43,hiyzx 写道:
参与方报错,调用方也要显示异常才会回滚.不然调用方不知道参与方异常了. 我是在调用方接收到参与方返回值后做判断.不符合预期就抛出异常.
这样就不需要分布式事务了
还是需要吧, 跨服务了啊
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
我也是这样问题,后来把服务的全局异常捕捉给去掉了就可以了