当前位置:网站首页>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
边栏推荐
- i.MX6ULL driver development | 33 - NXP original network device driver reading (LAN8720 PHY)
- Smart Trash Can (8) - Infrared Tube Sensor (Raspberry Pi pico)
- LevelSequence源码分析
- 利用PHP开发具有注册、登陆、文件上传、发布动态功能的网站
- 【C语言】LeetCode27.移除元素
- Website vulnerability repair service provider's analysis of unauthorized vulnerability
- Replication Latency Case (3) - Monotonic Read
- npm安装时卡在sill idealTree buildDeps,npm安装速度慢,npm安装卡在一个地方不动
- 单细胞测序流程(单细胞rna测序)
- 对话庄表伟:开源第一课
猜你喜欢
基于Redis(SETNX)实现分布式锁,案例:解决高并发下的订单超卖,秒杀
Huawei's top engineers lasted nine years "anecdotal stories network protocol" PDF document summary, is too strong
基于C语言的编译器设计与实现
深度学习机器学习理论及应用实战-必备知识点整理分享
t-sne 数据可视化网络中的部分参数+
GP 6总体架构学习笔记
Design and Implementation of Compiler Based on C Language
.NET 20周年专访 - 张善友:.NET 技术是如何赋能并改变世界的
【7.29】Code Source - 【Arrangement】【Stone Game II】【Cow and Snacks】【Minimum Number of Spawns】【Sequence】
【C语言】LeetCode27.移除元素
随机推荐
复制延迟案例(3)-单调读
Applicable Scenarios of Multi-Master Replication (1) - Multi-IDC
Oracle dynamically registers non-1521 ports
flutter设置statusbar状态栏的背景颜色和 APP(AppBar)内部颜色一致方法。
Design and Implementation of Compiler Based on C Language
server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none 失败
go图书管理系统
关于柱状图的经典画法总结
Graham's Scan method for solving convex hull problems
对话庄表伟:开源第一课
多主复制下处理写冲突(1)-同步与异步冲突检测及避免冲突
无主复制系统(1)-节点故障时写DB
苹果官网样式调整 结账时产品图片“巨大化”
Handling write conflicts under multi-master replication (4) - multi-master replication topology
智能垃圾桶(九)——震动传感器(树莓派pico实现)
【luogu P8326】Fliper(图论)(构造)(欧拉回路)
Applicable scenario of multi-master replication (2) - client and collaborative editing that require offline operation
ansible study notes 02
智能垃圾桶(八)——红外对管传感器(树莓派pico)
Flutter gets the height of the status bar statusbar