← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 2313.e.5.f.10.a.4.a.1.a.2

乐观锁原子校验版本

理解等级:中级

乐观锁先读数据与版本,在提交修改时原子检查版本仍相同才写入并递增版本。冲突时重新读取后重试或交给业务合并。不能把独立的“先查版本再写入”当安全实现;两步之间仍会被并发插入修改。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Consistency and Availability · 查看原书依据

      Optimistic locking, on the other hand, assumes that conflicts are rare and allows transactions to proceed without locking. It relies on version control to detect conflicts. Each resource is assigned a version number or a timestamp, and when a transaction reads a resource, it retrieves the current version number along with the data.

    参考来源

    - 位置:《Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…》第04章《Consistency and Availability》(来源项目book-sources;源文件:extracted/Building Distributed Systems Designing scalable architectures with microservices, event-driven patterns, and robust deployment…/_epub-src/OPS/ch04.xhtml) - 结论依据:原文的机制或对比支持以下核心判断:乐观锁先读数据与版本,在提交修改时原子检查版本仍相同才写入并递增版本。 本卡将相邻说明中的适用限制保留为解释。 - 原始内容:Optimistic locking, on the other hand, assumes that conflicts are rare and allows transactions to proceed without locking. It relies on version control to detect conflicts. Each resource is assigned a version number or a timestamp, and when a transaction reads a resource, it retrieves the current version number along with the data.