-
Notifications
You must be signed in to change notification settings - Fork 340
Verify server ID before KILL QUERY to prevent cross-server cancellation #1575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: bgrainger <[email protected]>
Co-authored-by: bgrainger <[email protected]>
KILL QUERY
public const int CreatingConnectionAttributes = 2153; | ||
public const int ObtainingPasswordViaProvidePasswordCallback = 2154; | ||
public const int FailedToObtainPassword = 2155; | ||
public const int ConnectedTlsBasicPreliminary = 2156; | ||
public const int ConnectedTlsDetailedPreliminary = 2157; | ||
public const int CertificateErrorUnixSocket = 2158; | ||
public const int CertificateErrorNoPassword = 2159; | ||
public const int CertificateErrorValidThumbprint = 2160; | ||
public const int GettingServerIdentification = 2153; | ||
public const int RetrievedServerIdentification = 2154; | ||
public const int FailedToGetServerIdentification = 2155; | ||
public const int CreatingConnectionAttributes = 2156; | ||
public const int ObtainingPasswordViaProvidePasswordCallback = 2157; | ||
public const int FailedToObtainPassword = 2158; | ||
public const int ConnectedTlsBasicPreliminary = 2159; | ||
public const int ConnectedTlsDetailedPreliminary = 2160; | ||
public const int CertificateErrorUnixSocket = 2161; | ||
public const int CertificateErrorNoPassword = 2162; | ||
public const int CertificateErrorValidThumbprint = 2163; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change the IDs of existing events. Only add new IDs at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 780bc2b. Moved the new event IDs to the end of their respective sections (2161-2163, 2309-2310) and restored the original numbering for existing event IDs to maintain backward compatibility.
Co-authored-by: bgrainger <[email protected]>
In layer 4 load-balanced MySQL environments,
MySqlCommand.Cancel
could potentially cancel queries on the wrong server if connection IDs are reused across different MySQL servers. The original implementation only used IP address connection targeting, but this may not be sufficient in complex load-balanced scenarios.Solution
This PR adds server identity verification using MySQL's
@@server_uuid
and@@server_id
system variables to ensureKILL QUERY
commands target the correct server.Key Changes
Server Identification Storage
ServerUuid
andServerId
properties toServerSession
Connection Enhancement
GetServerIdentificationAsync()
to query server identification during connection establishmentSELECT @@server_uuid, @@server_id
(MySQL 5.6+) orSELECT @@server_id
(older versions)Cancellation Verification
DoCancel()
to verify server identity before executingKILL QUERY
Example Scenarios
Same server (allowed):
Different server (blocked):
Compatibility
Testing
The implementation ensures
KILL QUERY
commands are safe and reliable in load-balanced MySQL environments while maintaining full backward compatibility.Fixes #1574.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.