[MXS-2268] readwritesplitter is not routing queries properly in Maxscale 2.3.2 Created: 2019-01-16 Updated: 2019-02-08 Resolved: 2019-02-08 |
|
| Status: | Closed |
| Project: | MariaDB MaxScale |
| Component/s: | readwritesplit |
| Affects Version/s: | 2.3.2 |
| Fix Version/s: | 2.2.20, 2.3.4 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Jeffrey Parker | Assignee: | markus makela |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
CentOS 7, Rackspace cloud using OnMetal servers. Percona MySQL 5.6 behind Maxscale and PHP application in front. |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
Upon installing and configuring MaxScale 2.3.2 we encountered errors when slave database (which has read_only=1 set). After investigating it looks like MaxScale is marking all queries as read queries. We have a previous installation running version 2.1.11 which we never saw this issue on. Not a single query was marked as write despite the write queries being simple inserts. Attached is a log that contains queries showing that they are flagged as read. |
| Comments |
| Comment by markus makela [ 2019-01-17 ] | |||||||||||||||||||||||||||||||||||||||
|
Looks like the leading comment somehow confuses the query classifier. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-01-17 ] | |||||||||||||||||||||||||||||||||||||||
|
Do you have some filters enabled? It might explain why the query classifier won't process the insert if the newlines are removed by a filter. Please attach your configuration with all sensitive information removed from it. | |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-01-17 ] | |||||||||||||||||||||||||||||||||||||||
|
No filters other than a tee filter on that service. I attached my config as requested. | |||||||||||||||||||||||||||||||||||||||
| Comment by Dave Juntgen [ 2019-01-18 ] | |||||||||||||||||||||||||||||||||||||||
|
Looks like we're on the same page here, I submitted | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-01-18 ] | |||||||||||||||||||||||||||||||||||||||
|
Unconfirming this for now as my initial success was actually caused by the fact that I didn't add a newline after my comment. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-01-18 ] | |||||||||||||||||||||||||||||||||||||||
|
If possible, please try and see if adding query_classifier_cache_size=0 in the [maxscale] section helps. | |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-01-18 ] | |||||||||||||||||||||||||||||||||||||||
|
I added that line to config as requested and it does not look like anything changed as far as classifying the queries is concerned, though it does look like the logs are showing the newlines now.
| |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-04 ] | |||||||||||||||||||||||||||||||||||||||
|
Can you provide a minimal viable example that reproduces this with the command line client? We've had no luck in reproducing this in our environments. Note that to enable comments in the command line client you must provide the -c flag and to pass multiple statements use the DELIMITER command to change it from the default semicolon delimiter to something else. | |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-02-04 ] | |||||||||||||||||||||||||||||||||||||||
|
OK I got it. Initial setup, run the following on the master or on maxscale:
Then use the attached sql file with the following command line
| |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-02-04 ] | |||||||||||||||||||||||||||||||||||||||
|
The latest test to provide minimal viable example was done on maxscale 2.3.3 and not counting environment setup took about 10 seconds to confirm based on already provided information. | |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-02-04 ] | |||||||||||||||||||||||||||||||||||||||
|
Also mysql configs are all default except log-bin was uncommented and server_id was added for replication. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-05 ] | |||||||||||||||||||||||||||||||||||||||
|
Tested with the exact SQL but was not able to reproduce on MariaDB 10.3:
I tested with both master_accept_reads commented out and with the default config but with the order of the servers reversed to make sure the slave server would be preferred over the master for reads when no load is present. A notable difference is that the client appears to automatically split the queries at comment boundaries regardless of how the query is fed via the command line or what delimiter is used. To reproduce the single-command execution with the leading comment, a literal newline character (C-j) had to be inserted:
Even then I was not able to reproduce the routing of queries to slaves. Next I'll try if the MySQL 5.6 client behaves in some odd manner that causes this. | |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-02-05 ] | |||||||||||||||||||||||||||||||||||||||
|
The client that was used is below
only the servers behind maxscale were mysql 5.6 | |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-02-05 ] | |||||||||||||||||||||||||||||||||||||||
|
After retrying on my end I see that you are probably not using CentOS 7, as the issue does not seem to show up when I used Ubuntu. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-05 ] | |||||||||||||||||||||||||||||||||||||||
|
To my surprise, it does appear to be platform specific problem. I managed to reproduce the issue on CentOS 7 with 2.3.3 but not on Fedora 28. Initial analysis suggests it's somewhere in the parser code. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-05 ] | |||||||||||||||||||||||||||||||||||||||
|
Upon further analysis there is no systematic problem in the parser as it is able to classify a query with a statement correctly. Some other form of interference is taking place that is not known at this point in time. More investigation is require. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-05 ] | |||||||||||||||||||||||||||||||||||||||
|
It appears the difference is in the debug and release builds. For a still unknown reason a debug build classifies the statement correctly as a write whereas a release build on CentOS 7 causes it to be classified as a read. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-06 ] | |||||||||||||||||||||||||||||||||||||||
|
I've been investigating the behavior of the release builds and, based on my observations, the problem seems to be caused by the -fpeephole2 flag which is enabled when the -O2 optimization level is used. I am not 100% confident that this is the culprit as the problem doesn't appear to always be reproducible. Regardless of my lack of definitive proof, I've built release mode packages with the aforementioned optimization disabled for the query classifier. You can find the packages here: http://max-tst-01.mariadb.com/ci-repository/MXS-2.3-markusjm-feb6/mariadb-maxscale/centos/7/x86_64/ | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-06 ] | |||||||||||||||||||||||||||||||||||||||
|
We found some code in the query classifier that resulted in hard to detect undefined behavior. Having found the bug we fixed it and built packages which can be found here: http://max-tst-01.mariadb.com/ci-repository/MXS-2268/mariadb-maxscale/ | |||||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Parker [ 2019-02-08 ] | |||||||||||||||||||||||||||||||||||||||
|
The new code definitely works correctly in my test environment. | |||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-02-08 ] | |||||||||||||||||||||||||||||||||||||||
|
That's good to hear. The fix will be in the next 2.3 and 2.2 releases. |