MySQL Lock wait analysis "2"

Source: Internet
Author: User
Tags session id

MySQL Lock wait analysis "1" in the lock waiting analysis is step by step, although the final analysis came out, but the time is relatively long; after clearing the relationships between the tables, get the following SQL statement for later use

Selectblock_trx.trx_mysql_thread_id asBLOCKING_SESSION_ID,--session ID with lock already held request_trx.trx_mysql_thread_id asrequest_session_id,--the session ID Block_trx.trx_query is requesting a lock asBlocking_sql_text,--The SQL statement that already holds the lock Request_trx.trx_query asRequesting_sql_text,--The SQL statement that is requesting the lock waits.blocking_trx_id asBLOCKING_TRX_ID,--transaction ID with lock already held waits.requesting_trx_id asREQUESTING_TRX_ID,--The transaction ID that is requesting the lock waits.requested_lock_id asREQUESTED_LOCK_ID,--ID of the lock object locks.lock_table asLock_table,--table locked by the lock object Locks.lock_type asLock_type,--Lock Type Locks.lock_mode asLock_mode--Lock Mode fromInformation_schema.innodb_lock_waits asWaitsinner Join Information_schema.innodb_trx asBlock_trx on waits.blocking_trx_id=Block_trx.trx_idinner Join Information_schema.innodb_trx asRequest_trx on waits.requesting_trx_id=Request_trx.trx_idinner Join Information_schema.innodb_locks aslocks on waits.requested_lock_id=locks.lock_id;+---------------------+--------------------+-------------------+-----------------------------------+----------- ------+-------------------+-------------------+--------------+-----------+-----------+| blocking_session_id | request_session_id | Blocking_sql_text | Requesting_sql_text | blocking_trx_id | requesting_trx_id | requested_lock_id | lock_table | Lock_type | Lock_mode |+---------------------+--------------------+-------------------+-----------------------------------+ -----------------+-------------------+-------------------+--------------+-----------+-----------+|1435|1255| NULL |Select* fromtempdb.t forUpdate |26293|26299|26299: -:3:2| ' tempdb '-' t ' | RECORD | X | |1435|1165| NULL | INSERT into t (x) VALUES (3)        |26293|26294|26294: -:3:1| ' tempdb '-' t ' | RECORD | X |+---------------------+--------------------+-------------------+-----------------------------------+--------- --------+-------------------+-------------------+--------------+-----------+-----------+

MySQL Lock wait analysis "2"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.