查看mysql当前事务锁并kill

执行如下SQL,查看当前事务:

select
  t.trx_mysql_thread_id,
  t.trx_started,
  t.trx_state,
  t.trx_tables_in_use,
  t.trx_tables_locked,
  t.trx_rows_locked,
  timestampdiff(second, t.trx_started, now()) as trx_run_seconds,
  concat(e.timer_wait/1000000000000, 's') as timer_wait_seconds
from information_schema.innodb_trx t
join performance_schema.threads c on c.processlist_id=t.trx_mysql_thread_id
join performance_schema.events_statements_current e on e.thread_id=c.thread_id

  返回是trx_mysql_thread_id就是线程ID,通过kill命令可以终止线程。

 

posted @ 2022-12-15 13:06  卡卡西村长  阅读(874)  评论(0编辑  收藏  举报