From 5e4a0afe65890db858abb95463701a79c6fce5ae Mon Sep 17 00:00:00 2001 From: dipanjal Date: Mon, 7 Jul 2025 17:42:02 +0600 Subject: [PATCH 1/2] proxysql: fix query routing logic --- proxysql/proxysql.cnf | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/proxysql/proxysql.cnf b/proxysql/proxysql.cnf index 898c120..39f2a57 100644 --- a/proxysql/proxysql.cnf +++ b/proxysql/proxysql.cnf @@ -47,29 +47,24 @@ mysql_servers = mysql_query_rules = ( { - rule_id=100 + rule_id=1 active=1 - match_pattern="^SELECT .* FOR UPDATE" - destination_hostgroup=10 - apply=1 - }, - { - rule_id=200 - active=1 - match_pattern="^SELECT .*" + match_pattern="^SELECT.*" destination_hostgroup=20 apply=1 + comment="Route SELECT queries to replica servers" }, { - rule_id=300 + rule_id=2 active=1 - match_pattern=".*" + match_pattern="^(?!SELECT).*" destination_hostgroup=10 apply=1 - } + comment="Route DML queries to master server" + }, ) mysql_users = ( - { username = "root" , password = "password" , default_hostgroup = 10 , active = 1 } + { username = "root" , password = "password" , default_hostgroup = 20 , active = 1 } ) From 6cc5b875d5d0ceff437c44190df55f9a9a27b769 Mon Sep 17 00:00:00 2001 From: dipanjal Date: Mon, 7 Jul 2025 17:53:55 +0600 Subject: [PATCH 2/2] proxysql: revert default group --- proxysql/proxysql.cnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxysql/proxysql.cnf b/proxysql/proxysql.cnf index 39f2a57..8700969 100644 --- a/proxysql/proxysql.cnf +++ b/proxysql/proxysql.cnf @@ -66,5 +66,5 @@ mysql_query_rules = mysql_users = ( - { username = "root" , password = "password" , default_hostgroup = 20 , active = 1 } + { username = "root" , password = "password" , default_hostgroup = 10 , active = 1 } )