MySQL 死鎖日誌分析

haoge0205發表於2015-11-18
  1. ------------------------  
  2. LATEST DETECTED DEADLOCK  
  3. ------------------------  
  4. 140824  1:01:24  
  5. *** (1) TRANSACTION:  
  6. TRANSACTION 110E, ACTIVE 73 sec starting index read   ## 事務ID=110E,活躍了73s  
  7. mysql tables in use 1, locked 1  
  8. LOCK WAIT 3 lock struct(s), heap size 376, 2 row lock(s)  ## 有2個行鎖  
  9. MySQL thread id 1, OS thread handle 0x7f55ea639700, query id 81 localhost root updating  ## 該事務的執行緒ID=1  
  10. delete from t1 where a=1   ## 這是當前事務執行的SQL  
  11. *** (1) WAITING FOR THIS LOCK TO BE GRANTED:  ## 上面SQL等待的鎖資訊  
  12. RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110E lock_mode X locks rec but not gap waiting  
  13. Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 32  ## 等待在主鍵上的page num=3上有加一個X鎖(not gap waiting),鎖80 bits  
  14.  0: len 4; hex 80000001; asc     ;;  
  15.  1: len 6; hex 00000000110c; asc       ;;  
  16.  2: len 7; hex 0d000002350084; asc     5  ;;  
  17.  3: len 4; hex 80000001; asc     ;;  
  18.   
  19. *** (2) TRANSACTION:  
  20. TRANSACTION 110C, ACTIVE 1716 sec starting index read, thread declared inside InnoDB 500  ## 事務ID=110C,活躍了1716s  
  21. mysql tables in use 1, locked 1  
  22. 3 lock struct(s), heap size 376, 2 row lock(s), undo log entries 1  ## 3個鎖,2個行鎖,1個undo log  
  23. MySQL thread id 2, OS thread handle 0x7f563c05e700, query id 82 localhost root updating  ## 該事務的執行緒ID=2  
  24. delete from t1 where a=3   ## 這是當前事務執行的SQL  
  25. *** (2) HOLDS THE LOCK(S):  ## 這個事務持有的鎖資訊  
  26. RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110C lock_mode X locks rec but not gap  
  27. Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 32  ## 在主鍵上的page num=3上已持有一個X鎖(not gap),鎖80 bits  
  28.  0: len 4; hex 80000001; asc     ;;  
  29.  1: len 6; hex 00000000110c; asc       ;;  
  30.  2: len 7; hex 0d000002350084; asc     5  ;;  
  31.  3: len 4; hex 80000001; asc     ;;  
  32.   
  33. *** (2) WAITING FOR THIS LOCK TO BE GRANTED:  ## 同時這個事務還等待的鎖資訊  
  34. RECORD LOCKS space id 12 page no 3 n bits 80 index `PRIMARY` of table `test`.`t1` trx id 110C lock_mode X locks rec but not gap waiting  
  35. Record lock, heap no 3 PHYSICAL RECORD: n_fields 4; compact format; info bits 0  ## 同樣等待在主鍵上的page num=3上有加一個X鎖(not gap waiting),鎖80 bits  
  36.  0: len 4; hex 80000003; asc     ;;  
  37.  1: len 6; hex 000000000f71; asc      q;;  
  38.  2: len 7; hex ed0000022f0090; asc     /  ;;  
  39.  3: len 4; hex 80000003; asc     ;;  
  40.   
  41. *** WE ROLL BACK TRANSACTION (1)   ## 這裡選擇回滾了事務110E。  
  42.   
  43. 也就是說,這個死鎖使用事務110E中的SQL沒有執行,回滾了:  
  44. delete from t1 where a=1  
  45. 而事務110C中的SQL是正常被執行的:  
  46. delete from t1 where a=3  


轉自:http://blog.csdn.net/hw_libo/article/details/38789115

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-1840398/,如需轉載,請註明出處,否則將追究法律責任。

相關文章