Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * manages processes
- */
- delimiter //
- /**
- * process_kill_runaway
- * kills queries that run longer than a specified time in seconds
- * limited to zenoradio-v25 database
- */
- drop procedure if exists process_killrun_aways;
- //
- create procedure process_kill_runaways
- (
- in runtime tinyint unsigned
- )
- comment 'kills queries that run longer than a specified time in seconds'
- language sql
- not deterministic
- begin
- declare done int default 0;
- declare conn_id int unsigned;
- declare continue_handler for sqlstate '02000' set done = 1;
- declare cur1 cursor for
- select id
- from information_schema.processlist
- where command = 'Query'
- and db = 'zenoradio-v25'
- and time >= runtime;
- open cur1;
- repeat
- fetch cur1 into conn_id;
- if not done then
- kill conn_id;
- end if;
- until done end repeat;
- close cur1;
- end;
- //
- delimiter ;
Advertisement
Add Comment
Please, Sign In to add comment