Open EagleEyeJohn opened 3 days ago
Accept an additional opening comment instead of /*+ for annotations so as to not clash with MySQL's parsing
ProxySQL only needs that the annotation is in the first comment, it doesn't require the same syntax used by the optimizer.
That is, just use a comment like /* annotation goes here */
Testing for us seems to suggest that /*+
is required in order to pick up annotations such as hostgroup=n
Nope, that is not right.
My guess is that you are testing with mysql client without -c
option, thus mysql client itself removes the comment
Thank you, I was.
This query is now correctly routed by the annotation. However, the MySQL optimizer hint is ignored by MySQL as query isn't killed at 3s.
Admin> SELECT /* hostgroup=41 */ /*+ MAX_EXECUTION_TIME(3000) */ @@hostname WHERE NOT SLEEP(10);
+------------+
| @@hostname |
+------------+
| database-f |
+------------+
1 row in set (10.00 sec)
If I flip the comment order, MySQL optimizer hint is obeyed
SELECT /*+ MAX_EXECUTION_TIME(3000) */ /* hostgroup=41 */ @@hostname WHERE NOT SLEEP(10);
ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded
If we reduce the sleep so that the optimizer hint doesn't kick in, we see hostgroup annotation being ignored
SELECT /*+ MAX_EXECUTION_TIME(3000) */ /* hostgroup=41 */ @@hostname WHERE NOT SLEEP(1);
+------------+
| @@hostname |
+------------+
| database-d |
+------------+
1 row in set (1.00 sec)
So I think I'm still at the same place where to get both MySQL optimizer hints and ProxySQL annotations functioning, we get the warning?
SELECT /*+ MAX_EXECUTION_TIME(3000); hostgroup=41 */ @@hostname WHERE NOT SLEEP(1);
+------------+
| @@hostname |
+------------+
| database-f |
+------------+
1 row in set, 1 warning (1.00 sec)
Warning (Code 1064): Optimizer hint syntax error near '; hostgroup=41 */ @@hostname WHERE NOT SLEEP(1)' at line 1
When using ProxySQL annotations these are passed through to MySQL causing it to raise a warning. As we capture warnings in ProxySQL, our logs are now littered with unwanted noise, which we would like to prevent.
The same happens when issuing a query that uses MySQL Optimizer hints and ProxySQL query annotations - both work when all MySQL optimizer hints appear first, followed by all ProxySQL query annotations. However, MySQL issues a warning when it sees the first ProxySQL annotation.
We have tried using separate comments for MySQL and for ProxySQL, but this results in loss of functionality, as only the first comment starting
/*+
is obeyed.Before sending a query to MySQL, would it be possible to have ProxySQL
/*+
for annotations so as to not clash with MySQL's parsing