The database driver version 5.1.21 is upgraded to 5.1.42, and the program stuck problem is triggered.

Crime scene

At that time, due to some technical solutions, the driver version of the database was changed from

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.21</version>
		</dependency>

upgraded to

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>

spring boot version 1.5.4.RELEASE, after checking the actual use is

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.42</version>
  </dependency>

After the test went live, the pre-release deployment test was fine, but when it came to production, I don't know why it got stuck.
After comparing the code changes, try to roll back the modified changes, and then re-push them.

Failure Analysis

The phenomenon at that time was that the program was stuck, causing the POD to restart continuously, ELK had no error log, and the physical machine saw the following warn level log.

Thu Jun 01 19:19:25 CST 2023 WARN: Establishing SSL connection 

without server's identity verification is not recommended. 

According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ 

requirements SSL connection must be established by default if explicit option isn't set. 

For compliance with existing applications 

not using SSL the verifyServerCertificate property is set to 'false'. 

You need either to explicitly disable SSL by setting useSSL=false, 

or set useSSL=true and provide truststore for server certificate verification.

There is one thing to note here, MySQL needs to indicate whether to perform SSL connection in higher versions.

The services provided by the SSL protocol mainly:
1) Authenticate user servers to ensure that data is sent to the correct server;
2) Encrypt data to prevent data from being stolen during transmission;
3) Maintain data integrity and verify whether data is lost during transmission;
Currently supports two layers of the SSL protocol:
SSL Record Protocol (SSL Record Protocol): established by the transmission protocol (TCP) high-level protocol to provide basic functions such as data encapsulation, compression, encryption, etc. Support
SSL Handshake Protocol (SSL Handshake Protocol): established SSL Record Protocol Before the actual data transmission, the communication parties conduct identity authentication, negotiate encryption
algorithms, exchange encryption keys, etc.

It is not recommended to establish an SSL connection without server authentication. As required by MySQL 5.5.45+, 5.6.26+, and 5.7.6+, a default SSL connection must be established if no explicit option is set. SSL needs to be explicitly disabled by setting useSSL=false, or set useSSL=true and provide a trust store for server certificate verification.

1.true requires connection
2.false does not require connection

Therefore, it is recommended to set useSSL to false, and sometimes the problems encountered can be considered in this way

autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull

example

jdbc:mysql://localhost:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull

So what pitfalls does the MySQL 5.1.42 database have?

  • MySQL 5.1.42 is a stable release that has been released for more than ten years as of September 2021.
  • Since it is a long-term supported release, many earlier bugs have been fixed, and MySQL 5.1.42 introduces no new bugs.
  • However, like other software, MySQL 5.1.42 may have known bugs.
  • The following are some known MySQL 5.1.42 bugs:
    • In some cases, MySQL 5.1.42 may reject the request because the wrong charset or collation was used when creating the table .

    • MySQL 5.1.42 may crash or deadlock under certain circumstances. These problems may be related to locks or concurrent operations .

    • There may be performance issues with the query optimizer in MySQL 5.1.42, especially when processing complex queries.

    • In MySQL 5.1.42, certain binary datatypes may lead to incorrect results.

    • Overall, MySQL 5.1.42 is a stable release and has been tested and verified for a long time.

    • If you need to use an earlier MySQL version, please consider using MySQL 5.1.43 or later.

What are the bugs in mysql-connect-java 5.1.42?

  • mysql-connect-java is a Java library for connecting to MySQL databases.
  • mysql-connect-java 5.1.42 is a long-term supported release that has been released for more than ten years as of September 2021.
  • Since it is a long-term supported release, many earlier bugs have been fixed, and mysql-connect-java 5.1.42 introduces no new bugs.
  • However, like other software, mysql-connect-java 5.1.42 may have known bugs.
  • Here are some known mysql-connect-java 5.1.42 bugs:
    • In some cases, mysql-connect-java 5.1.42 may reject a request because the wrong charset or collation was used when creating the table.
    • mysql-connect-java 5.1.42 may crash or deadlock under certain conditions. These problems may be related to locks or concurrent operations.
    • There may be performance issues with the query optimizer in mysql-connect-java 5.1.42, especially when processing complex queries.
    • In mysql-connect-java 5.1.42, some binary datatypes could lead to incorrect results.
  • Overall, mysql-connect-java 5.1.42 is a stable release and has been tested and verified for a long time
  • If you need to use an earlier MySQL version, please consider using mysql-connect-java 5.1.43 or later.

It seems that this is very likely to be the cause. For some reasons, the project tried to modify the character set and collation.

Coincidentally, I upgraded to this version again.

warning

In the future, after the code modification test plan is invalid, you must remember to change the code back, and don't take it for granted.
The collation rules of the database must not be easily modified, if modified, it may affect the case-sensitive matching of data.
To upgrade the database version, you must modify the connection parameters of the JDBC URL.

related articles

When connecting to the database, add useSSL=false after the url

Guess you like

Origin blog.csdn.net/hadues/article/details/130996363