Bug #44728 mysql_kill() and COM_PROCESS_KILL only handle 32-bit IDs
Submitted: 7 May 2009 20:14 Modified: 23 Aug 2012 16:27
Reporter: Jim Winstead Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: API

[7 May 2009 20:14] Jim Winstead
Description:
mysql_kill() and the underlying COM_PROCESS_KILL can only handle 32-bit IDs, but the server uses 64-bit IDs.

How to repeat:
Use the source.

Suggested fix:
Maybe just deprecate and remove mysql_kill() and COM_PROCESS_KILL -- it is almost as easy for clients to just generate a KILL statement.

Otherwise, add a replacement for mysql_kill(), and add a flag for killing just a query while we're at it.
[23 Aug 2012 16:27] Paul DuBois
Noted in 5.7.0 changelog.

Connection ID (thread ID) values greater than 32 bits can occur on
some systems (such as 64-bit systems), causing these problems:

* Connection IDs written to the general query log and slow query log
  were incorrect. This was true for logging to both files and tables.

* The CONNECTION_ID() function could return a value with a data type
  too small for values larger than 32 bits.

* The mysql_thread_id() and mysql_kill() C API functions did not handle
  ID values larger than 32 bits. This could result in killing the wrong
thread; for example, if you invoked mysql_kill(mysql_thread_id()).

Connection IDs now are permitted to be 64-bit values when possible,
which has these effects:

* Connection IDs are logged correctly to the general query log and slow
  query log.

  Note: This change involves a modification to the log tables, so after
  upgrading to this release, you must run mysql_upgrade and restart the
  server.

* CONNECTION_ID() returns a data type appropriate for values larger
  than 32 bits.

* mysql_thread_id() is unchanged; the client/server protocal has only 4
  bytes for the ID value. This function returns an incorrect
  (truncated) value for connection IDs larger than 32 bits and should
  be avoided.

* mysql_kill() still cannot handle values larger than 32 bits but to
  guard against killing the wrong thread now returns an error in these
  cases:

  * If given an ID larger than 32 bits, mysql_kill() returns a
    CR_INVALID_CONN_HANDLE error.

  * After the server's internal thread ID counter reaches a value larger
    than 32 bits, it returns an ER_DATA_OUT_OF_RANGE error for any
    mysql_kill() invocation and mysql_kill() fails.

* To avoid problems with mysql_thread_id() and mysql_kill(), you should
  not use them. To get the connection ID, execute a SELECT
  CONNECTION_ID() query and retrieve the result. To kill a thread,
  execute a KILL statement.
[4 Dec 2012 19:01] Paul DuBois
Backported to 5.6.9. Noted in 5.6.9 changelog.