From 0c4b216c16e3d34a71bc67580369b3fcced7957b Mon Sep 17 00:00:00 2001 From: Fariha Shaikh Date: Fri, 30 Jan 2026 00:59:45 +0000 Subject: [PATCH] MDEV-34713 Create mariadb_upgrade_info during mariadb-backup --copy-back mariadb-backup --copy-back was not creating the mariadb_upgrade_info file in the restored datadir, causing unnecessary upgrade prompts after restore. The file is now created with the server version string to prevent mariadb-upgrade from incorrectly detecting that an upgrade is needed. All new code of the whole pull request, including one or several files 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. --- extra/mariabackup/backup_copy.cc | 24 +++++++++++++++++++ .../suite/mariabackup/full_backup.result | 4 ++++ mysql-test/suite/mariabackup/full_backup.test | 10 ++++++++ 3 files changed, 38 insertions(+) diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 36e4210b7f498..d86019dae5be8 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1926,6 +1926,30 @@ copy_back() rocksdb_copy_back(ds_tmp); + /* MDEV-34713 Create mariadb_upgrade_info file to avoid unnecessary upgrade + prompts after restore */ + if (ret) { + char upgrade_info_path[FN_REFLEN]; + FILE *upgrade_info_file; + + snprintf(upgrade_info_path, sizeof upgrade_info_path, + "%s/mariadb_upgrade_info", mysql_data_home); + + upgrade_info_file = fopen(upgrade_info_path, "w"); + if (upgrade_info_file) { + if (fprintf(upgrade_info_file, "%s", MYSQL_SERVER_VERSION) < 0 || + fflush(upgrade_info_file) != 0) { + msg("Warning: Failed to write mariadb_upgrade_info"); + } else { + msg("Created mariadb_upgrade_info with version %s", + MYSQL_SERVER_VERSION); + } + fclose(upgrade_info_file); + } else { + msg("Warning: Failed to create mariadb_upgrade_info"); + } + } + cleanup: if (it != NULL) { datadir_iter_free(it); diff --git a/mysql-test/suite/mariabackup/full_backup.result b/mysql-test/suite/mariabackup/full_backup.result index 936fdce0db2b2..b1a3dd79c51bb 100644 --- a/mysql-test/suite/mariabackup/full_backup.result +++ b/mysql-test/suite/mariabackup/full_backup.result @@ -16,6 +16,10 @@ INSERT INTO t VALUES(2); SELECT * FROM t; i 1 +# +# MDEV-34713 Check that mariadb_upgrade_info is created during copy-back +# +FOUND 1 /MariaDB/ in mariadb_upgrade_info DROP TABLE t; # # MDEV-27121 mariabackup incompatible with disabled dedicated diff --git a/mysql-test/suite/mariabackup/full_backup.test b/mysql-test/suite/mariabackup/full_backup.test index 09a73c146b3aa..deab07a66326e 100644 --- a/mysql-test/suite/mariabackup/full_backup.test +++ b/mysql-test/suite/mariabackup/full_backup.test @@ -31,6 +31,16 @@ exec $XTRABACKUP --prepare --target-dir=$targetdir; --enable_result_log SELECT * FROM t; + +--echo # +--echo # MDEV-34713 Check that mariadb_upgrade_info is created during copy-back +--echo # +let $_datadir= `SELECT @@datadir`; +--file_exists $_datadir/mariadb_upgrade_info +--let SEARCH_FILE=$_datadir/mariadb_upgrade_info +--let SEARCH_PATTERN=MariaDB +--source include/search_pattern_in_file.inc + DROP TABLE t; rmdir $targetdir;