Bug #19723 KILL of active connection yields error on Mac OS X
Submitted: 11 May 2006 11:50 Modified: 14 Dec 2007 17:16
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.22 OS:MacOS (Mac OsX)
Assigned to: Alexander Nozdrin CPU Architecture:Any

[11 May 2006 11:50] Magnus Blåudd
Description:
Killing the active connection to the server with the SQL command "kill" returns different erorr messages.

How to repeat:
select @con_id=connection_id();
kill @con_id;

Will return no error on most platforms but error 2013 on Mac OS X

Suggested fix:
Close the connection in such a way that we can detect it and don't have to report an error. For example by saying "bye bye" before "hanging up the phone".
[11 May 2006 12:08] Andrey Hristov
Magnus, that's known issue because on MacOS X the connection is closed prematurely and the server cannot send it's response back to the client library.
I reported in the past that this is a problem but I was overruled to fix the test which had the problem and not the exact problem.
[1 Nov 2007 15:36] Konstantin Osipov
Andrey, how do you think this could be fixed?
[15 Nov 2007 11:58] Konstantin Osipov
Approved by email.
[15 Nov 2007 12:34] 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/37845

ChangeSet@1.2613, 2007-11-15 15:35:35+03:00, anozdrin@station. +3 -0
  A patch for BUG#19723: kill of active connection yields
  different error code depending on platform.
  
  On Mac OS X, KILL statement issued to kill the current
  connection would return a different error code and message than on
  other platforms ('MySQL server has gone away' instead of 'Shutdown
  in progress').
  
  The reason for this difference was that on Mac OS X we have macro
  SIGNAL_WITH_VIO_CLOSE defined. This macro forces KILL
  implementation to close the communication socket of the thread
  that is being killed. SIGNAL_WITH_VIO_CLOSE macro is defined on
  platforms where just sending a signal is not a reliable mechanism
  to interrupt the thread from sleeping on a blocking system call.
  In a nutshell, closing the socket is a hack to work around an
  operating system bug and awake the blocked thread no matter what.
  
  However, if the thread that is being killed is the same
  thread that issued KILL statement, closing the socket leads to a
  prematurely lost connection. At the same time it is not necessary
  to close the socket in this case, since the thread in question
  is not inside a blocking system call.
  
  The fix, therefore, is to not close the socket if the thread that
  is being killed is the same that issued KILL statement, even with
  defined SIGNAL_WITH_VIO_CLOSE.
[15 Nov 2007 12:36] Alexander Nozdrin
Pushed into 5.1-rt.
[6 Dec 2007 10:00] Bugs System
Pushed into 5.1.23-rc
[6 Dec 2007 10:02] Bugs System
Pushed into 6.0.5-alpha
[14 Dec 2007 17:16] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.1.23 and 6.0.5 changelogs as:

        Issuing an SQL KILL of the active connection
        caused an error on Mac OS X.

Updated synopsis so that it didn't refer to "different errors on different platforms" since the bug report itself stated that the real issue was that an error resulted on one platform but not others.