InnoDB存储引擎下查看阻塞语句和等待语句

SELECT r.trx_id waiting_trx_id, r.trx_mysql_thread_id waiting_thread, r.trx_query waiting_query, b.trx_id blocking_trx_id, b.trx_mysql_thread_id blocking_thread, b.trx_query blocking_query FROM information_schema.innodb_lock_waits w INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id INNER JOIN information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id; 结果如下所示: +―――――-+―――――-+―――――――――�C+―――――�C+―――――�C+―――――――――�C+ | waiting_trx_id | waiting_thread | waiting_query | blocking_trx_id | blocking_thread | blocking_query | +―――――-+―――――-+―――――――――�C+―――――�C+―――――�C+―――――――――�C+ | 827 | 12 | select c from T2 for update | 826 | 11 | select b from T2 for update | | 827 | 12 | select c from T2 for update | 815 | 10 | select sleep(999) | | 826 | 11 | select b from T2 for update | 815 | 10 | select sleep(999) | +―――――-+―――――-+―――――――――�C+―――――�C+―――――�C+―――――――――�C+ 等待事务id827 select c from T2 for update被select b from T2 for update和select sleep(999)阻塞; 等待事务id826 select b from T2 for update被select sleep(999)阻塞。

你可能感兴趣的:(职场,休闲)