I have a Perl (DBI) program that does a number of very large queries on a mysql server. The typical result set size is in the 100s of MB. The queries take a long time. However, sometimes I have to kill the process before the query completes. Using 'show processlist' I see that there are leftover threads from queries executed from the now killed process. These queries seem to tie up the server until I kill them manually.
Is there a way to have perl DBI automatically kill the sql query thread when an interrupt is detected?
Is there a way to have perl DBI detect a leftover query thread and kill it (or block or warn) before sending a new query?