[MXS-2890] 5.5.5 prefix is always added even with version_string=8.0.16 Created: 2020-02-13  Updated: 2023-11-16  Resolved: 2021-07-14

Status: Closed
Project: MariaDB MaxScale
Component/s: Core
Affects Version/s: 2.4.6
Fix Version/s: 2.5.14

Type: Bug Priority: Minor
Reporter: Judy Yu Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

mysql 8.0.16
maxscale 2.4.6
mysql-connector-java 8.0.16


Attachments: File jmeter-client.pcap     File maxscale-client.pcap     File mysql-direct.pcap    
Issue Links:
Relates
relates to MXS-4865 5.5.5- prefix should not be added if ... Closed

 Description   

The mysql-connector-java doesn't know to remove the 5.5.5- prefix sent by MariaDB and it thinks it's using an older MySQL version. To support connectors which do not understand the 5.5.5- prefix, an option to not automatically generate it would be needed.


Original title: cannot connect db through maxscale using mysql-connector-java

I could connect DB using mysql-connector-java, and could connect DB through maxscale using mysql cli.
But when using mysql-connector-java connect DB through maxscale it says "java.sql.SQLException: Unknown system variable 'query_cache_size'". This variables is abandoned by mysql 8.0.*. And all the answer about this question is said set the right version to mysql-connector-java could solve this problem. But to me it not works, I think it may could resoved by maxscale.

I catch the packet between client mysql-connector-java and maxscale shows as attachment. 10.197.0.34 is client and 10.197.49.34 is maxscale. The packet no 8 shows it use 8.0.16 mysql-connector-java but also ask query_cache_size info.



 Comments   
Comment by markus makela [ 2020-02-13 ]

Does the connector use that based on the version of the server it uses? If so, you could try to manually set version_string in the MaxScale service.

Comment by Judy Yu [ 2020-02-14 ]

I set version_string=8.0.16 which is mysql version. Then try again and the exception throws either. And the log says as below. Do you have any suggestions?

2020-02-14 11:54:11.996 info : (6) [readwritesplit] (log_server_connections): Servers and router connection counts:
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (log_server_connections): current operations : 0 in [10.197.0.230]:3306 Master, Running
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (log_server_connections): current operations : 0 in [10.197.0.110]:3307 Slave, Running
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (log_server_connections): current operations : 0 in [10.197.0.33]:3307 Slave, Running
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (prepare_connection): Connected to 'server1'
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (open_connections): Selected Master: server1
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (prepare_connection): Connected to 'server2'
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (open_connections): Selected Slave: server2
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (prepare_connection): Connected to 'server3'
2020-02-14 11:54:11.996 info : (6) [readwritesplit] (open_connections): Selected Slave: server3
2020-02-14 11:54:11.996 info : (6) (session_start): Started Splitter-Service client session [6] for 'root' from ::ffff:10.197.0.34
2020-02-14 11:54:11.998 info : (6) (log_transaction_status): > Autocommit: [enabled], trx is [not open], cmd: (0x03) COM_QUERY, plen: 976, type: QUERY_TYPE_READ|QUERY_TYPE_SYSVAR_READ, stmt: /* mysql-connector-java-8.0.16 (Revision: 34cbc6bc61f72836e26327537a432d6db7c77de6) */SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@collation_server AS collation_server, @@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_write_timeout AS net_write_timeout, @@performance_schema AS performance_schema, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout
2020-02-14 11:54:11.998 info : (6) [readwritesplit] (handle_got_target): Route query to slave: server2 [10.197.0.110]:3307 <
2020-02-14 11:54:11.998 info : (6) (gw_decode_mysql_server_handshake): Connected to 'server1' with thread id 72490
2020-02-14 11:54:11.999 info : (6) (gw_decode_mysql_server_handshake): Connected to 'server3' with thread id 54729
2020-02-14 11:54:12.000 info : (6) (gw_decode_mysql_server_handshake): Connected to 'server2' with thread id 377672
2020-02-14 11:54:12.002 info : (6) [readwritesplit] (clientReply): Reply complete, last reply from server2
2020-02-14 11:54:12.003 info : (session_free): Stopped Splitter-Service client session [6]

Comment by Judy Yu [ 2020-02-17 ]

Hi markus, today I try to connect to mysql-8.0.16 through maxscale and direct connect, then catch the packet and compare. The packet added also.
In maxscale-client.pcap file, I find when connect through maxscale, maxscale tell client (mysql-connector-java 8.0.16) the version is 5.5.5-8.0.16 ( packet no 4 ). Then client ask backend server variables info will include 'query_cache_size', which will cause this session closed( packet no 8 ).
In mysql-direct.pcap file, when client(mysql-connector-java 8.0.16) connect mysql directly, the server tells client the version is 8.0.16 ( packet no 4). Then client will not ask some variables info which has been deprecated like 'query_cache_size'( packet no 8).

And I set version_string=8.0.16 in service partion.
[Splitter-Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=maxscale
password=xxx
enable_root_user=1
connection_timeout=300
version_string=8.0.16

Comment by markus makela [ 2020-07-03 ]

This is expected behavior of MaxScale: it'll add a 5.5.5- prefix if the version string doesn't start with one (this is expected by multiple connectors). This might be a problem in the connector if it doesn't know to remove the 5.5.5- prefix and use the actual version after it. Have you tried if the MariaDB JDBC connector behaves the same way?

The problem with behaving as if MaxScale was a 8.0 server means that it must also support caching_sha2_password which cannot be supported by MaxScale.

Comment by markus makela [ 2020-10-12 ]

yuyuyu1618 have you been able to test whether the MariaDB JDBC connector works for you?

Comment by Nguyen Tan Vy [ 2020-12-31 ]

I am facing the same issue.
My test case:
1/ Run MySQL 5.7.24 behind Maxscale 2.4 + Maxscale 2.5. My service use mysql-connector-java 8.0.16 for connect to Maxscale 2.4 & 2.5:

  • My service can work with Maxscale 2.4 + Maxscale 2.5.
  • MySQL version string: 5.7.24-27-log.

2/ Run MySQL 8.0.20 behind Maxscale 2.4 + Maxscale 2.5. My service use mysql-connector-java 8.0.16 for connect to Maxscale 2.4 & 2.5:

  • My service cannot work with Maxscale 2.4 + Maxscale 2.5
  • MySQL version string: 5.5.5-8.0.20-11.
  • The error message:

Caused by: com.mysql.cj.exceptions.CJException: Unknown system variable 'query_cache_size'

Comment by markus makela [ 2021-07-14 ]

Fixed by pull request 230.

Generated at Thu Feb 08 04:17:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.