Skip to content

Commit 3a2f8e2

Browse files
FarihaISgkodinov
authored andcommitted
MDEV-34713 Backup and restore mariadb_upgrade_info file
The mariadb_upgrade_info file was not being backed up during mariadb-backup --backup, causing MariaDB to incorrectly prompt for upgrade after restore. Add mariadb_upgrade_info to the list of files backed up from the datadir during backup operations, ensuring the upgrade state is preserved across backup and restore cycles. All new code of the whole pull request, including one or several files that are that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
1 parent 90f8178 commit 3a2f8e2

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

extra/mariabackup/backup_copy.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,9 @@ ibx_copy_incremental_over_full()
15191519
!(ret = backup_files_from_datadir(ds_data,
15201520
xtrabackup_incremental_dir,
15211521
"aria_log")) ||
1522+
!(ret = backup_files_from_datadir(ds_data,
1523+
xtrabackup_incremental_dir,
1524+
"mariadb_upgrade_info")) ||
15221525
!(ret = backup_mroonga_files_from_datadir(ds_data,
15231526
xtrabackup_incremental_dir)))
15241527
goto cleanup;

extra/mariabackup/xtrabackup.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5379,6 +5379,13 @@ class BackupStages {
53795379
return false;
53805380
}
53815381

5382+
if (!backup_files_from_datadir(backup_datasinks.m_data,
5383+
fil_path_to_mysql_datadir,
5384+
"mariadb_upgrade_info")) {
5385+
msg("Error on root data dir files backup");
5386+
return false;
5387+
}
5388+
53825389
if (has_rocksdb_plugin()) {
53835390
rocksdb_create_checkpoint();
53845391
}

mysql-test/suite/mariabackup/full_backup.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,19 @@ undo001
4141
undo002
4242
XA COMMIT 'zombie';
4343
DROP TABLE t;
44+
#
45+
# MDEV-34713: mariadb_upgrade_info should be backed up and restored
46+
#
47+
CREATE TABLE t2(i INT) ENGINE INNODB;
48+
INSERT INTO t2 VALUES(100);
49+
# xtrabackup backup
50+
# xtrabackup prepare
51+
# shutdown server
52+
# remove datadir
53+
# xtrabackup move back
54+
# restart: --innodb_undo_tablespaces=0
55+
FOUND 1 /^[0-9]+\.[0-9]+\.[0-9]+/ in mariadb_upgrade_info
56+
SELECT * FROM t2;
57+
i
58+
100
59+
DROP TABLE t2;

mysql-test/suite/mariabackup/full_backup.test

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,41 @@ list_files $targetdir undo*;
6868
XA COMMIT 'zombie';
6969
DROP TABLE t;
7070
rmdir $targetdir;
71+
72+
--echo #
73+
--echo # MDEV-34713: mariadb_upgrade_info should be backed up and restored
74+
--echo #
75+
76+
CREATE TABLE t2(i INT) ENGINE INNODB;
77+
INSERT INTO t2 VALUES(100);
78+
79+
let $_datadir=`SELECT @@datadir`;
80+
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup_upgrade_info;
81+
82+
--write_file $_datadir/mariadb_upgrade_info
83+
10.11.0-MariaDB
84+
EOF
85+
86+
--echo # xtrabackup backup
87+
--disable_result_log
88+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
89+
--enable_result_log
90+
91+
--file_exists $targetdir/mariadb_upgrade_info
92+
93+
--echo # xtrabackup prepare
94+
--disable_result_log
95+
exec $XTRABACKUP --prepare --target-dir=$targetdir;
96+
--source include/restart_and_restore.inc
97+
--enable_result_log
98+
99+
--file_exists $_datadir/mariadb_upgrade_info
100+
101+
--let SEARCH_FILE=$_datadir/mariadb_upgrade_info
102+
--let SEARCH_PATTERN=^[0-9]+\.[0-9]+\.[0-9]+
103+
--source include/search_pattern_in_file.inc
104+
105+
SELECT * FROM t2;
106+
DROP TABLE t2;
107+
--remove_file $_datadir/mariadb_upgrade_info
108+
rmdir $targetdir;

0 commit comments

Comments
 (0)