知识卡片
并发存款可能覆盖余额
两个服务实例独立读相同余额,各自加上存款再写回,后写者可能覆盖先写者,导致一笔存款效果丢失。根因是跨节点的读改写未被共同串行化,不是计算加法错误。对应协调及故障边界见[[共享锁协调不能忽略持锁故障]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 云与分布式计算 · 查看原书依据
Changing the account balance requires reading the current balance, adding or subtracting the transaction amount, and then writing back the new balance. If we allow both service instances to operate independently on this data item, there is the possibility of a race condition, such as two simultaneous deposits overwriting each other.
参考来源
- 位置:《Software Architecture in Practice, 4th Edition》第17章《云与分布式计算》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch17.html)
- 结论依据:所引连续原文给出本卡机制或取舍;条件与示例结合本节已读上下文解释。
- 原始内容:Changing the account balance requires reading the current balance, adding or subtracting the transaction amount, and then writing back the new balance. If we allow both service instances to operate independently on this data item, there is the possibility of a race condition, such as two simultaneous deposits overwriting each other.