SELECT b.trx_mysql_thread_id AS'blocked_thread_id' ,b.trx_query AS'blocked_sql_text' ,c.trx_mysql_thread_id AS'blocker_thread_id' ,c.trx_query AS'blocker_sql_text' ,( Unix_timestamp() - Unix_timestamp(c.trx_started) ) AS'blocked_time' FROM information_schema.innodb_lock_waits a INNERJOIN information_schema.innodb_trx b ON a.requesting_trx_id = b.trx_id INNERJOIN information_schema.innodb_trx c ON a.blocking_trx_id = c.trx_id WHERE ( Unix_timestamp() - Unix_timestamp(c.trx_started) ) >4;
1 2 3 4 5 6 7 8 9 10 11 12
SELECT a.sql_text, c.id, d.trx_started FROM performance_schema.events_statements_current a JOIN performance_schema.threads b ON a.thread_id = b.thread_id JOIN information_schema.processlist c ON b.processlist_id = c.id JOIN information_schema.innodb_trx d ON c.id = d.trx_mysql_thread_id WHERE c.id=884 ORDER BY d.trx_started\G;
1 2 3 4 5 6 7 8 9 10 11 12
SELECT b.trx_mysql_thread_id AS'blocked_thread_id'-> ,b.trx_query AS'blocked_sql_text'-> ,c.trx_mysql_thread_id AS'blocker_thread_id'-> ,c.trx_query AS'blocker_sql_text'-> ,( Unix_timestamp() - Unix_timestamp(c.trx_started) ) ->AS'blocked_time'-> FROM information_schema.innodb_lock_waits a -> INNERJOIN information_schema.innodb_trx b -> ON a.requesting_trx_id = b.trx_id -> INNERJOIN information_schema.innodb_trx c -> ON a.blocking_trx_id = c.trx_id -> WHERE ( Unix_timestamp() - Unix_timestamp(c.trx_started) ) >4; +-------------------+-------------------------------------------+-------------------+------------------+--------------+ blocked_thread_id blocked_sql_text blocker_thread_id blocker_sql_text blocked_time +-------------------+-------------------------------------------+-------------------+------------------+--------------+ 882 select * from lockr where i=10 for update 884 NULL 45 +-------------------+-------------------------------------------+-------------------+------------------+--------------+ 1 row in set, 1 warning (0.00 sec)