apache / apache/incubator-seata
transaction doesn't rollback
- Dominant language
- Java
- Stars
- 26k
- Forks
- 8.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
- [ ] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate.
### Ⅰ. Issue Description
Service A starts a global transaction to call service B. After service B throws an exception, the transaction is not rolled back, and finally seata submits the transaction.
### Ⅱ. Describe what happened
service B throws an exception seata submits the transaction.
### Ⅲ. Describe what you expected to happen
service A and B rollback
### Ⅳ. How to reproduce it (as minimally and precisely as possible)
` @Override
服务A
@GlobalTransactional
public ResultVo createOrder(Integer id) {
try {
log.info("当前 XID: {}", RootContext.getXID());
ResultVo resultVo = productFeignSerivce.findById(id);
if (!"200".equals(resultVo.getReturnCode())) {
return ResultVo.fail("查询商品信息失败");
}
Product p = resultVo.getData();
log.info("product:{}", p);
Order order = new Order();
order.setName(p.getName());
order.setPrice(p.getPrice());
orderDao.save(order);
ResultVo desResultVo = productFeignSerivce.desProductCount(p);
if (!"200".equals(desResultVo.getReturnCode())) {
throw new RuntimeException("库存修改失败啦,回滚");
}
if (id.equals(1)){
throw new RuntimeException("手动测试回滚");
}
return ResultVo.success(order);
}catch (Exception e){
throw new RuntimeException(e.getMessage());
}
}
服务B
@Override
public int desProductCount(Product product) {
log.info("当前 XID: {}", RootContext.getXID());
if (product == null) {
return 0;
}
// 先执行sql 再异常
int result = productDao.desProductCount(product.getId(), product.getStock() - 1);
// int i = 1 / 0;
return result;
}
`
### Ⅴ. Anything else we need to know?
Service A starts the global transaction to call service B. Service A can roll back normally after throwing an exception.
### Ⅵ. Environment:
- JDK version : jdk1.8
- OS : windows10
- Others: idea
mybaits+seata
com.alibaba.cloud
spring-cloud-starter-alibaba-seata
2.1.1.RELEASE
Contributor guide
Research direction
Start by reproducing the Service A to Service B flow shown in the issue with JDK 8, MyBatis, and the listed Spring Cloud Seata dependency. Trace how Service B's exception is propagated and verify the global transaction outcome; done means both services roll back when Service B fails.
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
- 25/100