当前位置:网站首页>MySQL事务提交流程
MySQL事务提交流程
2022-06-23 16:43:00 【用户7353950】
有binlog的CR方式(重点核心!!): 有binlog情况下,commit动作开始时,会有一个Redo XID 的动作记录写到redo,然后写data到binlog,binlog写成功后,会将binlog的filename,日志写的位置position再写到redo(position也会写到pos文件里),此时才表示该事务完成(committed)。如果只有XID,没有后面的filename和position,则表示事务为prepare状态。 流程: commit; --> write XID to redo. --> write data to Binlog. --> write filename,postsion of binlog to redo. --> commited.
记录Binlog是在InnoDB引擎Prepare(即Redo Log写入磁盘)之后,这点至关重要。
如果事务在不同阶段崩溃,recovery时会发——
crash发生阶段 | 事务状态 | 事务结果 |
|---|---|---|
当事务在prepare阶段crash | 该事务未写入Binary log,引擎层也未写redo到磁盘。 | 该事务rollback。 |
当事务在binlog写阶段crash | 此时引擎层redo已经写盘,但Binlog日志还没有成功写入到磁盘中。 | 该事务rollback。 |
当事务在binlog日志写磁盘后crash,但是引擎层没有来得及commit | 此时引擎层redo已经写盘,server层binlog已经写盘,但redo中事务状态未正确结束。 | 读出binlog中的xid,并通知引擎层提交这些XID的事务。引擎提交这些后,会回滚其他的事务,使引擎层redo和binlog日志在事务上始终保持一致。事务通过recovery自动完成提交。 |
总结起来说就是如果一个事务在prepare阶段中落盘成功,并在MySQL Server层中的binlog也写入成功,那这个事务必定commit成功。
(redolog 写成功 && binlog 写成功 == commit,缺一不可。)
边栏推荐
- mysql-选择使用Repeatable read的原因
- Comparison of asemi Schottky diode and ultrafast recovery diode in switching power supply
- Shushulang passed the listing hearing: the gross profit margin of the tablet business fell, and the profit in 2021 fell by 11% year-on-year
- ASEMI快恢复二极管RS1M、US1M和US1G能相互代换吗
- [go] calling Alipay to scan code for payment in a sandbox environment
- 电感参数有哪些?怎么选择电感?
- [network communication -- webrtc] source code analysis of webrtc -- bandwidth estimation at the receiving end
- ABAP essay - material master data interface enhancement
- 酒店入住时间和离店时间的日期选择
- 短视频平台开发,点击输入框时自动弹出软键盘
猜你喜欢

Shushulang passed the listing hearing: the gross profit margin of the tablet business fell, and the profit in 2021 fell by 11% year-on-year

ASEMI快恢复二极管RS1M、US1M和US1G能相互代换吗

测试的重要性及目的

hands-on-data-analysis 第二单元 第四节数据可视化

Counter attack by flour dregs: MySQL 66 question! Suggested collection

Huawei mobile phones install APK through ADB and prompt "the signature is inconsistent. The application may have been modified."

微信小程序:酒店预计到店日期的时间选择器

Rongyun: let the bank go to the "cloud" easily

EasyPlayer移动端播放webrtc协议时长按播放页面无法关闭“关于我们”页面

How important is 5g dual card dual access?
随机推荐
Hands on data analysis unit 2 section 4 data visualization
The evolution of social structure and capital system brought about by the yuan universe
Codeforces Round #620 (Div. 2)ABC
Date selection of hotel check-in time and check-out time
混沌工程在云原生中间件稳定性治理中的实践分享
时间戳90K是什么意思?
千呼万唤,5G双卡双通到底有多重要?
ADC数字地DGND、模拟地AGND的谜团!
Is your PCB ground wire right? Why should we have a master land?
Look, this is the principle analysis of modulation and demodulation! Simulation documents attached
Redis cluster operation method
B. Integers Shop-Hello 2022
How to select an oscilloscope? These 10 points must be considered!
Date转换为LocalDateTime
How important is 5g dual card dual access?
Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 1)
mysql-选择使用Repeatable read的原因
qYKVEtqdDg
《MPLS和VP体系结构》
Mobile cloud jointly builds the capability base of information innovation cloud and helps the development of China's information innovation industry