Skip to content

Let ProxySQL support Azure MySQL #2185

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

Merged
merged 8 commits into from
Aug 11, 2019
Merged

Conversation

Yiyao-MS
Copy link
Contributor

@Yiyao-MS Yiyao-MS commented Aug 9, 2019

The username of the monitor account in ProxySQL can only be one name, so is the proxysql account username of a set of master-slave servers. However, when connecting to Azure MySQL database, it requires the user name in the format of 'user@server' or 'server%user' which causes the monitor/proxysql account to be logged into only one Azure MySQL server. Therefore ProxySQL cannot be used in the read-write split on Azure MySQL databases.
Now Azure MySQL R&Ds are doing the work of removing the ‘@' + 'server' in the username information, which will be online soon. However, a new connection attribute '_server_host' which contains the hostname information is added. This attribute has been already added in driver MariaDB Connector C and MariaDB Connector J (reference: MariaDB/mariadb-connector-j@de8883b).
So some code is added to make sure ProxySQL can be applied to the read-write split on Azure MySQL Servers in the future.

@pondix
Copy link
Contributor

pondix commented Aug 9, 2019

Automated message: PR pending admin approval for build testing

@@ -335,6 +335,7 @@ class MySQL_Threads_Handler
MySQL_Listeners_Manager *MLM;
public:
struct {
bool azure_enabled;
Copy link

@EthanLeey EthanLeey Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check with Qianqian if the var "azure_enabled" follows the public name conversion as other open source tools.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connection attribute field is defined by MySQL protocol, I think the MySQL drivers can set the key-value pairs for this field as long as it does not exceed the length limitation

@renecannao renecannao changed the base branch from v2.0.5 to v2.0.6 August 10, 2019 05:05
@renecannao
Copy link
Contributor

ok to test

@renecannao
Copy link
Contributor

@YYJiangLoveU : thank you for the pull request.
I started the automated testing against this PR, and will verify it.
As I never used Azure, do you have some links that describe Azure behavior?
Thanks

@Yiyao-MS
Copy link
Contributor Author

@renecannao : here are some links: Create an Azure MySQL Database, Create Read Replicas in Azure MySQL and Azure Database for MySQL Documentation

Are these what you need? If not, please let me know.
Thanks.

@renecannao
Copy link
Contributor

@YYJiangLoveU : thank you for the links!
I think this is relevant to me, I didn't know Azure has this bizarre username setting.

I reviewed the changes, it seems pretty straightforward. Although, can you please revert the changes to ProxySQL_Cluster.cpp ? This module only connects to other ProxySQL instances, not to any backend.
Thanks

revert the changes
@Yiyao-MS
Copy link
Contributor Author

@renecannao : sorry for the late reply!
Thank you for telling me that ProxySQL_Cluster.cpp does not need to be changed. I didn't fully understand this before and I removed the code added.
Thanks

@renecannao
Copy link
Contributor

Thank you @YYJiangLoveU !

@renecannao renecannao merged commit 9e81359 into sysown:v2.0.6 Aug 11, 2019
@funkyfundev
Copy link

funkyfundev commented Sep 10, 2019

@renecannao I installed proxysql_2.0.6-ubuntu18_amd64.deb v2.0.6 today and I can't find this option in global variables: (ProxySQL version 2.0.6-73-gc746bf7f, codename Truls)

  • mysql-azure_enabled

@YYJiangLoveU can you also help how to enable it?

thank you guys. :)

@renecannao
Copy link
Contributor

hi @funkyfundev .
@YYJiangLoveU removed the flag, because there is indeed no reason for it.
Thanks

@Yiyao-MS
Copy link
Contributor Author

@funkyfundev : the mysql_azure_enabled has been removed (link) after discussion with my colleagues because the new connection attribute _server_host has no effect on the connection with non-azure databases. In other words, this attribute is transmitted by default when ProxySQL connecting database. You don't need extra configuration.
However, besides the change on ProxySQL, it also needs fix support on Azure (as I said above). The fix has just been deployed in the servers in some certain regions, and is not available in a production environment yet. So, you cannot use ProxySQL on Azure databases now. But I believe it will be online soon.
If you need more help, please let me know.
Thanks :)

@funkyfundev
Copy link

@funkyfundev : the mysql_azure_enabled has been removed (link) after discussion with my colleagues because the new connection attribute _server_host has no effect on the connection with non-azure databases. In other words, this attribute is transmitted by default when ProxySQL connecting database. You don't need extra configuration.
However, besides the change on ProxySQL, it also needs fix support on Azure (as I said above). The fix has just been deployed in the servers in some certain regions, and is not available in a production environment yet. So, you cannot use ProxySQL on Azure databases now. But I believe it will be online soon.
If you need more help, please let me know.
Thanks :)
thank you for the explanation.

@kf6kjg
Copy link

kf6kjg commented Oct 31, 2023

FYI to anyone that comes here: This doesn't work with Azure MySQL Single Server and won't work. Azure MySQL Flexible which doesn't use a gateway and thus doesn't need the user@hostname pattern, so this header isn't needed there.

Single server REQUIRES the user@hostname - which will cause ALL traffic that's supposed to go to the read replica to instead be redirected to whichever server is named in the user name, no matter what URL is used. If you attempt to set up ProxySQL without the @hostname portion you will get an error on connection, even if your client is sending the _server_host header that was added in this PR. You could work around this by adding two users to ProxySQL, one for the write server's hostgroup and one for the read replica hostgroup - but that currently means that your client software now has to decide which user name to connect to the ProxySQL frontend with, defeating the purpose of the query rules.

Additionally, Azure has no interest in altering Single Server to make this work - it's already marked as obsolete and to be migrated away from ASAP.

Confirmed the above information about Azure with Azure customer support and a technician that my support rep brought into a call with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants