知识卡片
条件更新建立所有权
比较并交换在一个原子操作中检查旧值并决定是否写新值,避免两个候选同时看到空闲后都认领。跨节点版本依赖具有相应保证的协调存储;成熟客户端把一致性与失败处理封装起来,比自行拼装共识更可靠。普通读取再写入不具备同样互斥语义。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 10. Ownership Election · 查看原书依据
Compare-and-swap atomically writes a new value if the existing value matches the expected value. If the value doesn’t match, it returns false. If the value doesn’t exist and currentValue is not null, it returns an error. If you haven’t seen compare-and-swap before, it is basically an atomic
参考来源
- 位置:《Designing Distributed Systems, 2nd Edition》第10章《Chapter 10. Ownership Election》(来源项目 book-sources;源文件:extracted/Designing Distributed Systems, 2nd Edition/_epub-src/OEBPS/ch10.html)
- 结论依据:原文定义CAS并推荐用成熟共识键值库实现更高层协调。
- 原始内容:Compare-and-swap atomically writes a new value if the existing value matches the expected value. If the value doesn’t match, it returns false. If the value doesn’t exist and currentValue is not null, it returns an error. If you haven’t seen compare-and-swap before, it is basically an atomic