Description:
Hi, guys
When I executed LOCK TABLE test01 WRITE command, the table of PERFORMANCE_SCHEMA.metadata_locks displayed the MDL lock duration as TRANSACTION, But actually it should be EXPLICIT.
And, after I executed ALTER TABLE test01 RENAME test02, there was no MDL locks held by the test02.
At this point, another thread can insert or update data in the test02. However, version 8.0 cannot perform this operation.
How to repeat:
MySQL [test]> create table test01 (id int);
Query OK, 0 rows affected (0.01 sec)
MySQL [test]> insert into test01 values (1);
Query OK, 1 row affected (0.00 sec)
MySQL [test]> lock table test01 write;
Query OK, 0 rows affected (0.00 sec)
MySQL [test]> select * from performance_schema.metadata_locks;
+-------------+--------------------+----------------+-----------------------+----------------------+---------------+-------------+--------+-----------------+----------------+
| OBJECT_TYPE | OBJECT_SCHEMA | OBJECT_NAME | OBJECT_INSTANCE_BEGIN | LOCK_TYPE | LOCK_DURATION | LOCK_STATUS | SOURCE | OWNER_THREAD_ID | OWNER_EVENT_ID |
+-------------+--------------------+----------------+-----------------------+----------------------+---------------+-------------+--------+-----------------+----------------+
| GLOBAL | NULL | NULL | 140204644129344 | INTENTION_EXCLUSIVE | STATEMENT | GRANTED | | 38 | 20 |
| SCHEMA | test | NULL | 140204644112592 | INTENTION_EXCLUSIVE | TRANSACTION | GRANTED | | 38 | 20 |
| TABLE | test | test01 | 140204644038224 | SHARED_NO_READ_WRITE | TRANSACTION | GRANTED | | 38 | 20 |
| BACKUP | NULL | NULL | 140204644128992 | INTENTION_EXCLUSIVE | STATEMENT | GRANTED | | 38 | 20 |
| TABLE | performance_schema | metadata_locks | 140204644145808 | SHARED_READ | TRANSACTION | GRANTED | | 38 | 21 |
+-------------+--------------------+----------------+-----------------------+----------------------+---------------+-------------+--------+-----------------+----------------+
5 rows in set (0.00 sec)
MySQL [test]> alter table test01 rename test02;
Query OK, 0 rows affected (0.00 sec)
MySQL [test]> select * from performance_schema.metadata_locks;
+-------------+--------------------+----------------+-----------------------+---------------------+---------------+-------------+--------+-----------------+----------------+
| OBJECT_TYPE | OBJECT_SCHEMA | OBJECT_NAME | OBJECT_INSTANCE_BEGIN | LOCK_TYPE | LOCK_DURATION | LOCK_STATUS | SOURCE | OWNER_THREAD_ID | OWNER_EVENT_ID |
+-------------+--------------------+----------------+-----------------------+---------------------+---------------+-------------+--------+-----------------+----------------+
| GLOBAL | NULL | NULL | 140204644129344 | INTENTION_EXCLUSIVE | STATEMENT | GRANTED | | 38 | 20 |
| SCHEMA | test | NULL | 140204644112592 | INTENTION_EXCLUSIVE | TRANSACTION | GRANTED | | 38 | 20 |
| BACKUP | NULL | NULL | 140204644128992 | INTENTION_EXCLUSIVE | STATEMENT | GRANTED | | 38 | 20 |
| TABLE | performance_schema | metadata_locks | 140204644145808 | SHARED_READ | TRANSACTION | GRANTED | | 38 | 23 |
+-------------+--------------------+----------------+-----------------------+---------------------+---------------+-------------+--------+-----------------+----------------+
4 rows in set (0.01 sec)
------ Another thread -------
MySQL [test]> insert into test02 values (2);
Query OK, 1 row affected (0.00 sec)