-
Notifications
You must be signed in to change notification settings - Fork 1k
Avoid send close in ssl connections #5096
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: v3.0
Are you sure you want to change the base?
Conversation
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.
Summary of Changes
Hello @Gonlo2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request resolves an issue where ProxySQL's custom connection closing mechanism would send unencrypted QUIT messages to MySQL backends configured with SSL. This behavior caused MySQL to abruptly terminate connections, leading to an increase in aborted_clients metrics and obscuring actual network problems. The changes introduce a conditional check to prevent these unencrypted messages from being sent when SSL is in use, thereby improving the accuracy of monitoring metrics and preventing unnecessary connection resets.
Highlights
- Issue Resolution: Prevents sending unencrypted close messages to SSL-enabled MySQL backends, which previously caused abrupt connection terminations.
- Metric Accuracy: Addresses the problem of
aborted_clientsmetrics being inflated due to these erroneous connection closures, improving the clarity of monitoring data. - Conditional Logic: Modifies connection closing functions in
MySQL_Monitor.cppandmysql_connection.cppto conditionally send theQUITcommand only when SSL is not in use.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request correctly prevents sending an unencrypted COM_QUIT packet over an SSL connection by adding a check for !my->options.use_ssl in close_mysql functions. This avoids abrupt connection closures from the MySQL backend. My review suggests a small improvement to also check for connection compression. This would make the fix more complete, especially in lib/mysql_connection.cpp where a FIXME comment explicitly mentions that both encryption and compression are not supported by the custom close_mysql logic.
|
|
||
| static void close_mysql(MYSQL *my) { | ||
| if (my->net.pvio) { | ||
| if (my->net.pvio && !my->options.use_ssl) { |
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 change correctly avoids sending an unencrypted COM_QUIT packet over an SSL connection. To make this more robust, you could also check if compression is enabled, as sending an uncompressed packet on a compressed connection would also be incorrect. This would be consistent with a similar FIXME comment in lib/mysql_connection.cpp.
if (my->net.pvio && !my->options.use_ssl && !my->options.compress) {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.
According to the comment that it does not work with compression this change would be fine but, since I have not tested it, I did not want to introduce it. If you can check it and it solves this issue, I see no problem in extending the patch.
| // FIXME: currently doesn't support encryption and compression | ||
| void MySQL_Connection::close_mysql() { | ||
| if ((send_quit) && (mysql->net.pvio) && ret_mysql) { | ||
| if ((send_quit) && (mysql->net.pvio) && ret_mysql && !mysql->options.use_ssl) { |
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 change correctly avoids sending an unencrypted COM_QUIT packet over an SSL connection, which addresses part of the FIXME on line 2959. To further address the FIXME, you could also add a check to prevent sending an uncompressed packet when compression is enabled.
if ((send_quit) && (mysql->net.pvio) && ret_mysql && !mysql->options.use_ssl && !mysql->options.compress) {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.
According to the comment that it does not work with compression this change would be fine but, since I have not tested it, I did not want to introduce it. If you can check it and it solves this issue, I see no problem in extending the patch.
|
Can one of the admins verify this patch? |
|
|
@renecannao please review |



This PR avoid sending an unencrypted message to a server that uses SSL, as this will cause the backend to abruptly close the connection.
A clear description of the issue
It seems that since the standard MySQL function is blocking, this logic has been recoded in ProxySQL to use a non blocking aproach, at least partially because it doesn't allow SSL or compression. This causes the MySQL backend to receive an incorrect message (or rather, an invalid message since it is not encrypted) and MySQL abruptly cuts the connection. This is not a serious problem since the desired result is achieved in the end, but it makes it difficult to detect real network problems since the MySQL metrics constantly show that there are problems.
Not sending anything can be worse than sending something, but it works for us, and I don't know if it works for you too.
ProxySQL version
v3.0.2
The steps to reproduce the issue
Anything that attempts to close a backend connection if SSL is used can be seen in the MySQL errors defining
log_error_verbosity=3or with the global status metricaborted_clients.