当前位置:网站首页>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
边栏推荐
- 智能垃圾桶(九)——震动传感器(树莓派pico实现)
- .NET 20周年专访 - 张善友:.NET 技术是如何赋能并改变世界的
- Automated testing - web automation - first acquaintance with selenium
- 动态规划之线性dp(上)
- server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none 失败
- How C programs run 01 - the composition of ordinary executable files
- Mariabackup implements incremental data backup for Mariadb 10.3
- adb shell 报错error: device unauthorized
- Summary of the implementation method of string inversion "recommended collection"
- 2020 WeChat applet decompilation tutorial (can applet decompile source code be used)
猜你喜欢

阿里三面:MQ 消息丢失、重复、积压问题,如何解决?

Smart Trash Can (8) - Infrared Tube Sensor (Raspberry Pi pico)

使用互相关进行音频对齐

【7.29】代码源 - 【排列】【石子游戏 II】【Cow and Snacks】【最小生成数】【数列】

动态规划(一)

6-22 Vulnerability exploit - postgresql database password cracking

How to switch remote server in gerrit

2022年整理LeetCode最新刷题攻略分享(附中文详细题解)

Premiere Pro 2022 for (pr 2022)v22.5.0

研发过程中的文档管理与工具
随机推荐
多主复制的适用场景(2)-需离线操作的客户端和协作编辑
Applicable scenario of multi-master replication (2) - client and collaborative editing that require offline operation
Replication Latency Case (1) - Eventual Consistency
联邦学习:联邦场景下的多源知识图谱嵌入
对话庄表伟:开源第一课
SHELL内外置命令
百度网盘网页版加速播放(有可用的网站吗)
Implementing DDD based on ABP
How to switch remote server in gerrit
多数据中心操作和检测并发写入
牛客 HJ18 识别有效的IP地址和掩码并进行分类统计
tooltips使用教程(鼠标悬停时显示提示)
无主复制系统(2)-读写quorum
How to install CV2 smoothly in Anaconda
Foreign media right, apple on May be true in inventory
Unity 之 图集属性详解和代码示例 -- 拓展一键自动打包图集工具
【TypeScript】深入学习TypeScript类型操作
npm安装时卡在sill idealTree buildDeps,npm安装速度慢,npm安装卡在一个地方不动
T - sne + data visualization parts of the network parameters
【7.28】代码源 - 【Fence Painting】【合适数对(数据加强版)】

