Undo Log
Undo Log
Undo Page
Page format
Normal Undo Page
First Page In Linked List
Specific Logs
insert
Speficic data
delete
Flow
Update
Not Update Primary Key
if it’s in-place update, it just update.
else, meaning that record will take more place and it’s not enough, it will delete original record, and insert a new record
Update Primary Key
- delete mask on original record
- create a new record
Second index
if it update second index, it will execute delete mask operation and change File Header’s PAGE_MAX_TRX_ID to the transaction’s id.
Transaction
for a transaction, mysql wiil create at most 2 kinds of undo page list for normal table, respectively insert undo list and update undo list. It’s a lazy load technology meaning that it will be create only it needed. for a temp table, Undo Page List do the same as normal table, but it doesn’t need to create redo page for temp table.
Rollback Segment
Architecture
Fifth Page
Rollback Segment Header Page
Reuse Undo List
If Undo List satisfies two conditions
- only one Undo Page
- used space in the page less than 3/4.
for different kinds of undo page list, has different strategy
- insert undo list: Just Use.
- update undo list : append write a new Undo Log Header and new logs.
Purge
When purge a undo list ?
if the minimum ReadVies’s transaction_no is bigger than this undo list’s transaction_no, it’s time to purge it, meaning that all the ReadViess can see this change.
How to purge a undo list
Insert Undo List
After a transaction commit, for insert undo list, it can be purged right now, because it’s designed to rallback and not useful anymore. But its trx_id and roll_pointer should be keeped, not been purged.
Update Undo List
after a transaction commit, write its transaction_no which means committing order to Undo Logo Header, and the whole list will be insert into history list. History list will range there Undo list order by their transaction_no.
Also, ReadView will be ranged an ordered list order by theirtransaction_no.
While purging, background thread will get current mimimum transaction_no of ReadView list, and check history list, if Uodo list’s transaction_no is less than ReadView’s, the Undo list could be purged.
if Undo list marked delete mask, it will delete record acctually.