SELECT * FROM INFORMATION
SCHEMA.INNODB
LOCK_WAITS w
INNER JOIN INFORMATIONSCHEMA.INNODB
LOCKS l1 ON w.REQUESTING
TRX
ID = l1.LOCK
TRX
ID
INNER JOIN INFORMATIONSCHEMA.INNODB
LOCKS l2 ON w.BLOCKING
TRX
ID = l2.LOCK
TRX
ID;
SHOW ENGINE INNODB STATUS\G
Look for the `TRANSACTIONS` section.
SELECT trx
id, trx
state, trx
started, trx
requested
lock
id, trx
wait
started, trx
weight, trx
mysql
thread
id, trx_query
FROM informationschema.innodb
trx
ORDER BY trx_started;
KILL THREAD_ID;
Replace `THREADID` with the `trxmysqlthreadid` from the query in step 3.
SET GLOBAL slow
query
log = 'ON';
SET GLOBAL slowquery
log_file = '/path/to/your/log/file.log';
SET GLOBAL longquery
time = 2;
Adjust the `longquerytime` value as needed.
EXPLAIN SELECT * FROM your
table WHERE your
conditions;
Replace the `SELECT` statement with the query causing lock contention.
These are immediate actions you can take to identify and potentially resolve lock contention issues in your MySQL database.
(Perfect for DevOps & SREs)
(Perfect for DevOps & SREs)