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 ;

相关文章:

  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2023-01-12
  • 2021-06-30
猜你喜欢
  • 2021-07-22
  • 2021-08-03
  • 2022-12-23
  • 2021-08-19
相关资源
相似解决方案