当前位置:网站首页>MySQL series transaction log redo log learning notes
MySQL series transaction log redo log learning notes
2022-07-01 21:48:00 【51CTO】
MySQL Series of transaction logs Redo log Learning notes
Before learning this blog, you need to reserve knowledge :
- MySQL Architecture
- InnoDB Storage engine
- MySQL Business knowledge
In the last blog , We know undo log, Continue with the last blog , Learn another important InnoDB Transaction log redo log
1、Redo Log
1.1、 What is? Redo log?
Redo : Do it again ,undo Undo rollback means
Redo log: It is called redo log , When an accident occurs in the database , Data recovery ,redo log The backup is the modified data in the process of transaction execution ,redo log The latest data location during the transaction is backed up
1.2、Redo log working principle
Previous learning , We know undo log Is a log record for rollback , It belongs to logical log , And this blog introduces redo log It's a physical log , As long as it is used to prevent system redundancy and other special situations , When this happens , restart mysql Will read redo log, Thus, some data that is not written to the disk is written to the disk for persistent storage
Based on the diagram of blog in the previous chapter , Expand , Compare the undo log and redo log
- undo log and redo logo All are InnoDB The function of , All transaction logs
- undo log It's a logical log , Record is the operation record log ,redo log It's a physical log , New data is recorded
- undo log It is designed to ensure the atomicity of transactions ,redo log It is set to ensure transaction persistence .undo log stay InnoDB Is used to realize multi version control , perform rollback In operation ,undo log It can be used as a snapshot read reference for transaction rollback , and redo log Is the latest data location for backup , System redundancy , Just restart mysql service , You can persist unsaved data to disk
Insert picture description here
1.3、Redo log Write mechanism
Insert picture description here
- write point: This pointer records the current position , While writing , Move along , Write to the end of the last file and go back to 0 No. file overwrites again
- check point: This pointer records the current position to be erased , It's also going back and forth , Before erasing a record, update the record to a data file
quote 51 Legend of blog : The picture is from https://blog.51cto.com/wangwei007/2287431
redo log When it is full , The pointer returns to the origin , Restart overwrite save , If write pos Catch up checkpoint, Indicates full , No new updates can be performed at this time , You have to stop and erase some records , hold checkpoint Push forward the node
1.4、Redo log Configuration parameters
Check... By command redo log Parameters :
1.5、Redo Data persistence strategy
【 Expand knowledge 】, Every InnoDB The storage engine has at least 1 Log redo filegroups (redo file group), Each filegroup has at least 2 individual redo Log files , The default is ib_logfile0
and ib_logfile1
, The storage path is ${datadir}
Redo Buffer Persist to Redo Log The strategy of , Through the variable innodb_flush_log_at_trx_commit
The value of
Insert picture description here
- 0: Set the value to 0, Express Log Buffer The data in does not go through OS cache , Call directly fsync Directly brush to disk file to save
- 1: Set the value to 1( The default value is ), After the transaction is committed , It will be saved to log buffer, Then save to os buffer cache , At the same time call fsync Sync to disk
- 2: Set the value to 2, The data is not written log buffer, Cache directly to os buffer, Every second , call fsync Swipe data to disk
appendix : Reference material
- MySQL InnoDB redo Log elementary analysis
- Detailed analysis MySQL Transaction log (redo log and undo log)
边栏推荐
猜你喜欢
随机推荐
【深度学习】利用深度学习监控女朋友的微信聊天?
测试撤销1
K-means based user portrait clustering model
MySQL系列之事务日志Redo log学习笔记
选择在同花顺上炒股开户可以吗?安全吗?
二叉树的基本操作
都能看懂的LIS(最长上升子序列)问题[通俗易懂]
PHP 读取ini或env类型配置
JS how to get a list of elements in a collection object
idea中类中显示成员变量和方法
tensorflow 张量做卷积,输入量与卷积核维度的理解
杰理之蓝牙耳机品控和生产技巧【篇】
AirServer手机第三方投屏电脑软件
PMP与NPDP之间的区别是什么?
杰理之、产线装配环节【篇】
手动实现function isInstanceOf(child,Parent)
同花顺股票开户选哪个券商好手机开户是安全么?
cmake工程化相关
【STM32】STM32CubeMX教程二–基本使用(新建工程点亮LED灯)
ICML2022 | 基于元语义正则化的介入性对比学习