INFORMATION_SCHEMA tables enable you to monitor
transactions and diagnose potential locking problems:
INNODB_TRX: Contains information about every transaction currently executing inside
InnoDB, including the transaction state (for example, whether it is running or waiting for a lock), when the transaction started, and the particular SQL statement the transaction is executing.
INNODB_LOCKS: Each transaction in InnoDB that is waiting for another transaction to release a lock (
LOCK WAIT) is blocked by exactly one blocking lock request. That blocking lock request is for a row or table lock held by another transaction in an incompatible mode. A lock that blocks a transaction is always held in a mode incompatible with the mode of requested lock (read vs. write, shared vs. exclusive). The blocked transaction cannot proceed until the other transaction commits or rolls back, thereby releasing the requested lock. For every blocked transaction,
INNODB_LOCKScontains one row that describes each lock the transaction has requested, and for which it is waiting.
INNODB_LOCKSalso contains one row for each lock that is blocking another transaction, whatever the state of the transaction that holds the lock (
INNODB_LOCK_WAITS: This table indicates which transactions are waiting for a given lock, or for which lock a given transaction is waiting. This table contains one or more rows for each blocked transaction, indicating the lock it has requested and any locks that are blocking that request. The
REQUESTED_LOCK_IDvalue refers to the lock requested by a transaction, and the
BLOCKING_LOCK_IDvalue refers to the lock (held by another transaction) that prevents the first transaction from proceeding. For any given blocked transaction, all rows in
INNODB_LOCK_WAITShave the same value for
REQUESTED_LOCK_IDand different values for
For more information about the preceding tables, see Section 21.28.8, “The INFORMATION_SCHEMA INNODB_TRX Table”, Section 21.28.6, “The INFORMATION_SCHEMA INNODB_LOCKS Table”, and Section 21.28.7, “The INFORMATION_SCHEMA INNODB_LOCK_WAITS Table”.