Skip to content

MDEV-34713 Backup and restore mariadb_upgrade_info file#4605

Merged
gkodinov merged 1 commit intoMariaDB:mainfrom
FarihaIS:mdev-34713
Apr 8, 2026
Merged

MDEV-34713 Backup and restore mariadb_upgrade_info file#4605
gkodinov merged 1 commit intoMariaDB:mainfrom
FarihaIS:mdev-34713

Conversation

@FarihaIS
Copy link
Copy Markdown
Contributor

@FarihaIS FarihaIS commented Jan 30, 2026

Description

The mariadb_upgrade_info file was not being backed up during mariadb-backup --backup operations, causing MariaDB to incorrectly prompt for an upgrade even when restoring from a backup of the same version.

Without this file being preserved in the backup, mariadb-upgrade cannot determine the database version after restore and assumes an upgrade is needed, forcing users to run unnecessary upgrade operations during disaster recovery.

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.

Release Notes

N/A

How can this PR be tested?

Execute the mariabackup.full_backup test in mysql-test-run. This commit adds a test in this file that verifies the creation of mariadb_upgrade_info during a successful copy-back.

Before the fix

mysqltest: At line 91: command "file_exists" failed with error: 1  my_errno: 175  errno: 2

The result from queries just before the failure was:
< snip >
XA END 'zombie';
XA PREPARE 'zombie';
# restart: --innodb_undo_tablespaces=0
# xtrabackup backup
# xtrabackup prepare
# shutdown server
# remove datadir
# xtrabackup move back
# restart: --innodb_undo_tablespaces=0
# Display undo log files from target directory
undo001
undo002
XA COMMIT 'zombie';
DROP TABLE t;
#
# MDEV-34713: mariadb_upgrade_info should be backed up and restored
#
CREATE TABLE t2(i INT) ENGINE INNODB;
INSERT INTO t2 VALUES(100);
# xtrabackup backup

After the fix

mariabackup.full_backup '8k'             w4 [ pass ]  12850
mariabackup.full_backup '4k'             w3 [ pass ]  12990
mariabackup.full_backup '16k'            w5 [ pass ]  13000
mariabackup.full_backup '32k'            w2 [ pass ]  15527
mariabackup.full_backup '64k'            w1 [ pass ]  18216
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 72.583 of 25 seconds executing testcases

Completed: All 5 tests were successful.

Basing the PR against the correct MariaDB version

  • This is a bug fix, and the PR is based against the main branch.

Copyright

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.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 30, 2026

CLA assistant check
All committers have signed the CLA.

@FarihaIS FarihaIS changed the title MDEV-34713 Create mysql_upgrade_info during mariadb-backup --copy-back MDEV-34713 Create mariadb_upgrade_info during mariadb-backup --copy-back Jan 30, 2026
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Feb 3, 2026
@gkodinov gkodinov self-assigned this Feb 17, 2026
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. This is a preliminary review.

Please also sort out the CLA bot! It must say "CLA signed".

Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread mysql-test/suite/mariabackup/full_backup.test Outdated
Comment thread extra/mariabackup/backup_copy.cc Outdated
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see some answers to your questions below.

Also please clear the CLA bot!

Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread extra/mariabackup/backup_copy.cc Outdated
Comment thread mysql-test/suite/mariabackup/full_backup.test Outdated
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work. I will ignore the CLA bot for now. Please let me know if you have any updates on that.

LGTM. Please stand by for the final review.

@gkodinov gkodinov assigned vuvova and unassigned gkodinov Feb 26, 2026
@gkodinov gkodinov requested a review from vuvova February 26, 2026 13:52
Comment thread extra/mariabackup/backup_copy.cc Outdated
@vaintroub vaintroub self-requested a review February 26, 2026 14:36
Copy link
Copy Markdown
Member

@vaintroub vaintroub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this idea is wrong. This file should not be created with mariabackup --copy-back with the version of mariabackup. This file should already be in the backup, original, from the MariaDB server, included during mariadb-backup --backup time. It should be correct version exactly how it was on the server, not the one taken from mariabackup on the destination machine.

Look into backup_files_from_datadir to see how it is done for AWS KMS keys (that's from key management plugin we do not distibute anymore), aria_log, and something from mroonga.

Copy link
Copy Markdown
Member

@vuvova vuvova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing the review status to reflect @vaintroub's comment

@FarihaIS FarihaIS changed the title MDEV-34713 Create mariadb_upgrade_info during mariadb-backup --copy-back MDEV-34713 Backup and restore mariadb_upgrade_info file Mar 3, 2026
Copy link
Copy Markdown
Member

@vaintroub vaintroub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good. My only comment is that the file mariadb_upgrade_info that was created in the datadir during the test, and now was proven to survive backup, restore and moveback, needs to be removed again, at the end of the test.

Copy link
Copy Markdown
Member

@vaintroub vaintroub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@FarihaIS
Copy link
Copy Markdown
Contributor Author

FarihaIS commented Mar 4, 2026

@vaintroub thank you for all the feedback!

@FarihaIS
Copy link
Copy Markdown
Contributor Author

FarihaIS commented Apr 6, 2026

@gkodinov thank you for the approval. Looks like the only test that is failing now is main.vector, which seems unrelated to my changes - could you please help confirm?

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.
@gkodinov gkodinov enabled auto-merge (rebase) April 8, 2026 11:01
@gkodinov gkodinov disabled auto-merge April 8, 2026 11:01
@gkodinov gkodinov enabled auto-merge (rebase) April 8, 2026 11:01
@gkodinov gkodinov disabled auto-merge April 8, 2026 11:01
@gkodinov
Copy link
Copy Markdown
Member

gkodinov commented Apr 8, 2026

@gkodinov thank you for the approval. Looks like the only test that is failing now is main.vector, which seems unrelated to my changes - could you please help confirm?

yes, vector is unrelated.

@gkodinov gkodinov enabled auto-merge (rebase) April 8, 2026 11:08
@gkodinov gkodinov merged commit 3a2f8e2 into MariaDB:main Apr 8, 2026
18 of 19 checks passed
@FarihaIS FarihaIS deleted the mdev-34713 branch April 8, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

6 participants