Hi Rene
In order to reproduce the issue, I have saved my current configuration to proxysql.cnf
( sudo mysql -u admin -padmin -h 127.0.0.1 -P6032 -e "SELECT CONFIG FILE" > /tmp/proxysql.cnf)
I
have removed all the mysql_rules to keep the config minimal just as you
did. By doing this, I have discovered that some errors I thought were
backtick-related actually weren´t, and I have isolated the error to only
one keyword in backticks.
I
prepared dbtest1.php and run some queries that are part of the original
app, calling the different steps. Before running any steps, I emptied
the proxysql logs each time.
Here are my results:
TEST1
dbtest1.php?s=1
Returns DB data as expected acording to SELECT * FROM extension
ProxySQL Error logs is empty (No errors)
TEST2
dbtest1.php?s=2
Returns DB data as expected acording to SELECT * FROM extension and SELECT * FROM extension WHERE type = 'total'
ProxySQL
Error logs is empty (No errors)
TEST3
dbtest1.php?s=3
Returns DB data as expected acording to
SELECT * FROM extension and SELECT * FROM extension WHERE type = 'total'
but now fails on SELECT * FROM extension WHERE `type` = 'total'
PHP ERROR:
Fatal error: Uncaught Exception: Error: MySQL server has gone
away<br />Error No: 2006<br />SELECT * FROM extension
WHERE `type` = 'total' in /home/dbtest.php:43
Stack trace:
#0 /home/dbtest.php(83): db->query('SELECT *
FROM e...')
#1 {main}
thrown in /home/dbtest.php on line 43
ProxySQL
Error logs now show
2026-06-14
15:54:48 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,706895) , FD (Conn:42 , MyDS:42) , mysqluser ,
last_used 1ms ago : 2027, Received malformed packet
2026-06-14 15:54:48 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
15:54:48 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,706896) , FD (Conn:42 , MyDS:42) ,
mysqluser , last_used 255360280ms ago : 2027, Received malformed packet
On
test3, I deliberately ran Test1 and Test2 as well to track the error
within the same connection. Here appear something that I don't
understand, the log says that the connection was broken during the query
containing
`type` on it, reporting last_used 1ms ago (I assume this is because Test2 was sent right before Test3). Then the query was retried, but now the connection is broken again, but the last_used reported is
255360280ms (This is about 70 hours ago). Does this mean that the retry
connections had been idle for 70 hours and is different from the current
connection? I'm kinda lost with that.
TEST4
dbtest1.php?s=4
Returns DB data as expected
acording to
SELECT * FROM extension and SELECT * FROM extension WHERE type = 'total'
and (this is a surprise) according to SELECT * FROM extension WHERE `code` = 'total', so here we noted that the problem is not the backtick by itself.
Error logs is empty (No errors)
TEST5
dbtest1.php?s=5
Returns DB data as expected
acording to
SELECT * FROM extension and SELECT * FROM extension WHERE type = 'total'
and according to SELECT * FROM store WHERE REPLACE(`ssl`, 'www.', '') = 'https://domain.cl/', (This query used to fail before due to my workaround mysq_rule that removed backticks completely)
Error logs is empty (No errors)
So, in summary,
the only expression causing the connection to drop so far in the test script is:
SELECT * FROM extension WHERE `type` = 'total'
For some reason, `type` wrapped in backticks triggers the connection closure.
Also, please keep in mind that if I use localhost instead of 127.0.0.1, everything works flawlessly—the entire app runs without issues—but, of course, I lose the ability to use the cache this way.
AFTER making this test, I tried to implement my workaround again with the following rule:
INSERT INTO mysql_query_rules (rule_id, active, match_pattern, replace_pattern, apply) VALUES (10, 1, '`type`', 'type', 1);
LOAD MYSQL QUERY RULES TO RUNTIME;
SAVE MYSQL QUERY RULES TO DISK;
When running the isolated test script (dbtest1.php),
tests 1 to 5 now succeed. Common sense suggested the application would
work fine now, but Murphy's Law kicked in: the main application still
fails, surprisingly when executing the expression from TEST 5.
Testing the full application now throws:
PHP ERROR
Fatal error: Uncaught Exception: Error: MySQL server has gone
away<br />Error No: 2006<br />SELECT * FROM store WHERE
REPLACE(`ssl`, 'www.', '') = '
https://domain.cl/'
PROXYSQL ERROR LOG
2026-06-14 16:45:31 [INFO] Received command SET sql_quote_show_create = 1, autocommit = 1
2026-06-14 16:45:31 [INFO] Received command SET sql_quote_show_create = 1, autocommit = 1
2026-06-14 16:45:31 [INFO] Received LOAD MYSQL QUERY RULES TO RUNTIME command
2026-06-14
16:45:31 [INFO] Computed checksum for 'LOAD MYSQL QUERY RULES TO
RUNTIME' was '0x50FB58CEC5EF0023', with epoch '1781469931'
2026-06-14 16:45:31 [INFO] Received SAVE MYSQL QUERY RULES TO DISK command
2026-06-14
17:41:39 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726038) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 1ms ago : 2027, Received malformed packet
2026-06-14 17:41:39 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:39 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726039) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261771737ms ago : 2027, Received malformed packet
2026-06-14
17:41:45 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726053) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 1ms ago : 2027, Received malformed packet
2026-06-14 17:41:45 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:45 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726054) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261777152ms ago : 2027, Received malformed packet
2026-06-14
17:41:46 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726062) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 1ms ago : 2027, Received malformed packet
2026-06-14 17:41:46 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:46 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726063) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261778848ms ago : 2027, Received malformed packet
2026-06-14
17:41:47 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726065) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 2ms ago : 2027, Received malformed packet
2026-06-14 17:41:47 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:47 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726066) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261779039ms ago : 2027, Received malformed packet
2026-06-14
17:41:49 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726082) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 1ms ago : 2027, Received malformed packet
2026-06-14 17:41:49 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:49 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726083) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261781698ms ago : 2027, Received malformed packet
2026-06-14
17:41:50 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726084) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 1ms ago : 2027, Received malformed packet
2026-06-14 17:41:50 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:50 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726085) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261781937ms ago : 2027, Received malformed packet
2026-06-14
17:41:51 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726091) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 1ms ago : 2027, Received malformed packet
2026-06-14 17:41:51 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:51 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726092) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261783764ms ago : 2027, Received malformed packet
2026-06-14
17:41:53 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726094) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 0ms ago : 2027, Received malformed packet
2026-06-14 17:41:53 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:53 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726095) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261784939ms ago : 2027, Received malformed packet
2026-06-14
17:41:54 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726099) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 2ms ago : 2027, Received malformed packet
2026-06-14 17:41:54 MySQL_Session.cpp:4851:handler_minus1_ClientLibraryError(): [WARNING] Retrying query.
2026-06-14
17:41:54 MySQL_Session.cpp:4837:handler_minus1_ClientLibraryError():
[ERROR] Detected a broken connection while running query on
(1,127.0.0.1,3306,726100) , FD (Conn:42 , MyDS:42) , user mysqluser ,
last_used 261786153ms ago : 2027, Received malformed packet
So the backtick ghost appear again.
The application without any rules, fails on Test3, just as the dbtest1.php script does.
I am not entirely sure if it is genuinely failing on `ssl`,
as the log shows multiple malformed packets. The error might just be
manifesting during that specific expression while the root cause lies
elsewhere. Interestingly, this exact expression does not fail when
executed inside dbtest1.php, even after applying the new mysql_rule.
Maybe the issue here is something related to
timeouts with just a surprising correlation with backticks, but not
backticks per-se.
I Hope that my proxysql.cnf give some clues about what I did wrong after following the install steps.