mysql - 如何忽略wait_timeout/interactive_timeout?

标签 mysql timeout wait

我的 mySQL 服务器不遵守 15 秒的 wait_timeout 或 Interactive_timeout。查询会持续进行并持续超过相应的 15 秒。下面是 my.cnf -

[mysqld]

# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
user=mysql
#skip-innodb

#ignore-builtin-innodb
#default-storage-engine = myisam
#log-queries-not-using-indexes

#key_buffer              = 6M
key_buffer_size         = 1024M
max_allowed_packet      = 64M
thread_stack            = 256K
thread_cache_size       = 200
max_connections         = 200
table_cache             = 128K
tmp_table_size          = 24M
max_heap_table_size     = 24M
join_buffer_size        = 1M
query_cache_limit       = 32M
query_cache_size        = 8M
read_buffer_size        = 1M
# concurrent_insert       = ALWAYS

general_log = 0
general_log_file = /var/log/mysql/general.log

low_priority_updates=1

log_warnings=2
#log_error=/var/log/mysql/mysql_error.log
slow-query-log                  = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
long_query_time=1

wait_timeout=15
interactive_timeout=15

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# InnoDB Settings
innodb_buffer_pool_size = 768M
innodb_log_file_size = 100M
innodb-file-per-table          = 1

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
#;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
#;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication
#;rpl_semi_sync_master_enabled=1
#;rpl_semi_sync_master_timeout=10
#;rpl_semi_sync_slave_enabled=1

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
#;performance_schema

#log-queries-not-using-indexes

default-storage-engine=MyISAM
#log-queries-not-using-indexes

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

我在服务器上运行了该命令,但是当我执行 mytop 时 - 有超过 15 秒的查询。

mysql> select @@global.wait_timeout, @@session.wait_timeout;
+-----------------------+------------------------+
| @@global.wait_timeout | @@session.wait_timeout |
+-----------------------+------------------------+
|                    15 |                     15 |
+-----------------------+------------------------+
1 row in set (0.00 sec)

知道我做错了什么吗?

最佳答案

wait_timeout 记录如下:

The number of seconds the server waits for activity on a noninteractive connection before closing it. This timeout applies only to TCP/IP and Unix socket file connections, not to connections made using named pipes, or shared memory.

从您的问题来看,您似乎正在尝试突然使用它和 interactive_timeout 来放弃长时间运行的查询。但这不是它的目的。

关于mysql - 如何忽略wait_timeout/interactive_timeout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16321847/

相关文章:

java - 套接字连接不会超时

java - 使用 ThreadPoolExecutor 进行线程同步

php - 如何检索每一行的 ID,然后将其分配给链接

mysql - DISTINCT alias.* 在 mysql select 子句中会做什么

mysql - 使用参数时出现 SQL 语法错误

c# - MySql 数据库中的 EF 重命名列

javascript - 使用 Chrome DevTools 模拟单个脚本超时(或缓慢加载)

PHP:当循环很长的函数没有响应时退出并显示警报

c++ - 在生产者-消费者代码中使用 wait() boost 条件死锁

java - 使用线程 1 打印数字 1,2,3,使用线程 2 打印数字 4,5,6,使用线程 3 打印数字 7,8,9,使用线程 1 打印数字 10,11,12