当前位置:网站首页>stop slave卡住--事务的事件没有复制完整
stop slave卡住--事务的事件没有复制完整
2022-07-02 22:07:00 【翔云123456】
在文章stop slave卡住,初步介绍了stop slave的问题现象以及一些原因。
以及文章stop slave 卡住模拟–大事务场景中,介绍了大事务场景中,stop slave的模拟。
本文介绍另外一种情况:一个事务的事件没有完整复制到从库。
主从架构中,在主库上更新数据后,会写入binlog,并复制到从库。
在事务型存储引擎中,如innoDB,数据更新以事务为单位。
一个事务通常有很多event组成,例如begin, commit,query, write_rows等等。
在主库上提交一个事务,事件写入binlog,再复制到从库,从库接着开始回放binlog。从库回放binlog,并不是一个事务的所有event都复制过来以后,才开始回放的,而是一边I/O线程接收binlog日志,一边SQL 线程应用binlog日志。
这样,就可能存在一个问题,如果一个事务的event比较多,只将一部分event复制到从库,此时主库故障 或 网络断开,从库上一直无法接收剩余的event,导致SQL线程一直在等待剩余event。
在这个时候,在从库上执行stop slave,SQL 线程会等待,直到超过等待时间(默认60s),然后回滚事务。
基本的排查思路:
- 查看大事务正在执行的event(预先有大事务监控,可以采集正在执行的event)。
- 查看从库的错误日志,确定当时从库正在复制的主库的日志位点。使用这个日志位点,在老主库的binlog中查找对应的事件。
- 分析原因:
- 如果正在执行的是begin事件,且从库复制位点对应的事件不是commit,则可以得出,导致stop slave 超时的原因是事务的事件没有接收完整。
- 正在执行的SQL是 正常更新SQL,则导致stop slave超时原因可能是事务比较大,实际执行很耗时,也可能是事件没有接收完整(因为无法确定正在执行的事务与正在复制的事务是否同一个)。
边栏推荐
- What is the'function'keyword used in some bash scripts- What is the 'function' keyword used in some bash scripts?
- [QT] QT multithreading development - reentrancy and thread safety
- Zhong Xuegao responded that the product will not melt for 1 hour: it contains solid components and cannot melt into water
- UE4 游戏架构 学习笔记
- 数学建模——图与网络模型及方法(一)
- NC50965 Largest Rectangle in a Histogram
- 【ODX Studio编辑PDX】-0.1-如何快速查看各Variant变体间的支持的诊断信息差异(服务,Sub-Function...)
- 存储单位换算
- [error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
- Oracle cursor
猜你喜欢
SimpleITK使用——4. 奇怪的問題
Struct, bit segment, enumeration, union
Mathematical modeling -- graph and network models and methods (I)
[foreign journal] sleep and weight loss
Objects and object variables
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)
UE4 游戏架构 学习笔记
Oracle cursor
SimpleITK使用——3. 常见操作
E-commerce system microservice architecture
随机推荐
Commodity information management system (C language document version)
'when to use const char * and when to use const char []' - when to use const char * and when to use const char []
建立自己的网站(22)
SimpleITK使用——4. 奇怪的問題
【微服务|Sentinel】重写sentinel的接口BlockExceptionHandler
全面解析分享购商业模式逻辑?分享购是如何赋能企业
高并发介绍及应对
How should programmers write logs
Market Research - current market situation and future development trend of marine wet exhaust hose
钟薛高回应产品1小时不化:含固体成分 融化不能变成水
go 条件变量
傑理之修改不需要長按開機功能【篇】
JS solution for obtaining the width and height of hidden elements whose display is none
Jatpack------LiveData
Wait to solve the zombie process
杰理之修改不需要长按开机功能【篇】
Market Research - current market situation and future development trend of total nutrition products
JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)
存储单位换算
Jerry's modification does not require long press the boot function [chapter]