Mysql – Set timeout for Alter table & Update scripts

No straightforward way.

You could write code to perform SHOW PROCESSLIST every minute, ignore system actions that run ‘forever’, locate only “alter/update” commands (but not scripts), check the “Time”, and issue “kill pid”.

If this is a team effort, I would (instead) implement a review process for every “alter/update script” to try to fix scripts before attempting them.

Keep in mind that killing a command after 10 minutes:

  • Wasted some resources for 10 minutes.
  • May have to spend more than 10 minutes in ROLLBACK (in the case of UPDATE), again wasting resources.
  • And the desired task is still left to be done.