📜 ⬆️ ⬇️

Bulk stop requests

As a small addition to the article Cleaning the database server .

Sometimes, in a queue, a large number of database queries accumulate, whose execution must be stopped without restarting MySQL.

To solve this problem, we use the following method:
')
We get a list of long-running queries, in this case, SELECTs that are executed for more than 100 seconds
SELECT CONCAT('KILL ', id, ';') FROM information_schema.processlist WHERE `info` LIKE('SELECT%') AND `time` > 100 INTO OUTFILE '/tmp/killList.sql'; 


Actually, we kill them:
 SOURCE /tmp/killList.sql; 


Optionally, you can select queries by host, username, database, etc.

Source: https://habr.com/ru/post/153343/


All Articles