-
Notifications
You must be signed in to change notification settings - Fork 345
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
Conversation
Co-authored-by: bgrainger <188129+bgrainger@users.noreply.github.com>
Co-authored-by: bgrainger <188129+bgrainger@users.noreply.github.com>
KILL QUERY
(削除ここまで)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 <188129+bgrainger@users.noreply.github.com>
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.
Let's replace these both with ServerHostname
. It will be filled in with @@hostname
or null
if that variable isn't available.
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.
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.
Feels unnecessary to make this a separate method. Once we're just checking hostname, inline it.
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.
Inlined the verification logic and removed the separate VerifyServerIdentity method in commit a6b86d7.
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.
Simplify this method to just get the hostname
; call it GetServerHostnameAsync
.
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.
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.
delete
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.
Deleted SupportsServerUuid constant in commit a6b86d7.
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.
Fix using
order.
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 using statement order in commit a6b86d7.
Co-authored-by: bgrainger <188129+bgrainger@users.noreply.github.com>
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.
There's no TestUtilities.LogInfo method. Delete all logging from tests.
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.
Removed all TestUtilities.LogInfo calls from the integration tests in commit d4ba8b8.
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.
What is even the point of this test?
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.
Deleted the entire test class as it was unnecessary - commit ae54398
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.
This whole class is unnecessary; delete it.
We can trust that C# properties can be set and then read. Only write useful tests.
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.
Deleted the entire ServerIdentificationTests class as requested - commit ae54398
Co-authored-by: bgrainger <188129+bgrainger@users.noreply.github.com>
Co-authored-by: bgrainger <188129+bgrainger@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
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.