brodo
brodo

Reputation: 65

mysql auto kill query

Is it possible mysql to auto kill queries which took more than let`s say 20 seconds ?

Upvotes: 2

Views: 4675

Answers (3)

Erik Osterman
Erik Osterman

Reputation: 579

Install the RubyGem mysql_manager (sudo gem install mysql_manager) and then add a command like this to your crontab:

mysql-manager --kill --kill:user api --kill:max-query-time 30 --log:level DEBUG

For more options, run mysql-manager --help.

You might need to specify an alternative --db:dsn, --db:username, or --db:password.

Read more about it here: https://github.com/osterman/mysql_manager

Upvotes: 1

shantanuo
shantanuo

Reputation: 32346

I guess you are looking for maatkit utility called mk-kill that will kill queries that match certain criteria.

Upvotes: 2

Dan Grossman
Dan Grossman

Reputation: 52372

It's possible to write a program which does it. Your program would use SHOW PROCESSLIST to discover the currently running queries and how long they've been running, then issue a KILL query to terminate one.

Upvotes: 1

Related Questions