apache / apache/incubator-seata-samples
saga 中补偿业务的实现。
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
你好:
我看demo 中saga的例子是扣减库存,大概总结下来是:
transaction 1: set amount = amount+1 where id = 1;
transaction 2: set amount = amount +2 where id = 1;
当transaction 1 发生错误,需要补偿的时候:业务端 写个方法是: set amount = amount-1 where id = 1;
当transaction 2 发生错误,需要补偿的时候:业务端 写个方法是: set amount = amount-2 where id = 1;
这是正确的。
如果换成字符串好像就不对了,例如:
transaction 1: set name = 'n1' where id = 1;
transaction 2: set name = 'n2' where id = 1;
当transaction 1 发生错误,需要补偿的时候:业务端 写个方法是: set name = null where id = 1;
当 transaction 2 补偿的时候 set name = 'n1' where id = 1。最后name 变成了 n1 了。
Contributor guide
Research direction
No file, test, or entry point is named. First locate the Saga sample that demonstrates compensation, then clarify the expected behavior for string updates; done should include an agreed compensation design and a covering sample or test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100