MySQL死鎖查詢【原創】


死鎖詳情查詢

SELECT SUM(trx_rows_locked) AS rows_locked, SUM(trx_rows_modified) AS rows_modified, SUM(trx_lock_memory_bytes) AS lock_memory FROM information_schema.INNODB_TRX;

 

navicat實時查詢

show OPEN TABLES where In_use > 0;

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;

show processlist


將死鎖語句導出

mysql -uroot -p  -e "show engine innodb status \G;" > /tmp/lock-`date +%F_%T`.txt

cat /tmp/lock.txt|grep -i -n lock
cat /tmp/lock.txt|grep -i -n "LATEST DETECTED DEADLOCK"

在打印出來的信息中找到“LATEST DETECTED DEADLOCK”一節內容


注意:如果死鎖時間距離現在太遠,並且Buffer pool hit rate正常就可以忽略
cat /tmp/lock.txt|grep -i -n "hit"
330:Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM