MySQL & InnoDB (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is the Doublewrite Buffer in InnoDB?
senior LevelSystem DesignMySQL
In Simple Words: Operating systems write data in 4 KB blocks, while InnoDB writes in 16 KB pages. If power is lost mid-write, a Partial Page Write (torn page) occurs, leaving the page corrupted:
- The Redo Log cannot repair a page if the underlying page header is corrupted.
- Doublewrite Buffer: Before writing a 16 KB page to the data file, InnoDB writes it contiguously to the Doublewrite Buffer on disk. If a crash occurs, InnoDB restores the intact page from the doublewrite buffer before applying redo logs!