Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql 5.6online DDL

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Online ddl mainly includes three stages: prepare stage, ddl implementation stage and commit stage. Rebuild has essentially one more ddl implementation stage than no-rebuild, and the prepare stage is similar to the commit stage. The following will focus on the process of the three stages of ddl execution.

Prepare phase:

Create a new temporary frm file (independent of InnoDB)

Holds EXCLUSIVE-MDL lock, forbids reading and writing

Determine the execution mode (copy,online-rebuild,online-norebuild) according to the alter type

If it is Add Index, then choose online-norebuild or INPLACE mode.

Update the memory object of the data dictionary

Assign row_log object record increments (required only for rebuild types)

Generate a new temporary ibd file (required only for rebuild types)

Ddl execution phase:

Downgrade EXCLUSIVE-MDL lock to allow read and write

Scan every record in old_table 's clustered index rec

Traverse the clustered index and secondary index of the new table, processing them one by one

Construct the corresponding index entry according to rec

Insert the construction index entry into the sort_buffer block sort

Update the sort_buffer block to the new index

Record the increments generated during ddl execution (required only by the rebuild type)

Replay the operations in row_log to the new index (no-rebuild data is updated on the original table)

Replay the row_log to generate the dml operation append to the last Block of the row_log

Commit phase:

When the current Block is the last row_log, disable reading and writing, upgrade to EXCLUSIVE-MDL lock

Redo the last part of the increment in row_log

Update the data dictionary table of innodb

Commit the transaction (swipe the redo log of the transaction)

Modify statistics

Rename temporary idb file, frm file

Change completed

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report