Show all current locks from get_lock

前端 未结 7 1473
渐次进展
渐次进展 2020-12-13 12:00

Is there any way to select / show all current locks that have been taken out using the GET_LOCK function?

Note that GET_LOCK locks are different from ta

7条回答
  •  不思量自难忘°
    2020-12-13 12:41

    Reference taken from this post:

    You can also use this script to find lock in MySQL.

    SELECT 
        pl.id
        ,pl.user
        ,pl.state
        ,it.trx_id 
        ,it.trx_mysql_thread_id 
        ,it.trx_query AS query
        ,it.trx_id AS blocking_trx_id
        ,it.trx_mysql_thread_id AS blocking_thread
        ,it.trx_query AS blocking_query
    FROM information_schema.processlist AS pl 
    INNER JOIN information_schema.innodb_trx AS it
        ON pl.id = it.trx_mysql_thread_id
    INNER JOIN information_schema.innodb_lock_waits AS ilw
        ON it.trx_id = ilw.requesting_trx_id 
            AND it.trx_id = ilw.blocking_trx_id
    

提交回复
热议问题