当前位置:网站首页>多主复制下处理写冲突(1)-同步与异步冲突检测及避免冲突
多主复制下处理写冲突(1)-同步与异步冲突检测及避免冲突
2022-07-31 16:31:00 【华为云】
多主复制最大问题:可能发生写冲突,必须解决之。
如两个用户同时编辑wiki,如图-7。用户1将页面标题从A-》B,且用户2同时将标题从A-》C。每个用户的更改都成功提交到本地主节点。但当异步复制到对方时,发现存在冲突。正常的主从复制则不会出现此问题。
3.2.1 同步与异步冲突检测
若为主从复制数据库,第二个写请求将:
- 被阻塞直到第一个写完成
- 或被中止,强制用户必须重试
多主节点的复制模型下,这两个写都是成功的,且只能在稍后时间点才能异步检测到冲突,那时再要求用户解决冲突为时已晚。
理论上能做到同步冲突检测,即等待写请求完成对所有副本的同步,再通知用户写成功。但这样会失去多主的优点:允许每个主节点独立接受写请求。所以,若确实需要同步冲突检测,应考虑使用单主节点的主从复制!
3.2.2 避免冲突
处理冲突的最理想策略:避免它们,若应用层能保证对特定记录的所有写请求都通过同一主节点,就不会冲突。实践中,由于很多主节点复制模型所实现的冲突解决方案很不好,因此直接避免冲突是推荐首选方案。
如用户需编辑自己的数据,可确保特定用户的请求始终路由到特定IDC,并使用该IDC的主节点读/写。不同用户可能对应不同主数据中心(如根据用户地理位置选择),但从用户角度看,这基本等价于主从复制模型。
但有时可能需更改事先指定的主节点,可能因为:
- IDC故障,需将流量重新路由到另一个IDC
- 或可能因为用户已漫游到另一个位置,接近了不同的IDC
此时,冲突避免方式不再有效,必须要有方案应对不同主节点同时写入的可能。
边栏推荐
- Snake Project (Simple)
- 【7.28】代码源 - 【Fence Painting】【合适数对(数据加强版)】
- "Autumn Recruitment Series" MySQL Interview Core 25 Questions (with answers)
- adb shell error error: device unauthorized
- LevelSequence源码分析
- 百度网盘网页版加速播放(有可用的网站吗)
- go图书管理系统
- 关于柱状图的经典画法总结
- 智能垃圾桶(八)——红外对管传感器(树莓派pico)
- T - sne + data visualization parts of the network parameters
猜你喜欢
After Grafana is installed, the web opens and reports an error
[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development
华为顶级工程师历时9年总结的“趣谈网络协议”PDF文档,太强了
adb shell error error: device unauthorized
Graham's Scan method for solving convex hull problems
上传图片-微信小程序(那些年的坑记录2022.4)
T - sne + data visualization parts of the network parameters
LevelSequence源码分析
[TypeScript] In-depth study of TypeScript type operations
复杂高维医学数据挖掘与疾病风险分类研究
随机推荐
【C语言】LeetCode27.移除元素
LeetCode_733_Image rendering
The arm button controls the flashing of the led light (embedded button experiment report)
多主复制的适用场景(2)-需离线操作的客户端和协作编辑
C程序是如何跑起来的01 —— 普通可执行文件的构成
[pytorch] 1.7 pytorch and numpy, tensor and array conversion
Mariabackup implements incremental data backup for Mariadb 10.3
TypeError: unhashable type: ‘list‘
外媒所言非虚,苹果降价或许是真的在清库存
第二届中国PWA开发者日
2.索引及调优篇【mysql高级】
ansible study notes 02
Three aspects of Ali: How to solve the problem of MQ message loss, duplication and backlog?
Intelligent bin (9) - vibration sensor (raspberries pie pico implementation)
LevelSequence源码分析
ML.NET related resources
Website vulnerability repair service provider's analysis of unauthorized vulnerability
[7.28] Code Source - [Fence Painting] [Appropriate Pairs (Data Enhanced Version)]
研发过程中的文档管理与工具
Applicable Scenarios of Multi-Master Replication (1) - Multi-IDC