MySQL Forums
Forum List  »  Performance

Re: Hanging on copying to tmp table
Posted by: Brian Dalby
Date: April 26, 2012 02:17AM

I am really confused by this, right now I am thinking of doing a "dirty" trick, inspired by this: http://forge.mysql.com/tools/tool.php?id=106

DELIMITER $$
CREATE PROCEDURE `kill_run_aways` ( IN runtime TINYINT UNSIGNED )
LANGUAGE SQL
NOT DETERMINISTIC
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE ConnectionId INT UNSIGNED;
DECLARE ConnectionCursor CURSOR FOR SELECT ID FROM information_schema.PROCESSLIST
WHERE USER LIKE 'SPECIFIC_USER'
AND (COMMAND IN ('Query','Copying to tmp table'))
AND TIME >= runtime;

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

OPEN ConnectionCursor;

REPEAT
FETCH ConnectionCursor INTO ConnectionId;
IF NOT done THEN
KILL ConnectionId;
END IF;
UNTIL done END REPEAT;
CLOSE ConnectionCursor;
END$$
DELIMITER ;

SET GLOBAL event_scheduler = ON;

CREATE EVENT IF NOT EXISTS `kill_run_aways`
ON SCHEDULE EVERY 2 SECOND
ON COMPLETION PRESERVE ENABLE
DO CALL kill_run_aways(60)
/* Change schedule and runtime for your needs */;

That is not a nice way to do it, but it might solve the problem right now.

Options: ReplyQuote


Subject
Views
Written By
Posted
6462
April 23, 2012 06:55AM
3134
April 24, 2012 10:16AM
2516
April 24, 2012 02:44PM
2059
April 25, 2012 01:08PM
2222
April 25, 2012 08:43PM
2115
April 26, 2012 12:35AM
Re: Hanging on copying to tmp table
2415
April 26, 2012 02:17AM
1668
April 27, 2012 07:02AM
1912
April 28, 2012 01:37PM
1966
April 28, 2012 02:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.