当前位置:网站首页>InnoDB dirty page refresh mechanism checkpoint in MySQL
InnoDB dirty page refresh mechanism checkpoint in MySQL
2022-07-06 12:35:00 【wx5caecf2ed0645】
We know InnoDB use Write Ahead Log Policies to prevent downtime and data loss , When the transaction is committed , Write the redo log first , Then modify the memory data page , This produces dirty pages . Since there are redo logs to ensure data persistence , When querying, you can also directly get data from the buffer pool page , Then why flush dirty pages to disk ? If the redo log can be increased infinitely , At the same time, the buffer pool is large enough , Able to cache all data , There is no need to flush the dirty pages in the buffer pool to the disk . however , There are usually the following questions :
- Server memory is limited , There is not enough buffer pool , Unable to cache all data
- Redo logs increase infinitely, and the cost is too high
- If you redo all logs during downtime, the recovery time is too long
in fact , When the database goes down , The database does not need to redo all the logs , Just execute the log after the last swipe point . This point is called Checkpoint, It solves the above problems :
- Reduce database recovery time
- When the buffer pool is insufficient , Flush the dirty page to disk
- When the redo log is not available , Refresh the dirty pages
Redo logs are designed to be recyclable , When the log file is full , The corresponding data in the redo log has been refreshed to the disk, and the logs that are no longer needed can be overwritten and reused .
InnoDB The engine goes through LSN(Log Sequence Number) To mark the version ,LSN Is the end point of each log in the log space , In terms of byte offset . Every page Yes LSN,redo log Also have LSN,Checkpoint Also have LSN. By command show engine innodb status
To observe :
---
LOG
---
Log sequence number 11102619599
Log flushed up to 11102618636
Last checkpoint at 11102606319
0 pending log writes, 0 pending chkp writes
15416290 log i/o's done, 12.32 log i/o's/second
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
Checkpoint How many pages does the mechanism refresh at a time , Where to get the dirty pages , When to trigger refresh ? These are very complicated . There are two kinds of Checkpoint, Respectively :
- Sharp Checkpoint
- Fuzzy Checkpoint
Sharp Checkpoint It happened when the database was shut down , Brush all dirty pages back to disk . Use at run time Fuzzy Checkpoint Refresh some dirty pages . There are several ways to refresh some dirty pages :
- Master Thread Checkpoint
- FLUSH_LRU_LIST Checkpoint
- Async/Sync Flush Checkpoint
- Dirty Page too much Checkpoint
Master Thread Checkpoint
Master Thread Refresh a certain proportion of pages from the dirty page list of the buffer pool back to disk at the rate of per second or per ten seconds . This process is asynchronous , Does not block the query thread .
FLUSH_LRU_LIST Checkpoint
InnoDB Make sure that LRU The list is 100 Left and right free pages can be used . stay InnoDB1.1.X Before version , To check LRU Whether there are enough pages for the user to query the operation thread , without , Will LRU The page at the end of the list , If there are dirty pages in the eliminated pages , Will be enforced Checkpoint Brush back dirty page data to disk , Obviously this will block the user query thread . from InnoDB1.2.X Version start , This check is placed in a separate Page Cleaner Thread In the middle of , And users can use innodb_lru_scan_depth
control LRU The number of pages available in the list , The default value is 1024.
Async/Sync Flush Checkpoint
When the redo log file is not available , You need to force some pages in the dirty page list back to disk . This ensures that redo log files can be recycled . stay InnoDB1.2.X Before the release ,Async Flush Checkpoint Will block the user query thread that finds the problem ,Sync Flush Checkpoint Will block all query threads .InnoDB1.2.X Then put it in a separate Page Cleaner Thread.
Dirty Page too much Checkpoint
When there are too many dirty pages ,InnoDB The engine will force Checkpoint. The purpose is to ensure that there are enough free pages available in the buffer pool . This can be done through parameters innodb_max_dirty_pages_pct
To set up :
mysql> show variables like 'innodb_max_dirty_pages_pct';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| innodb_max_dirty_pages_pct | 90 |
+----------------------------+-------+
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
边栏推荐
- Get the position of the nth occurrence of the string
- Unity3D,阿里云服务器,平台配置
- [leetcode19] delete the penultimate node in the linked list
- Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
- Esp8266 connect onenet (old mqtt mode)
- About using @controller in gateway
- (课设第一套)1-4 消息传递接口 (100 分)(模拟:线程)
- Single chip Bluetooth wireless burning
- Understanding of AMBA, AHB, APB and Axi
- Symbolic representation of functions in deep learning papers
猜你喜欢
JS regular expression basic knowledge learning
Gravure sans fil Bluetooth sur micro - ordinateur à puce unique
History object
Esp8266 connect onenet (old mqtt mode)
基於Redis的分布式ID生成器
Générateur d'identification distribué basé sur redis
Unity3D,阿里云服务器,平台配置
Arduino JSON data information parsing
idea中导包方法
VSCode基础配置
随机推荐
Redis based distributed locks and ultra detailed improvement ideas
Minio file download problem - inputstream:closed
NRF24L01 troubleshooting
The dolphin scheduler remotely executes shell scripts through the expect command
[leetcode622] design circular queue
CUDA C programming authoritative guide Grossman Chapter 4 global memory
Solution to the problem of automatic login in Yanshan University Campus Network
Who says that PT online schema change does not lock the table, or deadlock
Arduino gets the length of the array
Naive Bayesian theory derivation
ES6语法总结--下篇(进阶篇 ES6~ES11)
[esp32 learning-2] esp32 address mapping
Arm pc=pc+8 is the most understandable explanation
What is the maximum length of MySQL varchar field
2021.11.10汇编考试
Unity3D摄像机,键盘控制前后左右上下移动,鼠标控制旋转、放缩
Common DOS commands
(5) Introduction to R language bioinformatics -- ORF and sequence analysis
Minio文件下载问题——inputstream:closed
Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect