1.異常背景
嘗試使用Xtrabackup來備份當前最新版的MySQL 8.0.20,一條命令下去直接報錯,還觸發了一個已知BUG,記錄一下錯誤背景
2.環境信息
## Xtrabackup 8.0.11
[root@10-186-61-109 ~]# xtrabackup --version
xtrabackup version 8.0.11 based on MySQL server 8.0.18 Linux (x86_64) (revision id: 486c270)
## MySQL Enterprise 8.0.20
root@localhost[(none)]> \s
--------------
mysql Ver 8.0.20-commercial for Linux on x86_64 (MySQL Enterprise Server - Commercial)
Connection id: 16
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.20-commercial MySQL Enterprise Server - Commercial
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /data/mysql/3306/data/mysqld.sock
Binary data as: Hexadecimal
Uptime: 1 hour 25 min 17 sec
Threads: 2 Questions: 86 Slow queries: 3 Opens: 156 Flush tables: 3 Open tables: 75 Queries per second avg: 0.016
3.備份報錯
[root@10-186-61-109 ~]# xtrabackup --socket=/data/mysql/3306/data/mysqld.sock --password --backup --target-dir=/data/mysql/3306/backup/
xtrabackup: recognized client arguments: --socket=/data/mysql/3306/data/mysqld.sock --password --backup=1 --target-dir=/data/mysql/3306/backup/
Enter password:
xtrabackup version 8.0.11 based on MySQL server 8.0.18 Linux (x86_64) (revision id: 486c270)
200525 14:38:23 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/data/mysql/3306/data/mysqld.sock' (using password: NO).
200525 14:38:23 version_check Connected to MySQL server
200525 14:38:23 version_check Executing a version check against the server...
200525 14:38:23 version_check Done.
200525 14:38:23 Connecting to MySQL server host: localhost, user: not set, password: set, port: not set, socket: /data/mysql/3306/data/mysqld.sock
Using server version 8.0.20-commercial
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql/3306/data/
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = /data/mysql/3306/redolog
xtrabackup: innodb_log_files_in_group = 3
xtrabackup: innodb_log_file_size = 2147483648
Number of pools: 1
200525 14:38:23 Connecting to MySQL server host: localhost, user: not set, password: set, port: not set, socket: /data/mysql/3306/data/mysqld.sock
## 錯誤關鍵點: Unknown redo log format (4)
Unknown redo log format (4). Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/ upgrading-downgrading.html.
xtrabackup: Error: recv_find_max_checkpoint() failed.
4. 排錯思路
-
Google搜索recv_find_max_checkpoint關鍵字說明直接搜到相關BUG鏈接
- https://jira.percona.com/browse/PXB-2162
- redo log format is changed and PXB need to be updated to support v4 redo log format
- https://jira.percona.com/browse/PXB-2162
-
MySQL官方對Redo log的版本變更原因
-
摘取的MySQL8.0.20的Release Note信息
InnoDB: Redo log records for modifications to undo tablespaces increased in size in MySQL 8.0 due to a change in undo tablespace ID values, which required additional bytes. The change in redo log record size caused a performance regression in workloads with heavy write I/O. To address this issue, the redo log format was modified to reduce redo log record size for modifications to undo tablespaces. (Bug #29536710)
5. 知識點歸納
- 當前最新版的Xtrabackup8.0.11還不支持備份MySQL8.0.20,后續會修復但支持的時間未知
- Xtrabackup已發布8.0.12版本,支持備份MySQL8.0.20(xtrabackup version 8.0.12 based on MySQL server 8.0.20 Linux (x86_64) (revision id: 01cce6d))
- https://www.percona.com/blog/2020/04/28/percona-xtrabackup-8-x-and-mysql-8-0-20/ - MySQL修改redo log格式版本的原因是在MySQL 8.0中,由於undo表空間ID值的變化,undo表空間修改的重做日志記錄的大小增加了,導致需要額外的字節存儲,redo log記錄大小的變化導致寫I/O較多的工作負載的性能下降(官方記錄是10%),為了解決這個問題,對redo log日志格式進行了修改(優化)
Bug#29536710: MYSQL 8.0 IS 10% SLOWER THAN 5.7 AT WRITE-IO BOUND CASE
(once descripted as WL#13419 : InnoDB: extend 32-bit value compaction also for high value of unsigned in transaction log)
Using undefined bit pattern of the current format,
high unsigned value also can be packed to
smaller bytes as higher its value is. (2 ~ 5 bytes)
1) increment LOG_HEADER_FORMAT to 4
The older parser detect as new format not to treat.
2) change the following 32-bit values packing
0xFF000000 ~ 0xFFFFFFFF : 0b11110000 + 4bytes
to
0xFF000000 ~ 0xFFFDFFFF : 0b11111110 + 3bytes
0xFFFE0000 ~ 0xFFFFFBFF : 0b1111110n + 2bytes
0xFFFFFC00 ~ 0xFFFFFFFF : 0b111110nn + 1byte
Approved by Pawel Olchawa <pawel.olchawa@oracle.com>
RB: 22349

