Skip to content

Instantly share code, notes, and snippets.

@mitkot
Last active February 3, 2017 10:51
Show Gist options
  • Save mitkot/ae651dfe5e8cc12a5ea62ee89c14c401 to your computer and use it in GitHub Desktop.
Save mitkot/ae651dfe5e8cc12a5ea62ee89c14c401 to your computer and use it in GitHub Desktop.
Show blocking locks infromation for InnoDB
select tb.trx_mysql_thread_id blocking_id
, tb.trx_state blocking_state
, tb.trx_started blocking_starttime
, pb.HOST blocking_host
, pb.TIME blocking_seconds
, pb.INFO blocking_info
, tw.trx_mysql_thread_id requesting_id
, tw.trx_state requesting_state
, tw.trx_started requesting_starttime
, pw.HOST requesting_host
, pw.TIME requesting_seconds
, pw.INFO requesting_info
, l.lock_table lock_table
, l.lock_index lock_index
, l.lock_mode lock_mode
from information_schema.INNODB_LOCK_WAITS w
inner join information_schema.INNODB_LOCKS l
on w.blocking_lock_id = l.lock_id
inner join information_schema.INNODB_TRX tb
on w.blocking_trx_id = tb.trx_id
inner join information_schema.INNODB_TRX tw
on w.requesting_trx_id = tw.trx_id
inner join information_schema.PROCESSLIST pb
on tb.trx_mysql_thread_id = pb.ID
inner join information_schema.PROCESSLIST pw
on tw.trx_mysql_thread_id = pw.ID
order by requesting_id,
blocking_id
\G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment