After upgrading from MySQL 8.0.35 to MySQL 8.0.36 it’s no longer possible to restore the slave (replication) from a previous backup from XtraBackup
Slave error
Replica failed to initialize applier metadata structure from the repository
Before the upgrade the following script worked
echo "Unpacking backup file: $bak"
xbstream -x -C "$mysql_restore_dir" < "$bak"
xtrabackup --decompress --remove-original --target-dir="$mysql_restore_dir" > "$db_import_log" 2>&1
xtrabackup_error "$db_import_log"
line=$(head -n 1 "$mysql_restore_dir/xtrabackup_binlog_info")
logfile=$(echo $line | awk -F '[ ,]' '{print $1}')
logpos=$(echo $line | awk -F '[ ,]' '{print $2}')
gtid="$(echo $line | awk -F '[ ]' '{print $3}')"
echo "\nLog file: $logfile\nLog pos: $logpos\nGTID: $gtid"
echo "Preparing: $mysql_restore_dir"
xtrabackup --prepare --target-dir="$mysql_restore_dir" > "$db_import_log" 2>&1
xtrabackup_error "$db_import_log"
xtrabackup --move-back --target-dir="$mysql_restore_dir" > "$db_import_log" 2>&1
xtrabackup_error "$db_import_log"
rm -r $mysql_restore_dir/*
chown -R mysql:mysql $mysql_dir
service mysql start
mysql -u root -p$mysql_pass -e "RESET MASTER;\
SET GLOBAL gtid_purged='$gtid';\
CHANGE MASTER TO MASTER_HOST='$master_host', MASTER_USER='repl', MASTER_PASSWORD='$mysql_pass', MASTER_AUTO_POSITION=1, GET_MASTER_PUBLIC_KEY=1;\
START SLAVE"
The above script would print something like
Log file: mysql-bin.000002
Log pos: 197
GTID: 2d74e213-978b-11ee-895a-4c52620e063f:1-4322940,3ccc2392-45ed-11e7-bc98-4061862b8d34:1-35942477,4ea12ff1-ed48-11ee-b747-4c52620e063f:1-141,fe51e8df-b7c4-11e9-be21-4061862b8d34:1-57690654
And the last line in the import log xtrabackup.log
2024-03-28T23:06:28.231560+01:00 0 [Note] [MY-011825] [Xtrabackup] completed OK!
When checking the slave status
Slave_IO_State:
Master_Host: xx.xx.xx.xx
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: rep-dynaccount-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB: dynaccount
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 13124
Last_Error: Replica failed to initialize applier metadata structure from the repository
Skip_Counter: 0
Exec_Master_Log_Pos: 0
Relay_Log_Space: 157
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 13124
Last_SQL_Error: Replica failed to initialize applier metadata structure from the repository
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
Master_UUID:
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 240328 23:06:32
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: 2d74e213-978b-11ee-895a-4c52620e063f:1-4322940,
3ccc2392-45ed-11e7-bc98-4061862b8d34:1-35942477,
4ea12ff1-ed48-11ee-b747-4c52620e063f:1-141,
fe51e8df-b7c4-11e9-be21-4061862b8d34:1-57690654
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
Master_public_key_path:
Get_master_public_key: 1
Network_Namespace: