当前位置:网站首页>Handling Write Conflicts under Multi-Master Replication (1)-Synchronous and Asynchronous Conflict Detection and Conflict Avoidance
Handling Write Conflicts under Multi-Master Replication (1)-Synchronous and Asynchronous Conflict Detection and Conflict Avoidance
2022-07-31 16:39:00 【HUAWEI CLOUD】
The biggest problem of multi-master replication: write conflicts may occur, which must be resolved.
For example, two users edit the wiki at the same time, as shown in Figure-7.User 1 changes the page title from A->B, and User 2 changes the title from A->C at the same time.Each user's changes are successfully committed to the local master node.But when asynchronously replicating to each other, a conflict is found.Normal master-slave replication does not have this problem.

3.2.1 Synchronous and asynchronous conflict detection
If a master-slave replicated database, the second write request will:
- Blocks until the first write is complete
- Or aborted, forcing the user to retry
Under the multi-master replication model, both writes succeed, and conflicts can only be detected asynchronously at a later point in time, when it is too late to ask the user to resolve the conflict.
Theoretically, synchronization conflict detection can be achieved, that is, waiting for the write request to complete the synchronization of all replicas, and then notifying the user that the write is successful.But this will lose the advantage of multi-master: allowing each master to accept write requests independently.Therefore, if you really need synchronization conflict detection, you should consider using master-slave replication with a single master node!
3.2.2 Avoiding conflicts
The best strategy for dealing with conflicts: avoid them, if the application layer can guarantee that all write requests for a particular record go through the same master, there will be no conflicts.In practice, due to the poor conflict resolution implemented by many primary replication models, direct conflict avoidance is the recommended preferred solution.
If users need to edit their own data, it can ensure that requests from specific users are always routed to a specific IDC and read/write using the primary node of that IDC.Different users may correspond to different primary data centers (for example, according to the user's geographic location), but from the user's point of view, this is basically equivalent to the master-slave replication model.
However, it may sometimes be necessary to change the pre-designated primary node, possibly because:
- IDC failure, traffic needs to be rerouted to another IDC
- Or possibly because the user has roamed to another location, near a different IDC
At this time, the conflict avoidance method is no longer effective, and there must be a plan to deal with the possibility of simultaneous writing by different master nodes.
边栏推荐
猜你喜欢

使用互相关进行音频对齐

AcWing 1282. 搜索关键词 题解((AC自动机)Trie+KMP)+bfs)

How to switch remote server in gerrit

Intelligent bin (9) - vibration sensor (raspberries pie pico implementation)

Qt实战案例(54)——利用QPixmap设计图片透明度

C language - function

After Effects 教程,如何在 After Effects 中调整过度曝光的快照?
![[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development](/img/f6/311d5a4c70993df6291250d2025d3f.jpg)
[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development

6-22 Vulnerability exploit - postgresql database password cracking

【C语言】LeetCode27.移除元素
随机推荐
server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none 失败
Stuck in sill idealTree buildDeps during npm installation, npm installation is slow, npm installation is stuck in one place
2020 WeChat applet decompilation tutorial (can applet decompile source code be used)
【愚公系列】2022年07月 Go教学课程 021-Go容器之切片操作
复杂高维医学数据挖掘与疾病风险分类研究
2.索引及调优篇【mysql高级】
苹果官网样式调整 结账时产品图片“巨大化”
How to switch remote server in gerrit
C程序是如何跑起来的01 —— 普通可执行文件的构成
LeetCode_733_Image rendering
单细胞测序流程(单细胞rna测序)
并发性,时间和相对性
基于Redis(SETNX)实现分布式锁,案例:解决高并发下的订单超卖,秒杀
form 表单提交后,使页面不跳转[通俗易懂]
Summary of the implementation method of string inversion "recommended collection"
.NET 20th Anniversary Interview - Zhang Shanyou: How .NET technology empowers and changes the world
认识异常 (看完这篇你就懂了)
入职一个月反思
第05章 存储引擎【1.MySQL架构篇】【MySQL高级】
Qt practical cases (54) - using transparency QPixmap design pictures