当前位置:网站首页>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.
边栏推荐
- Unity scene jump and exit
- Imgcat usage experience
- Office提示您的许可证不是正版弹框解决
- Arduino gets the length of the array
- Symbolic representation of functions in deep learning papers
- [Leetcode15]三数之和
- Get the position of the nth occurrence of the string
- [offer18] delete the node of the linked list
- [leetcode15] sum of three numbers
- Page performance optimization of video scene
猜你喜欢
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
Office提示您的许可证不是正版弹框解决
Whistle+switchyomega configure web proxy
Fashion Gen: the general fashion dataset and challenge paper interpretation & dataset introduction
CUDA C programming authoritative guide Grossman Chapter 4 global memory
The dolphin scheduler remotely executes shell scripts through the expect command
js 变量作用域和函数的学习笔记
NRF24L01故障排查
Learning notes of JS variable scope and function
Redis based distributed locks and ultra detailed improvement ideas
随机推荐
Detailed explanation of truncate usage
JS regular expression basic knowledge learning
燕山大学校园网自动登录问题解决方案
Common DOS commands
Who says that PT online schema change does not lock the table, or deadlock
基于Redis的分布式ID生成器
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
单片机蓝牙无线烧录
[offer78] merge multiple ordered linked lists
AMBA、AHB、APB、AXI的理解
Page performance optimization of video scene
[offer29] sorted circular linked list
MySQL takes up too much memory solution
Redis based distributed ID generator
RuntimeError: cuDNN error: CUDNN_ STATUS_ NOT_ INITIALIZED
[offer78]合并多个有序链表
Learning notes of JS variable scope and function
Pat 1097 duplication on a linked list (25 points)
Redis based distributed locks and ultra detailed improvement ideas
Talking about the startup of Oracle Database