Part 4 of 5 · 2 min read
The dirty page eventually reaches disk
A background process flushes dirty pages to the data file, completing the path from memory to permanent storage.
The dirty page eventually reaches disk
Think of the warehouse copying logbook changes onto the master inventory sheet. It does this in one daily batch, rather than rewriting that sheet after every single logged change.
In plain words: the dirty page sitting in the buffer pool is written to the actual data file on disk later, either because the buffer pool needs the space for another page, as covered on the buffer pool page, or because a periodic background process flushes dirty pages on a schedule. Once the flush succeeds, the data file on disk finally matches what the in-memory page already showed.
A worked example. Some time after the price update, a background flush writes the dirty page containing book_id 501 back to the data file, and the on-disk price finally reads 24.99.
The key lines. No new SQL; the flush is an internal storage-engine action, not something a query triggers directly.
Page flush
A page flush writes a dirty page's in-memory contents back to its corresponding location in the data file on disk, making the on-disk copy match the in-memory copy.
Example: the warehouse's batch copy of logged changes onto the master inventory sheet is a page flush.
Remember this
The write path has three stops, not one: change the in-memory page, log the change durably, then flush the page to disk later. This ordering, log before data, is exactly what Level 8's recovery modules rely on to recover correctly after a crash.
Quick notes
- A write first changes an in-memory copy of a page in the buffer pool, not the data file directly.
- A write-ahead log entry describing the change is written durably before the data page change is guaranteed on disk.
- The dirty page reaches the data file later, through eviction or a periodic background flush.
- This log-before-data ordering is the foundation Level 8's recovery modules build on.
- Levels 7 and 8 return to this same write path in far more depth.