Rate This Document
Findability
Accuracy
Completeness
Readability

Usage Description

Fix vulnerabilities as soon as possible based on the Common Vulnerabilities and Exposures (CVE) of MySQL 8.0.20 on the official website.

Application Scenarios

During the execution of SQL statements in MySQL, the thread counter updates the number of threads in real time. In high-concurrency scenarios, frequent update will cause significant contention. In sysbench's point select test, the CPU usage of the server is approximately 100%. The perf top tool detects that mysqld's dispatch_command is a hotspot function. After a further analysis on the dispatch_command function, it is found that the CPU usage of two atomic threads accounts for a high proportion. That is, a contention occurs. This feature optimizes the thread counter to relieve contention on hotspot functions.

Compilation and Installation Method

The MySQL thread counter tuning feature is provided as a patch file. This patch is developed based on MySQL 8.0.20 and is open-sourced in the Gitee community. Before using this feature, apply the patch to the MySQL source code, and then compile and install MySQL.

  1. Download the MySQL 8.0.20 source package, upload it to the /home directory on the server and decompress it, and then go to the root directory of the MySQL source code.
    cd /home
    tar -zxvf mysql-boost-8.0.20.tar.gz
    cd mysql-8.0.20
  2. In the root directory of the source code, run the git init command to create Git management information.
    git init
    git add -A
    git commit -m "Initial commit"
    • Generally, Git is provided by the system. If not, configure the Yum source by following instructions in MySQL Porting Guide and then install Git.
      1
      yum install git
      
    • If the Git commit user information is not configured, configure the user email and user name before running the git commit command.
      1
      2
      git config user.email "123@example.com"
      git config user.name "123"
      
  3. Download the MySQL thread counter tuning patch and upload it to the root directory of the MySQL source code.
    1
    wget https://gitee.com/kunpengcompute/mysql-server/releases/download/KunpengBoostKit21.0.0-OLTP/0001-THREAD_COUNTER_OPT.patch --no-check-certificate
    
  4. Query the status of the local Git.
    1
    git status
    
    The following shows that a 0001-THREAD_COUNTER_OPT.patch file is added.
    1
    2
    3
    4
    5
    6
    7
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
            0001-THREAD_COUNTER_OPT.patch
    
    nothing added to commit but untracked files present (use "git add" to track)
    
  5. Check whether the patch file conflicts with the MySQL source code.
    1
    2
    dos2unix 0001-THREAD_COUNTER_OPT.patch
    git apply --check 0001-THREAD_COUNTER_OPT.patch
    

    If no error is reported, the patch can be applied.

  6. Apply the thread counter patch file.
    1
    git apply --whitespace=nowarn 0001-THREAD_COUNTER_OPT.patch
    

    Warning information can be ignored. If no error information is displayed, the patch is successfully installed.

  7. Compile and install the MySQL source code. For details, see MySQL Porting Guide.