Bug #96042 metadata lock waiting
Submitted: 1 Jul 2019 8:00 Modified: 1 Jul 2019 13:07
Reporter: chunyang xu Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.7.18 OS:Any
Assigned to: CPU Architecture:Any
Tags: Metadata lock, rollback

[1 Jul 2019 8:00] chunyang xu
Description:
when alter a table ,  it can't  finish successfuly. waiting acquire a   metadata lock .

How to repeat:
session A:
mysql> create table xcy_test_utf8( id  int ,

    -> name varchar(2),

    -> addr varchar(200));

mysql> begin;

Query OK, 0 rows affected (0.00 sec)

mysql> insert into xcy_test_utf8 values(1,'xcy','beijing');

ERROR 1406 (22001): Data too long for column 'name' at row 1

then , Session B try to modify the table xcy_test_utf8  struct, want to extend  
the name  column size. 

SESSION B:

alter table  xcy_test_utf8  modify name varchar(30);

AND THEN. the status  of session B  is   "Waiting for table metadata lock"

if  use  the command    "show engine innodb status  "  to  check  if exists  active session , but can't find it .

if  use  the command    "select * from information_schema.innodb_trx "  to  check  if exists  active session , no rows about  it .

   

Suggested fix:

if a sql  faild , should release  metadata lock about it .
[1 Jul 2019 13:07] MySQL Verification Team
Hi Mr. Xu,

Thank you for your bug report.

However, this is not a bug. This is exactly why MDL were invented and implemented in the SQL layer. Those were invented so that DDL operations would prevent InnoDB SE from changing data, while DDL is in progress.

The only thing that you can do is to make 100 % sure that lock_wait_timeout (which refers to MDL) is much larger then innodb_lock_wait_timeout (which is InnoDB SE specific), That is all that you can do.

This is all fully described in our Reference Manual.