Bug #116952 Router w/ RW split causes ERROR: 4501 if sql script contains comments lines ("-- ")
Submitted: 11 Dec 2024 16:20 Modified: 24 Jan 22:00
Reporter: Keith Hollman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Router Severity:S3 (Non-critical)
Version:8.4.3 OS:Any
Assigned to: CPU Architecture:Any
Tags: 4501, 8.4.3, router, Statement not allowed if access_mode is 'auto'

[11 Dec 2024 16:20] Keith Hollman
Description:
Understanding that RW split has it's limitations, as per https://dev.mysql.com/doc/mysql-router/8.4/en/router-read-write-splitting-statements.html however, reviewing the documented exceptions, none mention that commented out lines also cause the same error.

Irrespective of the way you use a script, any "-- " comment lines will cause the statement not allowed error if we go via v8.4.3 router.

How to repeat:
vi /tmp/kk.sql
select "1";
-- Nothing
select "2"

mysqlsh --login-path=admin -hweb02 --show-warnings=true --sql -D keith -A -e "source /tmp/kh.sql"

1
1
Statement ID: 1300185
ERROR: 4501 (HY000) at line 2: Statement not allowed if access_mode is 'auto'

Suggested fix:
Tell router w/ RW splitting that commented out lines using "-- " are ok and harmless.
[13 Dec 2024 8:54] Jan Kneschke
Other queries not currently allowed:

- <empty statement>
- -- comment
- /* comment */
- ;

They all should be allowed and be forwarded to the current node as is.
[24 Jan 22:00] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Router 8.4.5 and 9.3.0 releases, and here's the proposed changelog entry from the documentation team:

Empty and commented out statements were not allowed with Read-Write
splitting enabled.

Thank you for the bug report.