Bug #52515 | mysql sessions are not terminated properly | ||
---|---|---|---|
Submitted: | 1 Apr 2010 2:51 | Modified: | 9 May 2011 19:26 |
Reporter: | Roel Van de Paar | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Command-line Clients | Severity: | S2 (Serious) |
Version: | 5.1.45, 5.1.40sp1 | OS: | Any |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
[1 Apr 2010 2:51]
Roel Van de Paar
[1 Apr 2010 2:55]
Roel Van de Paar
(And close the CMD/K session as well before checking process list)
[1 Apr 2010 3:06]
Roel Van de Paar
Same on Linux (Centos). Verifying as D2. Possibly the bug is "partly" in the SELECT SLEEP code ("partly" since the CLI should still be able to handle the closure correctly)?
[5 Apr 2010 23:30]
Jim Winstead
I doubt that this is a bug in the client or related to SLEEP() at all. The most likely culprit is the server not noticing dropped connections on Windows. You say you've repeated the problem on Linux -- is this with a client on Linux connecting to a Windows server?
[19 May 2010 18:57]
Jim Winstead
Needs feedback on how bug was reproduced on non-Windows systems.
[28 May 2010 4:51]
Roel Van de Paar
Andrew was originally testing on Linux and he was able to reproduce the same issue once, but cannot repeat it again. For the moment, look at this Windows-only maybe, keeping in mind the same.
[28 May 2010 4:52]
Roel Van de Paar
Btw, that "one occurrence" was pure-Linux, no Windows involved
[13 Jul 2010 12:08]
Georgi Kodinov
Confirmed with a linux box accessed through ssh : mysql> show full processlist; -------------- show full processlist -------------- +----+------+-----------+------+---------+------+------------+-----------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+------+---------+------+------------+-----------------------+ | 1 | root | localhost | test | Query | 78 | User sleep | select sleep(5000) | | 2 | root | localhost | test | Query | 38 | User sleep | SELECT SLEEP (10000) | | 4 | root | localhost | test | Query | 0 | NULL | show full processlist | +----+------+-----------+------+---------+------+------------+-----------------------+ Note that if I Ctrl-C the client's console it will correctly send a KILL command to the server : mysql> SELECT SLEEP (10000); -------------- SELECT SLEEP (10000) -------------- ^CCtrl-C -- sending "KILL QUERY 4" to server ... Ctrl-C -- query aborted. +---------------+ | SLEEP (10000) | +---------------+ +---------------+ 1 row in set (9.23 sec) mysql>
[19 Jul 2010 15:12]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/113880 3492 Georgi.Kodinov@oracle.com 2010-07-19 Bug #52515: mysql sessions are not terminated properly The mysql command line client was not reacting at all on closing its controlling terminal. Now it intercepts the SIGHUP on unix-alikes (and the corresponding windows way of notification) and issues a KILL command before closing similarly to how Ctrl-C is handled. Added a command line option to turn this new behaviour off if needed.
[19 Jul 2010 16:39]
Vladislav Vaintroub
Joro, you can have it more simple in case of windows. Instead of using signal(), you can always use SetConsoleCtrlHandler() and handle analoges of SIGINT and SIGHUP by checking dwCtrlType in your HandlerRoutine() callback ( http://msdn.microsoft.com/en-us/library/ms683242(VS.85).aspx ), e.g in with a switch/case logic. SIGINT corresponds to CTRL_C_EVENT, SIGHUP to CTRL_CLOSE_EVENT. You might want to expand the cases for CTRL_BREAK_EVENT, CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT. The handling of all those events might be similar,and be something like handle_sigint in the current implementation. I actually don't see a compelling reason to ignore command window close (CTRL_CLOSE_EVENT), you think it can help somehow?
[16 Dec 2010 12:54]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/127068 3435 Georgi Kodinov 2010-12-16 Bug #52515: mysql sessions are not terminated properly The mysql command line client was not reacting at all on closing its controlling terminal. Added windows specific code to handle the console events. Added a handler for the SIGHUP to gracefully shutdown the running statement.
[5 Jan 2011 11:24]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/127959 3435 Georgi Kodinov 2011-01-05 Bug #52515: mysql sessions are not terminated properly The mysql command line client was not reacting at all on closing its controlling terminal. Added windows specific code to handle the console events. Added a handler for the SIGHUP to gracefully shutdown the running statement. Made sure the windows specific code handles correctly Ctrl-C.
[9 May 2011 19:26]
Paul DuBois
Noted in 5.6.3 changelog. The mysql client sometimes did not properly close sessions terminated by the user with Control+C. CHANGESET - http://lists.mysql.com/commits/136800