apache / apache/incubator-seata-samples

springcloud-eureka-feign-mybatis-seata demo中添加(ControllerAdvice)全局异常处理器后,数据不回滚

Open
#315 10 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
2.4k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

先按照springcloud-eureka-feign-mybatis-seata demo将工程运行起来。
在account服务中模拟抛出超时异常或者除0异常
order,account,storage中的数据都会回滚。

但是在account服务中添加如下代码
`@ControllerAdvice
public class BaseExceptionHandler {

@ExceptionHandler(value = Exception.class)
@ResponseBody
public Result error(Exception e) {
e.printStackTrace();
return new Result(20001, e.getMessage());
}
}
`
在account抛出除0异常后,
order,storage中的数据不会回滚,order,storage均提示
`Branch commit result: PhaseTwo_Committed`
account 在抛出java.lang.ArithmeticException: / by zero异常后
重新连接TM
NettyPool create channel to transactionRole:TMROLE,address:192.168.200.10:8091,

Contributor guide

Open the contributing guide

Research direction

Run the springcloud-eureka-feign-mybatis-seata demo, first reproducing the rollback with the account service's timeout or division-by-zero exception. Then compare the transaction logs and outcomes after adding the shown ControllerAdvice handler in account, especially the PhaseTwo_Committed messages from order and storage. Done means the exception is handled while account, order, and storage all roll back consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.