Open sunguck opened 3 months ago
And also wondering that there's any way to remove Writer instance from Reader hostgroup.
@sunguck Have you checked this variable "aurora_max_lag_ms_only_read_from_replicas" ?
Thanks @xykhappy .
Are you suggesting that I can send all read traffic to read replicas using max_lag_ms
annotation on query ?
There's too many queries have to add annotation and we may miss that too.
@sunguck That's not the case. Since you're already using the "mysql_aws_aurora_hostgroups", just try to tune "mysql-aurora_max_lag_ms_only_read_from_replicas" to a small value like 0.
Are you suggesting that I can send all read traffic to read replicas using max_lag_ms annotation on query ?
I reviewed your settings once more and feel another possible reason is that you have added the writer specifically to hostgroup 1 in mysql_servers. From my experience, the aurora hostgroup is just responsible for auto discovering or replacing the backend servers, but not for removing redundant ones. Therefore, you should consider defining only hostgroup 0 in mysql_servers and let the ProxySQL do the discovery.
Thanks @xykhappy
I reviewed your settings once more and feel another possible reason is that you have added the writer specifically to hostgroup 1 in mysql_servers. From my experience, the aurora hostgroup is just responsible for auto discovering or replacing the backend servers, but not for removing redundant ones. Therefore, you should consider defining only hostgroup 0 in mysql_servers and let the ProxySQL do the discovery.
The issue has gone after defining server only hostgroup=0 in mysql_servers.
One more thing is After configuring server on hostgroup=0, do we supposed to change configuration after failover of aurora mysql cluster ?. We are going to use proxysql on kubernetes, so proxysql does not have state, and we configure cluster information by only /etc/proxysql.cnf.
@sunguck It doesn't matter. The ProxySQL will detect the Aurora role changes and update the runtime_mysql_servers automatically. Anyway you can test this out on your local.
After configuring server on hostgroup=0, do we supposed to change configuration after failover of aurora mysql cluster ?. We are going to use proxysql on kubernetes, so proxysql does not have state, and we configure cluster information by only /etc/proxysql.cnf.
I have tested few cases as you suggested, and found no problems when I configure just single node in mysql_servers (CASE-1). And when I configure full list of aurora mysql servers in mysql_servers, all server need to be configured as correct reader and writer hostgroup (CASE-2 vs CASE-3).
CASE-1
mysql_servers=
(
{ hostgroup=1, address="test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com" port=3306, use_ssl=0, weight=100, max_connections=7000 }
)
ProxySQL-Admin> select * from mysql_servers;
+--------------+---------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+---------------------------------------------------------------+------+
| 1 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+---------------------------------------------------------------+------+
ProxySQL-Admin> select * from runtime_mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 0 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
ProxySQL-Admin> LOAD MYSQL SERVERS TO RUNTIME;
ProxySQL-Admin> select * from runtime_mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 0 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
CASE-2
mysql_servers=
(
{ hostgroup=0, address="test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com" port=3306, use_ssl=0, weight=100, max_connections=7000 },
{ hostgroup=1, address="test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com" port=3306, use_ssl=0, weight=100, max_connections=7000 },
{ hostgroup=1, address="test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com" port=3306, use_ssl=0, weight=0, max_connections=0 }
)
ProxySQL-Admin> select * from mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 0 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
ProxySQL-Admin> select * from runtime_mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 0 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
ProxySQL-Admin> LOAD MYSQL SERVERS TO RUNTIME;
ProxySQL-Admin> select * from runtime_mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 0 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
CASE-3
mysql_servers=
(
{ hostgroup=1, address="test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com" port=3306, use_ssl=0, weight=100, max_connections=7000 },
{ hostgroup=1, address="test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com" port=3306, use_ssl=0, weight=100, max_connections=7000 },
{ hostgroup=1, address="test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com" port=3306, use_ssl=0, weight=0, max_connections=0 }
)
ProxySQL-Admin> select * from mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 1 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
ProxySQL-Admin> select * from runtime_mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 0 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
ProxySQL-Admin> LOAD MYSQL SERVERS TO RUNTIME;
ProxySQL-Admin> select * from runtime_mysql_servers;
+--------------+--------------------------------------------------------------------+------+
| hostgroup_id | hostname | port |
+--------------+--------------------------------------------------------------------+------+
| 0 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-1.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
| 1 | test-auroramy-batch0.a00000000000.ap-northeast-2.rds.amazonaws.com | 3306 |
+--------------+--------------------------------------------------------------------+------+
Using Aurora MySQL + ProxySQL 2.6.3
Writer instance is registered as Reader hostgroup even if mysql_aws_aurora_hostgroups.writer_is_also_reader=FALSE. I have also attached ProxySQL log file
Test procedure
1. Load mysql_hostgroup_attributes by SQL first.
2. Startup proxysql with following proxysql.cnf
Just after restart, looks autodiscovery of proxysql is working fine.
2. Run "LOAD MYSQL SERVERS TO RUNTIME" command again
But, after run "LOAD MYSQL SERVERS TO RUNTIME" command, aurora mysql writer instance is registered in reader hostgroup too.
Even if
writer_is_also_reader=FALSE
.Thank you!