Day94【概念解析】
行业概念

Day94【概念解析】

· 约 2,312 字 · 阅读约 12 分钟
目录

整理定义

InnoDB Checkpoints (InnoDB 检查点)

As changes are made to data pages that are cached in the buffer pool, those changes are written to the data files sometime later, a process known as flushing. The checkpoint is a record of the latest changes (represented by an LSN value) that have been successfully written to the data files.

当对缓存在缓冲池中的数据页进行更改时,这些更改会在稍后写入数据文件,这个过程称为刷新(Flushing)。 检查点是已成功写入数据文件的最新更改(由 LSN 值表示)的记录。

MySQL :: MySQL 8.0 Reference Manual :: MySQL Glossary

这里重新复习下之前学过的一些词汇:

  1. Buffer pool:是InnoDB存储引擎的一个重要组成部分,它是InnoDB用于缓存表和索引数据的内存区域。

  2. flushing:

  3. LSN(log sequence number):

复述展开

将日志文件设置得非常大可能会减少检查点期间的磁盘 I/O。 将日志文件的总大小设置为与缓冲池一样大甚至更大通常是有意义的。

检查点处理的工作原理

InnoDB 实现了一种称为模糊检查点的检查点机制(fuzzy checkpointing)。 InnoDB 小批量地从缓冲池中刷新修改的数据库页面。 无需在单个批次中刷新缓冲池,否则会在检查点过程中中断用户 SQL 语句的处理。

在崩溃恢复(crash recovery)期间,InnoDB 会查找写入日志文件的检查点标签。 它知道标签之前对数据库的所有修改都存在于数据库的磁盘映像中。 然后InnoDB从检查点向前扫描日志文件,将记录的修改应用到数据库。

crash recovery

MySQL :: MySQL 8.0 Reference Manual :: MySQL Glossary The cleanup activities that occur when MySQL is started again after a crash. For InnoDB tables, changes from incomplete transactions are replayed using data from the redo log. Changes that were committed before the crash, but not yet written into the data files, are reconstructed from the doublewrite buffer. When the database is shut down normally, this type of activity is performed during shutdown by the purge operation. During normal operation, committed data can be stored in the change buffer for a period of time before being written to the data files. There is always a tradeoff between keeping the data files up-to-date, which introduces performance overhead during normal operation, and buffering the data, which can make shutdown and crash recovery take longer.

fuzzy checkpointing

MySQL :: MySQL 8.0 Reference Manual :: MySQL Glossary A technique that flushes small batches of dirty pages from the buffer pool, rather than flushing all dirty pages at once which would disrupt database processing.

理解体会

InnoDB 的检查点是一种优化磁盘 I/O 和确保数据一致性的机制。通过模糊检查点,InnoDB 能够在不中断数据库操作的情况下,逐步将缓冲池中更改过的页面刷新到磁盘。这种方法避免了在检查点时必须执行的大量磁盘写入操作,从而提高了系统的整体性能。

在系统崩溃后,InnoDB 利用检查点机制来恢复数据。它通过检查点标签确定哪些数据已经安全写入磁盘,然后从该点开始应用日志文件中记录的更改,以确保数据库的完整性和一致性。通过这种方式,InnoDB 能够在系统崩溃后快速恢复到最后一致的状态。

另外这章中,我们又学习几个概念:Buffer pool,flush,LSN,crash revovery, fuzzy checkpointing

相关文章