当前位置:网站首页>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.
边栏推荐
- Replication Latency Case (1) - Eventual Consistency
- [Source code analysis] BeanFactory and FactoryBean
- 【pytorch】pytorch 自动求导、 Tensor 与 Autograd
- The 2nd China PWA Developer Day
- MySQL多表联合查询
- 利用PHP开发具有注册、登陆、文件上传、发布动态功能的网站
- [pytorch] pytorch automatic derivation, Tensor and Autograd
- LeetCode_733_Image rendering
- Applicable scenario of multi-master replication (2) - client and collaborative editing that require offline operation
- Implementing distributed locks based on Redis (SETNX), case: Solving oversold orders under high concurrency
猜你喜欢
Unity 之 图集属性详解和代码示例 -- 拓展一键自动打包图集工具
.NET 20th Anniversary Interview - Zhang Shanyou: How .NET technology empowers and changes the world
Implementing distributed locks based on Redis (SETNX), case: Solving oversold orders under high concurrency
Premiere Pro 2022 for (pr 2022)v22.5.0
6-22漏洞利用-postgresql数据库密码破解
【7.29】代码源 - 【排列】【石子游戏 II】【Cow and Snacks】【最小生成数】【数列】
动态规划(一)
gerrit中如何切换远程服务器
i.MX6ULL driver development | 33 - NXP original network device driver reading (LAN8720 PHY)
第05章 存储引擎【1.MySQL架构篇】【MySQL高级】
随机推荐
Single-cell sequencing workflow (single-cell RNA sequencing)
SHELL内外置命令
Huawei's top engineers lasted nine years "anecdotal stories network protocol" PDF document summary, is too strong
无主复制系统(2)-读写quorum
Flutter set the background color of the statusbar status bar and APP method (AppBar) internal consistent color.
After Effects 教程,如何在 After Effects 中调整过度曝光的快照?
t-sne 数据可视化网络中的部分参数+
Stuck in sill idealTree buildDeps during npm installation, npm installation is slow, npm installation is stuck in one place
牛客 HJ17 坐标移动
Golang——从入门到放弃
【pytorch】1.7 pytorch与numpy,tensor与array的转换
使用 Postman 工具高效管理和测试 SAP ABAP OData 服务的试读版
字符串反转的实现方法总结「建议收藏」
MySQL多表联合查询
tooltips使用教程(鼠标悬停时显示提示)
基于Redis(SETNX)实现分布式锁,案例:解决高并发下的订单超卖,秒杀
js的toString方法
npm安装时卡在sill idealTree buildDeps,npm安装速度慢,npm安装卡在一个地方不动
C language - function
LevelSequence源码分析