1. MDL does not need to be used explicitly, it will be added automatically when accessed.
2. The function of MDL is to ensure the correctness of reading and writing.
As you can imagine, if a query is traversing the data in a table, and another thread changes the structure of the table and deletes a column during execution, then the results obtained by the query thread will definitely not match the table Structure.
3. MDL was introduced in MySQL version 5.5. When adding, deleting, modifying, and querying a table, add MDL read lock.
Add MDL write lock when making structural changes to the table.
Example
//session A: begin; select * from stu; #commin; //session B: alter table stu add t1 int; //session C: show processlist;
The above is the detailed content of What is the concept of mysql metadata lock. For more information, please follow other related articles on the PHP Chinese website!