Proxysql query rule starting with comment didn't work

372 views Asked by At

On proxyql 2.2.0

I've the following rule which isn't working (stats_mysql_query_rules counter always on 0). INSERT INTO mysql_query_rules (active, match_digest, destination_hostgroup, apply, multiplex) VALUES (1, '/\* Master \*/', 1, 1, 1);

This rule is in number position on my mysql_query_rules table.

The idea is to catch query like this one and push them to my Master node (AWS RDS Aurora writer endpoint).

/* Master */
select * from my_table;

Regex seems OK but the rule didn't (and query is counted on other rules).

2

There are 2 answers

0
alxsbn On BEST ANSWER

The documentation isn't explicit about it but it seems that query rules match_digest evaluation is stripping comments (e.g. /* Comments */) within SQL queries. So the pattern used above need to be insert inside the match_pattern field

0
Aurélien On

Just a big 'thank you' for you comment alxsbn. I didn't understand why my '^SELECT' query rules didn't match, as comments are not shown in stats_mysql_query_digest table....

In my case I changed my query rules to use 'match_digest' instead of 'match_pattern' and now everything seems to be OK.

*************************** 2. row ***************************
              rule_id: 200
               active: 1
               flagIN: 0
               digest: NULL
         match_digest: ^SELECT.*
        match_pattern: NULL

Not easy to debug, so thank you again you saved my week !