incubator-seata
incubator-seata copied to clipboard
redis updateGlobalTransactionDO unwatch need to be optimized
Why you need it?
Is your feature request related to a problem? Please describe in details redis模式里的updateGlobalTransactionDO在处理redis事务时使用了watch,但是使用unwatch的写法不统一,有些在抛出异常或者return之前执行了unwatch,有些则没有。需要搞清楚unwatch是不是必须的,然后保持写法一致
How it could be?
A clear and concise description of what you want to happen. You can explain more about input of the feature, and output of it. 考虑到这个以下2件事
- watch+multi在redis服务端的原理是:watch命令对某个client操作的key打标记,在进行multi.exec命令时会检查同一client同一key是否有标记,有则拒绝整个exec
- jedis client目前的获取写法是twr写法,在抛出异常或者return时会被close掉,他的close实际上是returnResource给pool ,看源码可以看到里面会重置状态,发送unwatch命令
建议把返回之前的unwatch都去掉,不用引起误解。 如果我们觉得这样改动有风险,也可以统一把unwatch放在finally里面实现,因为update核心逻辑比较复杂,夹杂这个很难维护而且容易遗漏
Other related information
Add any other context or screenshots about the feature request here.