Skip to main content

Handling and repairing of MySQL bugs

KlustronAbout 3 min

Handling and repairing of MySQL bugs

As the most widely used database MySQL in the Internet field, MySQL performs very well in terms of functions and performance, but in the process of daily use, we often encounter bugs hidden in various modules of MySQL.

If a bug is encountered during the production process and the MySQL instance crashes, it may affect the online business. Therefore, we need to fix the bug in time to avoid more serious consequences.

Generally speaking, the bugs we encounter are introduced by MySQL officials during the development process.

If you want to fix it, there are two situations: If there is an official fix, but you don’t want to upgrade to the corresponding official fix version, we need to find the corresponding fix and fix it by patching; for bugs that don’t have an official fix, you need to Report the bug to the authorities and try to fix it yourself.

This time we will take an official bug that has been fixed as an example to introduce the processing process for the first case in detail.

Recently, we discovered a MySQL crash problem during the development of new features of Klustron storage nodes.

The stack information of Crash is as follows: img

By analyzing the stack and core file information of Crash, we determined that this is a Crash during the import tablespace operation of a table with columns added. Therefore, based on this information, you can search for related bugs in the official bug repository.

Step 1: Search the official bug library based on the bug information to find the official fix

Enter the official bug repository MySQL Bugsopen in new window , select the Advanced search tab, enter the keyword "crash instant", and select "Closed" as the status (bug that has been fixed) img

Click "Search" to get a list of bugs as follows: img

After careful inspection, I found that the bug with ID 107517 was related to the problem we encountered, so I clicked in to view the detailed information as follows: img

The crash stack and other information on the bug page are the same as the crash we encountered, so we can be sure that this bug is the bug we encountered.

The last part of the bug page states that this bug has been fixed in version 8.0.31, so we need to go to versions after 8.0.31 to find the fix.

In addition, we can also find information about this bug in the official 8.0.31 release notes: img

There are two corresponding bug numbers, the 6-digit (bug#107517) is the external number, which is the number we can see in the bug system, and the 8-digit internal number (bug#34307874) corresponds to Pages are only visible to developers inside MySQL.

We note down this 8-digit build number bug#34307874, which will be used in the next step.

Step 2: Find the official fix patch:

To find the official repair patch, you must first obtain the commit log of all code submissions through git log on the cloned official code base, and then find the corresponding commit through the internal bug number bug#34307874 obtained in the previous step, and get the Commit id: 8afe86a32dbafed86be55921ac75d8c8dfc89e4c. img

Then, you can get the corresponding patch through git show8afe86a32dbafed86be55921ac75d8c8dfc89e4c > instant_import.bug. img

What needs to be reminded here is that a bug may have multiple commits, and the patches corresponding to all commits must be obtained.

Step 3: Apply a repair patch to your local code base

After obtaining all the official repair codes, we need to apply all the patches one by one in the local code base.

After all the patches are applied and MySQL is compiled, a simple verification is required.

Usually official repairs will have a corresponding MTR test case, for example, there is a new bug34307874.test test case in the above example. In the compiled mysql-test directory, execute: ./mtr -mem bug34307874 to run this test case. If it passes, it means that the bug has been fixed.

Next, MySQL can be packaged and released. img

The above mainly introduces a method of how to deal with official fixed bugs. This method is suitable for scenarios where you do not want to upgrade to the official fixed version. Generally speaking, it is not complicated, and I hope it can help everyone.

In the follow-up articles, we will also introduce how to fix the official bugs encountered by ourselves, and the process of submitting the fixes to the official, so stay tuned.

END