← 返回刚才阅读的位置

知识卡片

支付系统案例卡 · 2851.t.1

共享锁协调不能忽略持锁故障

理解等级:高级

针对[[并发存款可能覆盖余额]],共同锁使一个实例完成余额更新并释放后,另一个才能进入临界区。跨节点还会丢消息,持锁者也可能崩溃,不能照搬单机内存锁。应使用成熟协调服务并按其一致性与故障语义集成;协调服务本身不自动把银行数据库更新、锁失效与业务副作用组成一个无条件安全事务。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 云与分布式计算 · 查看原书依据

      The standard solution in this situation is to lock the data item, so that a service cannot access your account balance until it gets the lock. We avoid a race condition because service instance 1 is granted a lock on your bank account and can work in isolation to make its deposit until it yields the lock. Then service instance 2, which has been waiting for the lock to become available, can lock the bank account and make the second deposit.

    参考来源

    - 位置:《Software Architecture in Practice, 4th Edition》第17章《云与分布式计算》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch17.html) - 结论依据:所引连续原文给出本卡机制或取舍;条件与示例结合本节已读上下文解释。 - 原始内容:The standard solution in this situation is to lock the data item, so that a service cannot access your account balance until it gets the lock. We avoid a race condition because service instance 1 is granted a lock on your bank account and can work in isolation to make its deposit until it yields the lock. Then service instance 2, which has been waiting for the lock to become available, can lock the bank account and make the second deposit.