当前位置:网站首页>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)
边栏推荐
猜你喜欢

Introduction à l'ingénierie logicielle (sixième édition) notes d'examen de Zhang haifan

杰理之、产线装配环节【篇】

BlocProvider 为什么感觉和 Provider 很相似?

《軟件工程導論(第六版)》 張海藩 複習筆記

Flume面试题

Pytest Collection (2) - mode de fonctionnement pytest

leetcode刷题:二叉树01(二叉树的前序遍历)

BC35&BC95 ONENET MQTT(旧)

人才近悦远来,望城区夯实“强省会”智力底座

4. 对象映射 - Mapping.Mapstercover
随机推荐
Simple interactive operation of electron learning (III)
NIO与传统IO的区别
String类型转换BigDecimal、Date类型
Manually implement function isinstanceof (child, parent)
股票手机开户哪个app好,安全性较高的
idea中类中显示成员变量和方法
latex如何打空格
杰理之烧录上层版物料需要【篇】
基于YOLOv5的口罩佩戴检测方法
PCB线路板塞孔工艺的那些事儿~
Go — 相关依赖对应的exe
locust 系列入门
月入1W+的自媒体达人都会用到的运营工具
从MLPerf谈起:如何引领AI加速器的下一波浪潮
tensorflow 张量做卷积,输入量与卷积核维度的理解
基础—io密集型计算和cpu密集型计算
TOPS,处理器运算能力单位、每秒钟可进行一万亿次
考虑关系的图卷积神经网络R-GCN的一些理解以及DGL官方代码的一些讲解
There are four ways to write switch, you know
分离字符串中的字母和数字并使得字母在前数组在后