I've looked the documentation quite thoroughly but still cannot figure out so asking this question.
In InnoDB, I understand that any updates against buffer pool are tracked by redo log, which gets persisted on the disk, and the redo logs are used for recovery in the case of crash.
Occasionally, the MySQL server also flushes the dirty pages of the Buffer Pool. Under its normal operation, MySQL server only flushed some part of dirty pages, and they call it "fuzzy checkpointing". Under this procedure, the current Buffer Pool is claimed to be recoverable by reading the content of pages on disk and then applying all the redo logs whose LSN is greater than the last checkpoint.
My question is, how does the MySQL server chooses which dirty pages to flush, and also supports the crash-recoverability?
From some googling, I understood that by utilizing the dirty page's first modification LNS number, one can know which pages should be flushed so that the checkpoint LNS can be incremented.
But the dirty page with earliest uncheckpointed redo log can also have been modified by the latest transaction and thus have future content compared to the earliest uncheckpointed redo log. I assume it is very difficult (if possible) to redo from the disk persisted buffer pool pages if those pages includes such future contents.
So question:
- How does the MySQL server chooses which pages to flush, and also support crash recovery?