当前位置:网站首页>Last write wins (discards concurrent writes)
Last write wins (discards concurrent writes)
2022-07-31 16:39:00 【HUAWEI CLOUD】
A scheme to achieve eventual convergence, where each replica always stores the latest value, allowing old values to be overwritten and discarded.Assuming that every write request eventually syncs to all replicas, as long as it is determined which write is the latest, the replicas will eventually converge to the same value.
But how to define latest?In Figure-12, when a client sends a write request to a database node, neither client is aware of the other client, so it is unclear which happens first.It doesn't really make much sense to argue which happens first, when we say that writes are supported concurrently, we mean that their order is indeterminate.
We can enforce arbitrary ordering even if the "natural ordering" of write requests cannot be determined.For example, append a timestamp to each write request, then choose the latest or largest timestamp, and discard writes with earlier timestamps.This is LWW, last write wins, the only conflict resolution method Cassandra supports.
LWW achieves the ultimate convergence goal, but at the expense of durability: if there are multiple concurrent writes to the same K, even if they all notify the client of success (because w replicas completed the write), it is better toOnly one write will survive, the others will be silently discarded.LWW might even remove those non-concurrent writes.
In some scenarios, such as caching systems, overwrites are acceptable.If overwriting, loss of data is unacceptable, then LWW is not a good choice.
The only way to make LWW safe: write only once, then treat as immutable, avoid concurrent updates to the same K.For example, Cassandra recommends using UUID as K, so that each write operation provides a unique K.
Happens-before relationships and concurrency "happened before" relationships and concurrency
How to judge whether two operations are concurrent?
Cases
As shown below, the two writes are non-concurrent: A's insertion precedes B's incremental modification, because B's incremented value is based on A's inserted value.That is, the B operation is built on the basis of A, so it happens after B.B is causally dependent on A
The two writes in the figure below are concurrent: when each client initiates a write operation, it does not know whether another client is also performing the same K.Therefore, there is no causal relationship between operations
Operation A happens before operation B if B knows A or depends on A or builds on A in some way.Whether an operation occurs before another operation is the key to defining concurrency.It can also be stated simply that two operations are concurrent if neither occurs before the other (ie, neither operation knows about the other) [54].
Therefore, for two operations AB, there are three possibilities: A happens before B or B happens before A or AB is concurrent.We have an algorithm to tell us whether two operations are concurrent:
- If an operation occurs before another operation, the later operation can overwrite the earlier operation
- If these operations are concurrent, there are potential conflicts that need to be resolved
边栏推荐
- 研发过程中的文档管理与工具
- .NET 20周年专访 - 张善友:.NET 技术是如何赋能并改变世界的
- T - sne + data visualization parts of the network parameters
- [TypeScript] In-depth study of TypeScript type operations
- Intelligent bin (9) - vibration sensor (raspberries pie pico implementation)
- 最后写入胜利(丢弃并发写入)
- 多数据中心操作和检测并发写入
- Applicable Scenarios of Multi-Master Replication (1) - Multi-IDC
- AcWing 1282. 搜索关键词 题解((AC自动机)Trie+KMP)+bfs)
- 自动化测试—web自动化—selenium初识
猜你喜欢
组合学笔记(六)局部有限偏序集的关联代数,Möbius反演公式
After Effects 教程,如何在 After Effects 中调整过度曝光的快照?
自动化测试—web自动化—selenium初识
IP协议从0到1
第05章 存储引擎【1.MySQL架构篇】【MySQL高级】
外媒所言非虚,苹果降价或许是真的在清库存
Implementing distributed locks based on Redis (SETNX), case: Solving oversold orders under high concurrency
Qt practical cases (54) - using transparency QPixmap design pictures
深度学习机器学习理论及应用实战-必备知识点整理分享
SringMVC中个常见的几个问题
随机推荐
2.索引及调优篇【mysql高级】
【愚公系列】2022年07月 Go教学课程 021-Go容器之切片操作
无主复制系统(3)-Quorum一致性的局限性
npm安装时卡在sill idealTree buildDeps,npm安装速度慢,npm安装卡在一个地方不动
C language - function
selenium的常见方法及使用
【Meetup预告】OpenMLDB+OneFlow:链接特征工程到模型训练,加速机器学习模型开发
复制延迟案例(1)-最终一致性
多主复制下处理写冲突(1)-同步与异步冲突检测及避免冲突
智能垃圾桶(九)——震动传感器(树莓派pico实现)
How C programs run 01 - the composition of ordinary executable files
The new BMW 3 Series is on the market, with safety and comfort
Stuck in sill idealTree buildDeps during npm installation, npm installation is slow, npm installation is stuck in one place
MySQL常用语句整理
多主复制下处理写冲突(3)-收敛至一致的状态及自定义冲突解决逻辑
t-sne 数据可视化网络中的部分参数+
arm按键控制led灯闪烁(嵌入式按键实验报告)
[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development
JS基础小练习
自动化测试—web自动化—selenium初识