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

AT模式事物隔离问题 #48

Closed
pwjbj opened this issue May 27, 2021 · 3 comments
Closed

AT模式事物隔离问题 #48

pwjbj opened this issue May 27, 2021 · 3 comments

Comments

@pwjbj
Copy link

pwjbj commented May 27, 2021

分布式事物由两个事物组成
1负责创建订单时扣减库存
2负责创建订单时写入订单主表和订单明细表

当1事物 commit 之后(库存减少了) , 2事物出错了需要回滚 , 全局回滚完成 之前, 这时读取的库存数是1事物commit之后的, 这种问题要怎么处理?

@dk-lockdown
Copy link

分布式事物由两个事物组成
1负责创建订单时扣减库存
2负责创建订单时写入订单主表和订单明细表

当1事物 commit 之后(库存减少了) , 2事物出错了需要回滚 , 全局回滚完成 之前, 这时读取的库存数是1事物commit之后的, 这种问题要怎么处理?

使用 select for update 查询库存,查询时,集成 seata 的 driver 会重试去 tc 上询问对应的数据是否被锁住,tc 释放了锁,select for update 从数据库获取到当前的库存数据。

@pwjbj
Copy link
Author

pwjbj commented May 28, 2021

本地锁和全局锁是如何申请和释放的

@dk-lockdown
Copy link

本地锁和全局锁是如何申请和释放的

本地锁本地提交时释放,全局锁,全局提交、回滚成功后释放

luky116 pushed a commit that referenced this issue Jul 12, 2022
feature append action context for tcc
wang1309 pushed a commit to wang1309/seata-go that referenced this issue Jan 7, 2023
feature append action context for tcc
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