重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 655|回复: 0
打印 上一主题 下一主题

[参数配置] innodb_print_all_deadlocks参数

[复制链接]
跳转到指定楼层
楼主
发表于 2023-9-13 08:23:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jiawang 于 2023-9-13 08:23 编辑

当mysql 数据库发生死锁时, innodb status 里面会记录最后一次死锁的相关信息,但mysql 错误日志里面不会记录死锁相关信息,要想记录,启动 innodb_print_all_deadlocks  参数 。
当系统并发很高时,很多的线程等待同一个行锁,死锁检测可能会拖慢系统,这个时候关闭死锁检测可能更好innodb_deadlock_detect 5.7.15 版本才有)。让线程自动超时。


[root@sztech ~]# mysql -uroot -pWangjia
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql>
mysql> show VARIABLES LIKE '%innodb_print_all_deadlocks%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| innodb_print_all_deadlocks | OFF   |
+----------------------------+-------+
1 row in set (0.00 sec)

mysql> set global innodb_print_all_deadlocks = ON;
Query OK, 0 rows affected (0.00 sec)

mysql> show VARIABLES LIKE '%innodb_print_all_deadlocks%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| innodb_print_all_deadlocks | ON    |
+----------------------------+-------+
1 row in set (0.00 sec)

mysql>

如果输出结果中的Value列的值为ON,则表示日志已经被打印出来了。
  • 死锁日志的默认路径是MySQL的数据目录下的ib_logfile文件中,其中为0至9的整数。我们可以通过以下方式查看死锁日志:


注意:

  • 当前只是临时设置的,mysql 服务重启后,就off 了.......
  • 想要永久生效需要在/etc/my.cnf 文件中修改或增加配置,注意增加的位置[mysqld] 的下面,否则无效;
innodb_print_all_deadlocks = ON


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-5-2 14:39 , Processed in 0.073912 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表