http://gxg353.blog.sohu.com/232999339.html

因为最近遇到一些超时的问题,正好就把所有的timeout参数都理一遍,首先数据库里查一下看有哪些超时:

root@localhost : test 12:55:50> show global variables like "%timeout%";
+----------------------------+--------+
| Variable_name              | Value  |
+----------------------------+--------+
| connect_timeout            | 10     |
| delayed_insert_timeout     | 300    |
| innodb_lock_wait_timeout   | 120    |
| innodb_rollback_on_timeout | ON     |
| interactive_timeout        | 172800 |
| net_read_timeout           | 30     |
| net_write_timeout          | 60     |
| slave_net_timeout          | 3600   |
| table_lock_wait_timeout    | 50     | # 这个参数已经没用了
| wait_timeout               | 172800 |
+----------------------------+--------+

我们一个个来看

connect_timeout

手册描述:
The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake. The default value is 10 seconds as of MySQL 5.1.23 and 5 seconds before that.
Increasing the connect_timeout value might help if clients frequently encounter errors of the form Lost connection to MySQL server at ‘XXX’, system error: errno.
解释:在获取链接时,等待握手的超时时间,只在登录时有效,登录成功这个参数就不管事了。主要是为了防止网络不佳时应用重连导致连接数涨太快,一般默认即可。

delayed_insert_timeout

手册描述:
How many seconds an INSERT DELAYED handler thread should wait for INSERT statements before terminating.
解释:这是为MyISAM INSERT DELAY设计的超时参数,在INSERT DELAY中止前等待INSERT语句的时间。

innodb_lock_wait_timeout

手册描述:
The timeout in seconds an InnoDB transaction may wait for a row lock before giving up. The default value is 50 seconds. A transaction that tries to access a row that is locked by another InnoDB transaction will hang for at most this many seconds before issuing the following error:

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

When a lock wait timeout occurs, the current statement is not executed. The current transaction is not rolled back. (To have the entire transaction roll back, start the server with the –innodb_rollback_on_timeout option, available as of MySQL 5.1.15. See also Section 13.6.12, “InnoDB Error Handling”.)
innodb_lock_wait_timeout applies to InnoDB row locks only. A MySQL table lock does not happen inside InnoDB and this timeout does not apply to waits for table locks.
InnoDB does detect transaction deadlocks in its own lock table immediately and rolls back one transaction. The lock wait timeout value does not apply to such a wait.
For the built-in InnoDB, this variable can be set only at server startup. For InnoDB Plugin, it can be set at startup or changed at runtime, and has both global and session values.
解释:描述很长,简而言之,就是事务遇到锁等待时的Query超时时间。跟死锁不一样,InnoDB一旦检测到死锁立刻就会回滚代价小的那个事务,锁等待是没有死锁的情况下一个事务持有另一个事务需要的锁资源,被回滚的肯定是请求锁的那个Query。

innodb_rollback_on_timeout

手册描述:
In MySQL 5.1, InnoDB rolls back only the last statement on a transaction timeout by default. If –innodb_rollback_on_timeout is specified, a transaction timeout causes InnoDB to abort and roll back the entire transaction (the same behavior as in MySQL 4.1). This variable was added in MySQL 5.1.15.
解释:这个参数关闭或不存在的话遇到超时只回滚事务最后一个Query,打开的话事务遇到超时就回滚整个事务。

interactive_timeout/wait_timeout

手册描述:
The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the CLIENT_INTERACTIVE option to mysql_real_connect(). See also
解释:一个持续SLEEP状态的线程多久被关闭。线程每次被使用都会被唤醒为activity状态,执行完Query后成为interactive状态,重新开始计时。wait_timeout不同在于只作用于TCP/IP和Socket链接的线程,意义是一样的。

net_read_timeout / net_write_timeout

手册描述:
The number of seconds to wait for more data from a connection before aborting the read. Before MySQL 5.1.41, this timeout applies only to TCP/IP connections, not to connections made through Unix socket files, named pipes, or shared memory. When the server is reading from the client, net_read_timeout is the timeout value controlling when to abort. When the server is writing to the client, net_write_timeout is the timeout value controlling when to abort. See also slave_net_timeout.
On Linux, the NO_ALARM build flag affects timeout behavior as indicated in the description of the net_retry_count system variable.
解释:这个参数只对TCP/IP链接有效,分别是数据库等待接收客户端发送网络包和发送网络包给客户端的超时时间,这是在Activity状态下的线程才有效的参数

slave_net_timeout

手册描述:
The number of seconds to wait for more data from the master before the slave considers the connection broken, aborts the read, and tries to reconnect. The first retry occurs immediately after the timeout. The interval between retries is controlled by the MASTER_CONNECT_RETRY option for the CHANGE MASTER TO statement or –master-connect-retry option, and the number of reconnection attempts is limited by the –master-retry-count option. The default is 3600 seconds (one hour).
解释:这是Slave判断主机是否挂掉的超时设置,在设定时间内依然没有获取到Master的回应就人为Master挂掉了

