mysql principle - MDL elaborate lock

A brief introduction: MDL lock
binary
    1 MDL MDL read read lock locks are compatible SHARED_READ
    2 MDL write lock MDL write locks are exclusive EXCLUSIVE
three goals against
   a goal against MDL lock statement level, not the transaction itself, is mysql_server level lock
   2 when the purpose of executing the transaction itself is theoretically not tolerate the table structure is changed in the middle of
four MDL application
   0 select statement MDL_SHARED_READ
   1 DML statements MDL_SHARED_WRITE
   2 DDL statements
     1 inplace MDL_SHARED_UPGRADABLE, do not block DML operations
     2 copy MDL_EXCLUSIVE, DML operation will be blocked for select periods will rename the main card
  are more related to the lock 3 other global statement not to list the
five classic problem of metadata lock
   problem when we execute DDL or innobackup backup, there will be waiting for table meta lock problem, and will lead to wait for the follow-up session, and how do we deal with the
   analysis of the implementation of the operation need to apply for MDL lock, as evidenced by an operating dominated in MDL lock is not released, it is likely to be several
   1 for this table slow query (select), do not release the lock MDL
   2 of this table for uncommitted things may be caused by Program causes
   3 for other DDL table operations
   4 execution flush table with read lock, common innobackup 
   solve problems
   1 through show processlist see if there is slow query, DDL, FTWRL operation, if handled
   2 by innodb_trx see if there are uncommitted things, if there are treated
   3 for mysql5.7 version can be viewed by performance_schema.metadata_lock, keyword SHARED_READ
six supplementary
   1 MDL lock wait time is set by lock_wait_timeout
   optimized 2 mysql5.7 relevant characteristics of MDL lock
   3 things to read and write statements , are the first to apply MDL_EXCLUSIVE, downgrade to READ WRITE lock, so I did not mark above
  4 due to the design queue, so once MDL lock occurs, must be processed in a timely manner

Guess you like

Origin www.cnblogs.com/danhuangpai/p/11298417.html