MySQL timeout相关参数解析和测试(3)

测试2:

mysql> show session variables like '%timeout%'; +----------------------------+----------+ | Variable_name | Value | +----------------------------+----------+ | interactive_timeout | 20 | | wait_timeout | 20 | +----------------------------+----------+ 10 rows in set (0.00 sec) mysql> show global variables like '%timeout%'; +----------------------------+----------+ | Variable_name | Value | +----------------------------+----------+ | interactive_timeout | 10 | | wait_timeout | 10 | +----------------------------+----------+ 10 rows in set (0.00 sec) mysql> show full processlist; +----+-------------+-----------------+------+---------+--------+-----------------------------------------------------------------------------+-----------------------+-----------+---------------+-----------+ | Id | User | Host | db | Command | Time | State | Info | Rows_sent | Rows_examined | Rows_read | +----+-------------+-----------------+------+---------+--------+-----------------------------------------------------------------------------+-----------------------+-----------+---------------+-----------+ | 3 | root | localhost | NULL | Query | 0 | NULL | show full processlist | 0 | 0 | 11 | | 19 | root | localhost:50276 | NULL | Sleep | 19 | | NULL | 10 | 10 | 11 | +----+-------------+-----------------+------+---------+--------+-----------------------------------------------------------------------------+-----------------------+-----------+---------------+-----------+ 2 rows in set (0.00 sec) mysql> show full processlist; +----+-------------+-----------+------+---------+--------+-----------------------------------------------------------------------------+-----------------------+-----------+---------------+-----------+ | Id | User | Host | db | Command | Time | State | Info | Rows_sent | Rows_examined | Rows_read | +----+-------------+-----------+------+---------+--------+-----------------------------------------------------------------------------+-----------------------+-----------+---------------+-----------+ | 3 | root | localhost | NULL | Query | 0 | NULL | show full processlist | 0 | 0 | 11 | +----+-------------+-----------+------+---------+--------+-----------------------------------------------------------------------------+-----------------------+-----------+---------------+-----------+ 1 rows in set (0.00 sec) 总结

由以上的阶段测试可以获得以下结论。

超时时间只对非活动状态的connection进行计算。

超时时间只以session级别的wait_timeout 为超时依据,global级别只决定session初始化时的超时默认值。

交互式连接的wait_timeout 继承于global的interactive_timeout。非交互式连接的wait_timeout继承于global的wait_timeout

继承关系和超时对 TCP/IP 和 Socket 连接均有效果

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/80cbe3ac718b9bae6082c0216d78a77c.html