GreatSQL社区

搜索

[已解决] MySQL Deadlock 日志如何解读?

556 4 2023-6-5 13:51
5.7 版本的实例,今天线上出现了死锁问题,查看死锁日志,发现并不太好理解,其中有一段如下:
  1. 2023-06-03T03:00:04.306132+08:00 352040818 [Note] InnoDB: *** (2) WAITING FOR THIS LOCK TO BE GRANTED:

  2. RECORD LOCKS space id 797 page no 7 n bits 104 index PRIMARY of table `bxxx`.`xxxx` trx id 5298679407 lock_mode X locks rec but not gap waiting
  3. Record lock, heap no 2 PHYSICAL RECORD: n_fields 34; compact format; info bits 0
  4. 0: len 4; hex 80000001; asc     ;;  
  5. 1: len 6; hex 00013bd36e19; asc   ; n ;;
  6. 2: len 7; hex 4200001e850600; asc B      ;;
  7. 3: len 8; hex 8000000004081c5b; asc        [;;
  8. 4: len 8; hex 81b18838ca022b81; asc    8  + ;;
  9. 5: len 17; hex 5a594d5832333035303131303030303031; asc ZYMX2305011000001;;
  10. 6: len 1; hex 81; asc  ;;
  11. 7: len 27; hex e78eb0e4bba3e7ae80e7baa6e4b889e998b2e590b8e9a1b6e781af; asc                            ;;
  12. 8: len 4; hex 80000001; asc     ;;
  13. 9: len 4; hex 80000000; asc     ;;
  14. 10: len 4; hex 80000001; asc     ;;
  15. 11: len 8; hex 920c49c7988fa121; asc   I    !;;
  16. 12: len 9; hex 80000000000000c700; asc          ;;
  17. 13: len 9; hex 800000000000009c3c; asc         <;;
  18. 14: len 30; hex e9a29ce889b23ae799bde889b2efbc88e79bb4e5be84efbc893332636d7c; asc       :                  32cm|; (total 49 bytes);
  19. 15: SQL NULL;
  20. 16: len 9; hex 800000000000001400; asc          ;;
  21. 17: len 9; hex 800000000000000000; asc          ;;
  22. 18: len 4; hex 8001fc01; asc     ;;
  23. 19: len 12; hex e5bf85e8be89e5aeb6e5b185; asc             ;;
  24. 20: len 1; hex 81; asc  ;;
  25. 21: SQL NULL;
  26. 22: SQL NULL;
  27. 23: len 9; hex 800000000000009c3c; asc         <;;
  28. 24: len 1; hex 81; asc  ;;
  29. 25: len 9; hex 800000000000009c3c; asc         <;;
  30. 26: len 1; hex 82; asc  ;;
  31. 27: len 5; hex 99b0023000; asc    0 ;;
  32. 28: SQL NULL;
  33. 29: len 17; hex 5a594a5332333035303131303030303031; asc ZYJS2305011000001;;
  34. 30: len 6; hex 73797374656d; asc system;;
  35. 31: len 5; hex 99b0463003; asc   F0 ;;
  36. 32: len 6; hex 73797374656d; asc system;;
  37. 33: len 5; hex 99b0463003; asc   F0 ;;
复制代码
这些  “数字:len“ 开头的完全读不懂什么意思,另外从死锁日志中也只能看个大概,并不清楚是哪两个事物造成的锁循环。
不知道大家是如何排查和解决 MySQL 死锁问题的?



全部回复(4)
Maskfanatics 2023-6-5 15:14:19
x1 : len x2 表示的是 记录中第x1个字段的字段长度为x2;trx id 5298679407 表示在等待锁的事务id
yejr 2023-6-6 08:21:39
可以看下这篇文章
如何阅读死锁日志,https://mp.weixin.qq.com/s/9H4e2c2iqB1Iqz4npXGrjA
radius 2023-6-6 09:33:34
yejr 发表于 2023-6-6 08:21
可以看下这篇文章
如何阅读死锁日志,https://mp.weixin.qq.com/s/9H4e2c2iqB1Iqz4npXGrjA ...

这个文章对于我提的问题,没有涉及到。
张旭峰 2023-6-6 10:37:14
radius 发表于 2023-6-6 09:33
这个文章对于我提的问题,没有涉及到。

叶老师的意思是 你可以先 学习下 这篇文章是怎么样处理死锁分析的 len hex 99b0463003 这些不太重要 是一个16进制的表示 可以对照这篇文章 照猫画虎的去分析 数据库上的死锁
radius

4

主题

0

博客

11

贡献

新手上路

Rank: 1

积分
17

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-5-7 20:38 , Processed in 0.021930 second(s), 15 queries , Redis On.
快速回复 返回顶部 返回列表