MySqlCommand.Cancel attempts to ensure that KILL QUERY runs on the correct server by connecting directly to its IP address:
|
// connect directly to the session's IP address to ensure we're cancelling the query on the right server (in a load-balanced scenario) |
|
IPAddress? ipAddress = null; |
|
if (session.IPEndPoint is { Address: { } sessionIpAddress, Port: { } port }) |
|
{ |
|
// set the hostname to the existing session's hostname (for SSL validation) |
|
csb.Server = session.HostName; |
|
csb.Port = (uint) port; |
|
ipAddress = sessionIpAddress; |
|
} |
In a layer 4 load balancing scenario, this might not be sufficient. Running SELECT @@server_uuid; or SELECT @@server_id; at connection establishment time (depending on which servers support those system variables) could provide a unique ID that the Cancel implementation could check before it cancels the query. This would avoid cancelling a query that just happens to use the same server thread ID on a different server.
MySqlCommand.Cancelattempts to ensure thatKILL QUERYruns on the correct server by connecting directly to its IP address:MySqlConnector/src/MySqlConnector/MySqlConnection.cs
Lines 913 to 921 in 4cbcfc7
In a layer 4 load balancing scenario, this might not be sufficient. Running
SELECT @@server_uuid;orSELECT @@server_id;at connection establishment time (depending on which servers support those system variables) could provide a unique ID that theCancelimplementation could check before it cancels the query. This would avoid cancelling a query that just happens to use the same server thread ID on a different server.