MySQL的show global variables like “%timeout%“;相关推荐

  1. mysql stop很久_mysql的timeout

    mysql的timeout 很多时候我们连接mysql会在timeout这里跌倒,这里明确下mysql的timeout: 下面是获取timeout的变量: mysql> show global ...

  2. MySQL 系统变量(system variables)

    MySQL系统变量(system variables)实际上是一些系统参数,用于初始化或设定数据库对系统资源的占用,文件存放位置等等.这些个系统变量可以分为全局以及会话级别层面来修改,有些也可以进行动 ...

  3. Global variables vs. Host variables vs. Parameter markers

    Global variables are defined using the CREATE VARIABLE statement. Host variables are defined by stat ...

  4. Mysql 杀死进程 | 解决Lock wait timeout exceeded

    Mysql 杀死进程 | 解决Lock wait timeout exceeded 前言:2022年11月8日晚上11点左右一个小老弟问我Lock wait timeout exceeded怎么解决, ...

  5. MYSQL 5.7 Global Status的全面讲解

    MYSQL 5.7 Global Status的全面讲解 前言 介绍 使用方式 1. 版本问题 show_compatibility_56介绍 INFORMATION_SCHEMA Performan ...

  6. MYSQL错误: ERROR 1205: Lock wait timeout exceeded(处理MYSQL锁等待)解决办法

    在运行数据库某一语句的时候(数据量大概有一亿条),运行的特别慢,可能是我自己电脑配置不高,因此想删选一些数据但是运行的时候报1205错误. 原因 有会话执行过DML操作,然后没commit提交,再执行 ...

  7. mysql lock wait_Mysql错误: Lock wait timeout exceeded 解决办法

    一.临时解决办法: 执行mysql命令:show full processlist; 然后找出插入语句的系统id 执行mysql命令:kill id 或 首先,查看数据库的进程信息: show ful ...

  8. 关于MySQL出现锁等待lock wait timeout exceeded; try restarting transaction 的解决方案

    关于MySQL出现lock wait timeout exceeded; try restarting transaction 的解决方案. 一.问题抛出 在做查询语句时,MySQL 抛出了这样的异常 ...

  9. mysql deadlock6_mysql deadlock、Lock wait timeout解决和分析

    项目上线 线上遇到大量的deadlock 和wait timeout 但是看程序没什么问题 问dba也不能给出很好的解决方案!最终自己去了解mysql锁 以及看mysq锁日志 如果了解mysql锁的机 ...

  10. mysql 锁 启动失败_关于mysql锁的错误Lock wait timeout exceeded; try restarting transaction 【求解】...

    2020-03-13 18:44:18 | INFO | http-nio-8085-exec-10 | com.newretail.hospital.controller.HAdviceContro ...

最新文章

  1. 13、Java Swing事件监听:事件处理模型和事件监听器
  2. mysql 重置root密码 远程访问_重置mysql的root密码以及设置mysql远程登陆权限
  3. 敏捷开发日常跟进系列之四:跟进表
  4. 网友调侃特斯拉股价要冲向火星 马斯克:疯狂的时代
  5. 常用的限流框架,你都会用吗?
  6. [外包]!采用asp.net core 快速构建小型创业公司后台管理系统(四.quartz 简单配置使用)...
  7. python123电脑登录不了_python(14)- 简单练习:登录账户失败三次,账户自动锁定...
  8. LeetCode:累加数【306】
  9. vb 6.0 常用工具(鼠标移动,代码补全,代码对齐)
  10. 软件合集」8款小众实用软件免费分享(三),全部打包送给你,有款软件没多少人用过
  11. 微型计算机硬件系统包括什么,微型计算机硬件系统由什么组成(6个基本组成部件)...
  12. 重构改善既有代码的设计 --原则篇
  13. 吴晓波:拼多多的新与旧
  14. apache服务器设置
  15. windows快速生成ssh key
  16. 手机ppi排行测试软件,2018主流厂商旗舰手机屏幕测试数据汇总和子项排名统计...
  17. oracle exportdmp,Oracle导入导出dmp表
  18. C语言中 srand()函数和rand()函数
  19. SAP MM批次切换
  20. resnet_unetpp

热门文章

  1. python产生随机数的函数_Python 随机数函数
  2. 吴恩达机器学习作业 线性回归
  3. TR外汇黑平台资金盘深度揭秘,谨防上当受骗,迟早会跑路
  4. 基于ssm校园餐厅订餐管理系统获取(java毕业设计)
  5. a form 出口享惠情况_进出口报关
  6. 如何使用fiddler工具抓包?
  7. ubuntu下tftp服务器搭建
  8. excel文件修复工具_七款免费的PDF处理工具
  9. java 进程 互斥锁_Linux 进程互斥锁 - Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere - C++博客...
  10. 如何使用Java进行网络爬虫