Bug #75161 | MySQL does not have a reliable way to close session for remote clients | ||
---|---|---|---|
Submitted: | 10 Dec 2014 11:21 | Modified: | 10 Dec 2014 15:37 |
Reporter: | Valeriy Kravchuk | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Connection Handling | Severity: | S4 (Feature request) |
Version: | 5.6, any | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | disconnect, TCP/IP, wait_timeout |
[10 Dec 2014 11:21]
Valeriy Kravchuk
[10 Dec 2014 15:37]
MySQL Verification Team
I find this a very welcome feature request. Changing a client - server protocol to a two-way street could make this feature request much easier to implement. Hence, these improvements should obtain attention that they deserve.
[11 Dec 2014 5:57]
Davi Arnaut
Actually, it does if this hasn't been broken since Bug#10374 was fixed.
[11 Dec 2014 6:01]
Davi Arnaut
> Alternatively, implement some server side timeout-based check of sessions that kills/closes them unconditionally after N seconds, no matter what their thread status is. Like, hum, the server-side statement timeout in MySQL 5.7?
[18 Dec 2014 16:56]
Fernando Ipar
The server side statement timeout does not seem to help, at least in my tests. I hit a similar problem as this one with queries reading from a fifo, when there's an error with the fifo. They seem to get stuck forever in 'Query' or, after a KILL <pid>, 'Killed' state, even after the statement timeout, wait_timeout and net read/write timeouts have passed. To repeat, you can just: mkfifo /tmp/fifo Then create a simple table on mysql. I used this one: CREATE TABLE `test` ( `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB Then set the timeouts to a low enough value to test. I set the statement timeout to 10000 and the interactive/wait/net timeouts to 30. Then run this from mysql: load data infile '/tmp/fifo' into table test.test; Then rm -f /tmp/fifo And then you have a stuck query. Here's how my variables look like: mysql> show processlist; +----+------+-----------+------+---------+------+-------------+---------------------------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+-------------+---------------------------------------------------+ | 2 | root | localhost | NULL | Killed | 264 | System lock | load data infile '/tmp/fifo' into table test.test | | 7 | root | localhost | NULL | Query | 0 | starting | show processlist | +----+------+-----------+------+---------+------+-------------+---------------------------------------------------+ 2 rows in set (0.00 sec) mysql> show variables like '%timeout%'; +-----------------------------+----------+ | Variable_name | Value | +-----------------------------+----------+ | connect_timeout | 10 | | delayed_insert_timeout | 300 | | have_statement_timeout | YES | | innodb_flush_log_at_timeout | 1 | | innodb_lock_wait_timeout | 50 | | innodb_rollback_on_timeout | OFF | | interactive_timeout | 30 | | lock_wait_timeout | 31536000 | | net_read_timeout | 30 | | net_write_timeout | 30 | | rpl_stop_slave_timeout | 31536000 | | slave_net_timeout | 3600 | | wait_timeout | 30 | +-----------------------------+----------+ 13 rows in set (0.00 sec) mysql> show variables like 'max_statement_time'; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | max_statement_time | 10000 | +--------------------+-------+ 1 row in set (0.00 sec) And it seems if the thread is not stuck, then the statement timeout does its job ok: mysql> select sleep(12); +-----------+ | sleep(12) | +-----------+ | 1 | +-----------+ 1 row in set (10.00 sec) This is on 5.7.4-m14 I first hit this on 5.5.33 and as a result of a failed fifo, I've had stuck queries for over 12 hours (in 'Killed' state) and it seems the only way out of it will be to restart mysqld. While the queries are stuck in this state, they held the MDL for the table and thus prevent any DDL from running.