MySQL事件自动kill运行时间超时的SQL
Posted erisen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL事件自动kill运行时间超时的SQL相关的知识,希望对你有一定的参考价值。
delimiter $
create event my_long_running_trx_monitor
on schedule every 1 minute
starts ‘2015-09-15 11:00:00‘
on completion preserve enable do
begin
declare v_sql varchar(500);
declare no_more_long_running_trx integer default 0;
declare c_tid cursor for
select concat (‘kill ‘,trx_mysql_thread_id,‘;‘)
from information_schema.innodb_trx
where timestampdiff(minute,trx_started,now()) >= 1;
declare continue handler for not found
set no_more_long_running_trx=1;
open c_tid;
repeat
fetch c_tid into v_sql;
set @v_sql=v_sql;
prepare stmt from @v_sql;
execute stmt;
deallocate prepare stmt;
until no_more_long_running_trx end repeat;
close c_tid;
end;
$
delimiter ;
以上是关于MySQL事件自动kill运行时间超时的SQL的主要内容,如果未能解决你的问题,请参考以下文章