Opening files and the deleting them is a classical pattern for using temp files; it makes sure that they will be gone when the process exits. Finding a deleted but still opened file is no indication that it's not needed anymore.
My approach would have been to kill the mysql worker process that keeps them alive. That way the program that started the query gets an error message, instead of whatever undefined behaviour you get by empying the files and surprising mysqld.
My approach would have been to kill the mysql worker process that keeps them alive. That way the program that started the query gets an error message, instead of whatever undefined behaviour you get by empying the files and surprising mysqld.