liuyangming / ByteTCC-sample

GNU Lesser General Public License v3.0
133 stars 144 forks source link

其中一个服务在confirm后抛出异常的问题 #37

Open 172167396 opened 2 years ago

172167396 commented 2 years ago

请问当其中一个服务在confirm时抛出runtimeException之后,该服务执行了cancel,但是其他几个服务全都confirm了,这种情况怎么处理 报错打印为 2022-01-17 16:33:49,137 ERROR [pool-1-thread-1] o.b.b.s.s.XAResourceDeserializerImpl - can not find a matching xa-resource(beanId= xxx.xx.x.xxx:springboot-order-service:6001)! 2022-01-17 16:33:49,145 INFO [pool-1-thread-1] o.b.b.CompensableTransactionImpl - 018c200e5a84a93eabc889011bfb5f06| compensable transaction rolled back! 2022-01-17 16:34:49,249 INFO [pool-1-thread-1] o.b.b.CompensableTransactionImpl - 018c200e5a84a93eabc889011bfb5f06| forget transaction. 2022-01-17 16:34:50,410 ERROR [http-nio-6003-exec-6] o.b.b.CompensableCoordinator - Error occurred while committing transaction: 018c200e5a84a93eabc889011bfb5f06. javax.transaction.xa.XAException: null at org.bytesoft.bytetcc.CompensableCoordinator.invokeCommit(CompensableCoordinator.java:223)

liuyangming commented 2 years ago

从你提供的日志,看不出问题所在。你先确认一下,该事务对应的数据是否出现不一致了?如果的确出现了不一致,那么可能是一个缺陷导致,需要麻烦你提供一下能重现该问题的详细步骤。谢谢!

172167396 commented 2 years ago

感谢大佬百忙之中回复,今天又测试了下,有四个服务,order,providerA,providerB,bonus。入口是order服务,然后在providerB的confirm里抛出异常,大概过了几秒之后providerB执行了cancel,但是其他几个服务仍是confirm状态,不知道是不是我写的有问题,代码我压缩了一下传服务器了,能不能麻烦大佬指点下迷津,非常感谢!http://81.70.169.208/common/springboot-tcc-demo.zip

lijiawei199 commented 2 years ago

https://github.com/liuyangming/ByteTCC-sample/issues/37#issuecomment-1014594800 我理解的providerB try成功 confirm失败之后应该是继续重试confirm吧? 只有try失败的时候才会cancel