MySQL & InnoDB (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
How does Multi-Version Concurrency Control (MVCC) work in InnoDB?
senior LevelSystem DesignMySQL
In Simple Words: MVCC allows reads and writes to happen simultaneously without blocking each other ("Readers never block writers, writers never block readers"):
- Every InnoDB row contains two hidden system columns:
DB_TRX_ID: The transaction ID that inserted or modified the row.DB_ROLL_PTR: A pointer to the undo log record containing the prior row version.
- When Transaction A begins a read in Repeatable Read mode, it creates a Read View. It only reads rows whose
DB_TRX_IDwas committed before its Read View was created.