You can use show innodb status (or show engine innodb status for newer versions of mysql) to get a list of all the actions that are currently expected within the InnoDB engine. Buried in the output wall are transactions and what internal process identifier do they work with.
You cannot force a transaction or rollback these transactions, but you can kill the MySQL process that runs them, which essentially comes down to rollback. It kills the connection of processes and makes MySQL clear the mess of its left.
Here is what you would like to look for:
------------ TRANSACTIONS ------------ Trx id counter 0 140151 Purge done for trx n:o < 0 134992 undo n:o < 0 0 History list length 10 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 0 0, not started, process no 17004, OS thread id 140621902116624 MySQL thread id 10594, query id 10269885 localhost marc show innodb status
In this case, there is only one connection to the InnoDB engine right now (my login executing the show request). If this line was the actual connection / stuck transaction you would like to terminate, you should do kill 10594 .
Marc B Sep 29 2018-11-11T00: 00Z
source share