apache / apache/incubator-seata

多线程并发使用seata的问题

Open
#6,311 60 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Java
Stars
26k
Forks
8.8k
Avg merge
1d 8h
Merged PRs (30d)
4

Description

子线程使用RootContext.bind(xid);绑定了主线程的xid,能让报错时整体回滚。但碰到一个问题:

第一个线程修改一个字段,将数据从A改到B,第二个线程修改相同字段(因为是相同xid,可以获取到全局锁),将数据从B改到C,业务异常回滚,那么第一个线程会回滚失败,因为发现脏数据,此时全局锁就一直不会被释放,数据一直被锁住,业务无法继续下去。

请问下官方大佬,这种场景,除了在业务上避免并发修改相同数据外,还有什么好的解决方案呢?seata有机制可以避免吗?或者是我们用seata的方式不对?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the multithreaded scenario described with RootContext.bind(xid), where two threads update the same field and the transaction rolls back. Investigate Seata's global-lock handling and dirty-data rollback behavior, then determine whether this usage is supported and what mechanism, if any, releases the lock after rollback failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.