当前位置:网站首页>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,缺一不可。)
边栏推荐
- Date selection of hotel check-in time and check-out time
- [network communication -- webrtc] analysis of webrtc source code -- supplement of pacingcontroller related knowledge points
- 手机开户流程是什么?现在网上开户安全么?
- ELK日志收集系统部署
- Jetpack compose and material you FAQs
- Easyplayer mobile terminal plays webrtc protocol for a long time. Pressing the play page cannot close the "about us" page
- 公司招了个五年经验的测试员,见识到了真正的测试天花板
- 时间戳90K是什么意思?
- [untitled] Application of laser welding in medical treatment
- How long does it take to open a stock account by mobile phone? Is online account opening safe?
猜你喜欢
![[30. concatenate substrings of all words]](/img/e7/453c8524a23fbb7501e85140547ce1.png)
[30. concatenate substrings of all words]

Another breakthrough! Alibaba cloud enters the Gartner cloud AI developer service Challenger quadrant

测试的重要性及目的

接口的所有权之争

Ctfshow PHP features
![[untitled] Application of laser welding in medical treatment](/img/c5/9c9edf1c931dfdd995570fa20cf7fd.png)
[untitled] Application of laser welding in medical treatment

Here comes the official zero foundation introduction jetpack compose Chinese course!

图扑软件数字孪生挖掘机实现远程操控

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

JS常见的报错及异常捕获
随机推荐
使用Jmeter进行性能测试及性能监控平台搭建
Jmeter压力测试教程
ASEMI肖特基二极管和超快恢复二极管在开关电源中的对比
DataNode进入Stale状态问题排查
股票网上开户及开户流程怎样?在线开户安全么?
短视频平台开发,点击输入框时自动弹出软键盘
Robot Orientation and some misunderstandings in major selection in college entrance examination
三分钟学会如何找回mysql密码
Asemi ultrafast recovery diode es1j parameters, es1j package, es1j specification
How to configure MySQL log management
数据库 实验二 查询
Date转换为LocalDateTime
内网渗透令牌窃取
QT layout manager [qvboxlayout, qhboxlayout, qgridlayout]
【网络通信 -- WebRTC】WebRTC 源码分析 -- PacingController 相关知识点补充
A number of individual stocks in Hong Kong stocks performed actively, triggering investors' speculation and concern about the recovery of the Hong Kong stock market
Is it cost-effective to buy a long-term financial product?
ASEMI快恢复二极管RS1M、US1M和US1G能相互代换吗
mysql-选择使用Repeatable read的原因
How to use SQL window functions