Skip to content

Verify server ID before KILL QUERY #1574

Open
@bgrainger

Description

@bgrainger

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions