Skip to content
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

强制退出或宕机数据不能回滚? #15

Open
YANGJINJUE opened this issue May 8, 2020 · 3 comments
Open

强制退出或宕机数据不能回滚? #15

YANGJINJUE opened this issue May 8, 2020 · 3 comments

Comments

@YANGJINJUE
Copy link

@Transactional(rollbackFor = ServiceException.class) public void transfer(String sourceAcctId, String targetAcctId, double amount) throws ServiceException { this.remoteAccountService.decreaseAmount(sourceAcctId, amount); System.exit(-1); this.increaseAmount(targetAcctId, amount); }
跑的测试GenericConsumerMain,我在上述加入代码System.exit(-1)模拟宕机的场景,就是远程调用成功,账户1资金扣钱并冻结成功,当本地对账户2加钱前宕机了,那么后续我又启动恢复RecoverConsumerMain,账号1的钱还是有冻结金额?请问你们有碰到吗?还是说我测试问题?

@liuyangming
Copy link
Owner

宕机或强制退出,这是byteTCC支持的故障恢复场景,发布版本也有相应的自动测试集验证。ByteTCC-sample提供的代码,我刚又验证了一把,修改GenericTransferServiceImpl.transfer(...)方法如下:

this.remoteAccountService.decreaseAmount(sourceAcctId, amount);
System.exit(-1);
this.increaseAmount(targetAcctId, amount);

在RecoverConsumerMain执行后是可以将已执行的记录回撤的。如果你测试有问题,烦请提供详细的修改及操作说明。

@YANGJINJUE
Copy link
Author

使用idea开发调试
1,修改GenericTransferServiceImpl中方法transfer加入System.exit(-1),如上所示
2,启动提供者ProviderMain
3,运行GenericConsumerMain,之后inst01的tb_account_one数据变成-》
image,然后该进程就自动退出了
4,然后启动RecoverConsumerMain,然后inst01的tb_account_one数据还是-》
image

@YANGJINJUE
Copy link
Author

问题已经找到了,由于是在idea环境下调试的,导致生产者和消费者共同使用同一个本地事务日志bytetcc文件夹下的,后来将程序打包分开在不同文件夹下运行测试通过,宕机后启动恢复数据会回滚。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants