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

标题: innodb_print_all_deadlocks参数 [打印本页]

作者: jiawang    时间: 2023-9-13 08:23
标题: innodb_print_all_deadlocks参数
本帖最后由 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,则表示日志已经被打印出来了。


注意:

innodb_print_all_deadlocks = ON







欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2