beowulf1416

Untitled

Feb 5th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /**
  2. * manages processes
  3. */
  4.  
  5. delimiter //
  6.  
  7.  
  8. /**
  9. * process_kill_runaway
  10. * kills queries that run longer than a specified time in seconds
  11. * limited to zenoradio-v25 database
  12. */
  13. drop procedure if exists process_killrun_aways;
  14. //
  15.  
  16. create procedure process_kill_runaways
  17. (
  18. in runtime tinyint unsigned
  19. )
  20. comment 'kills queries that run longer than a specified time in seconds'
  21. language sql
  22. not deterministic
  23. begin
  24. declare done int default 0;
  25. declare conn_id int unsigned;
  26. declare continue_handler for sqlstate '02000' set done = 1;
  27. declare cur1 cursor for
  28. select id
  29. from information_schema.processlist
  30. where command = 'Query'
  31. and db = 'zenoradio-v25'
  32. and time >= runtime;
  33.  
  34. open cur1;
  35. repeat
  36. fetch cur1 into conn_id;
  37. if not done then
  38. kill conn_id;
  39. end if;
  40. until done end repeat;
  41. close cur1;
  42. end;
  43. //
  44.  
  45. delimiter ;
Advertisement
Add Comment
Please, Sign In to add comment