New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dubbo事务补偿问题 #223
Comments
请问C事务中断是抛异常吗?因为你使用了@transactional, 如果服务抛异常, 对应的数据库提交动作就不会执行。 不调用C的补偿方法是正确的。 但是B的补偿方法是需要调用的, 这个在Dubbo示例的代码里面是能够正常执行的。 https://github.com/apache/incubator-servicecomb-saga/blob/master/acceptance-tests/acceptance-pack-dubbo-demo/src/test/resources/CExceptionWhenAbAc_scenario.feature |
是的,C事务抛出中断异常,不补偿是正常的; 但是B事务执行成功了,但是没有调用补偿(cancel方法); 运行了dubbo demo方法,也并没有执行补偿,test-b表状态是run没有恢复为init;
执行地址格式: serviceInvoke/CExceptionWhenAbAc
你好,我使用的dubbo版本是2.5.3;是不是dubbo版本或者部署alpha-server部署有问题;
在2018年7月17日 14:49,Willem Jiang<notifications@github.com> 写道:
请问C事务中断是抛异常吗?因为你使用了@transactional, 如果服务抛异常, 对应的数据库提交动作就不会执行。 不调用C的补偿方法是正确的。 但是B的补偿方法是需要调用的, 这个在Dubbo示例的代码里面是能够正常执行的。 https://github.com/apache/incubator-servicecomb-saga/blob/master/acceptance-tests/acceptance-pack-dubbo-demo/src/test/resources/CExceptionWhenAbAc_scenario.feature
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
我们的验收测试用的是dubbo 2.6.1, 你看看能不升级一下。 如果B能回滚,就需要确保调C出错的时候,异常能够在A方法中抛出。 |
您好,已经调整到dubbo2.6.1版本,按照提供的dubbo-demo内所有jar包版本保持不变。应该与dubbo版本无关,仍然存在如下问题:
1、 alpha-server-0.2.0-exec.jar 采用MySQL,会报一个错误;
如图3所示;
![1](https://user-images.githubusercontent.com/17855411/42814197-0b10404e-89f6-11e8-8bca-0884ebac7ee8.png)
![2](https://user-images.githubusercontent.com/17855411/42814210-176ad430-89f6-11e8-8752-5dfb2de5c006.png)
![3](https://user-images.githubusercontent.com/17855411/42814211-188d43a2-89f6-11e8-8085-00355a475b34.png)
![4](https://user-images.githubusercontent.com/17855411/42814215-18e70e78-89f6-11e8-8e01-d35a06f999ec.png)
2、CExceptionWhenAbAc
如图1和图2所示,b没有触发调用补偿方法(cancelRun)进行补偿;
public void cancelRun(InvokeContext invokeContext) {
LOG.info("B.cancel called");
doCancelBusi();
}
3、AExceptionWhenAb
如图4所示,b没有触发调用补偿方法(cancelRun);
4、其他Ab, AbBc,BExceptionWhenAb, BExceptionWhenAb, CExceptionWhenAbBc,因为有@transactional所以会回滚正常;
问题:补偿方法未被触发?
|
感觉你是用了MySQL的主从复制功能,这种情况下JPA创建临时表不能同步复制。 |
@airbaby Is there any update of this issue? |
你好,出现此问题由于创建虚表导致,目前已解决这个问题,在20个应用微服务集群中压力测试稳定,后续有幸在实际应用中参与进来。
Thank you very much!
在2018年8月8日 16:12,Willem Jiang<notifications@github.com> 写道:
@airbaby Is there any update of this issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
这的确是个好消息, 现在系统已经投入生产了吗? |
Just close the issue as it is resolved. |
A系统调用B系统服务,A系统调用C系统服务, Saga-0.2.0版本;
1、A-B调用返回成功;
2、A-C调用返回失败;
出现问题:
B执行完后,C事务中断,C并“没有”调用自身补偿方法进行补偿,A也没有调用方法进行补偿?使用提供的Dubbo示例加入如下代码,也是同样的结果;
@SagaStart
@Compensable(compensationMethod="cancel")
@transactional(rollbackFor = Exception.class)
public void transfer(String from, String to, BigDecimal amount){
//B服务Dubbo调用
transBDubboService.transferBIn(to, 50);
//C服务Dubbo调用
transCDubboService.transferCIn(to, 50);
}
//B服务Dubbo接口方法
@Compensable(compensationMethod="cancel")
@transactional(rollbackFor = Exception.class)
@OverRide
public void transferBIn(String to, int amount) {
LOG.info("C.Called,开始转入资金:"+amount);
AccountPo accountPo= accountPoDao.queryByUserName(to);
LOG.info("C.Called,开始转入资金:"+amount);
//转入资金操作
accountPo.setBalance(accountPo.getBalance().add(BigDecimal.valueOf(amount)));
accountPoDao.updateByCond(accountPo);
}
//C服务Dubbo接口方法
@Compensable(compensationMethod="cancel")
@transactional(rollbackFor = Exception.class)
@OverRide
public void transferCIn(String to, int amount) {
LOG.info("C.Called,开始转入资金:"+amount);
AccountPo accountPo= accountPoDao.queryByUserName(to);
//转入资金操作
accountPo.setBalance(accountPo.getBalance().add(BigDecimal.valueOf(amount)));
accountPoDao.updateByCond(accountPo);
}
The text was updated successfully, but these errors were encountered: