-
Notifications
You must be signed in to change notification settings - Fork 979
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
mysql-connect_retries_on_failure not effective to failures like connection refused #4597
Comments
Hi @xykhappy . A premise of this issue: The issue you are facing is actually a feature.
It doesn't really make sense once you understand the difference between the two setups. If you are attempting directly to a backend, you get error 111 because there is no service. If the client connects to ProxySQL , the connection to the client's backend (ProxySQL) was successful. If a client connects to ProxySQL , it runs a query successfully, and the backend is restarted, would you expect ProxySQL to drop the client's connection? In a nutshell, you are trying to compare a direct connection to a backend to running a query through proxysql . Furthermore, please remember that ProxySQL is a reverse proxy and not a forward proxy. |
Hi @renecannao, Thanks for the quick response! Hope it makes more sense this time. |
Created the pull request for this. |
For the hostgroup with a single backend, if the backend server goes down, the ProxySQL will return the error "Max connect timeout reached while reaching hostgroup" after the "mysql-connect_timeout_server_max" duration elapses if the backend is marked as "SHUNNED". In contrast, if establishing a direct connection without ProxySQL, the client will get a "connection refused" error or error code 111 immediately, which makes more sense.
After debugging the latest binary, it appears that ProxySQL keeps attempting to get a good connection at intervals controlled by "mysql-connect_retries_delay" until "mysql-connect_timeout_server_max" is reached according to the method MySQL_Session::handler_again___status_CONNECTING_SERVER.
proxysql/lib/MySQL_Session.cpp
Line 3177 in 27e71d2
And the retry is not even controlled by "mysql-connect_retries_on_failure" (as it should be) because the process always falls into this condition in the scenario I mentioned above.
proxysql/lib/MySQL_Session.cpp
Line 3244 in 27e71d2
If debug further, we will find the method MyHGC::get_random_MySrvC returns NULL all the time during the retry for this single "SHUNNED" backend.
proxysql/lib/MyHGC.cpp
Line 55 in 27e71d2
According to this method, the ProxySQL should attempt to bring the "SHUNNED" backend online but it fails all the time because the "mysrvc->time_last_detected_error" is always in the future related to "mysql-monitor_ping_interval".
I'm not sure whether the logic is intentionally designed this way. However, the retry time should be controlled by 'mysql-connect_retries_on_failure' rather than its current implementation. Additionally, I believe it would be more effective to return the exact failure error to the client.
The text was updated successfully, but these errors were encountered: