MDEV-39092 Copy Aria data and logs as part of backup - #4971
Open
mariadb-andrzejjarzabek wants to merge 35 commits into
Open
MDEV-39092 Copy Aria data and logs as part of backup#4971mariadb-andrzejjarzabek wants to merge 35 commits into
mariadb-andrzejjarzabek wants to merge 35 commits into
Conversation
|
|
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
6 times, most recently
from
April 25, 2026 19:02
4ef94be to
c143ff2
Compare
dr-m
reviewed
Apr 28, 2026
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
from
May 4, 2026 14:00
efbc62b to
c77278b
Compare
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
2 times, most recently
from
May 17, 2026 19:19
e89625e to
06fd556
Compare
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
2 times, most recently
from
May 20, 2026 05:50
4d6a19c to
d86a6a1
Compare
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
2 times, most recently
from
May 20, 2026 20:24
c6f5119 to
9ebb23e
Compare
dr-m
reviewed
May 21, 2026
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
2 times, most recently
from
May 21, 2026 10:53
8565956 to
04e3bc2
Compare
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
2 times, most recently
from
May 29, 2026 09:47
14ca552 to
c9429eb
Compare
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
2 times, most recently
from
June 1, 2026 15:15
d35cd47 to
824afeb
Compare
mariadb-andrzejjarzabek
marked this pull request as ready for review
June 1, 2026 15:16
mariadb-andrzejjarzabek
marked this pull request as draft
June 1, 2026 15:17
buf_page_t::set_freed(), buf_page_t::flush(), buf_page_t::write_fix_try(), buf_page_t::write_unfix_try(): Use a compare-and-exchange loop to set or clear a write-fix. While set_freed() and flush() are protected by a page latch, write_fix_try() and write_unfix_try() are not. innodb_backup_batch_wait(): Look up any pages that we are about to back up. For any dirty pages, invoke buf_page_t::write_fix_try() to try to set a fake "write fix" lock-free. If the page is currently write-fixed, acquire and release a page latch to wait wait for the write to complete.
log_t::set_archive(false, thd): Ensure that the sequence bit value 0 will be expected on crash recovery and backup. log_t::circular_recovery_from_0(): Accessor for log_sys.circular_recovery_from_sequence_bit_0. buf_flush_wait(), log_checkpoint_low(): Ensure that a checkpoint will be written to reset log_sys.circular_recovery_from_sequence_bit_0. log_t::write_checkpoint(): Reset circular_recovery_from_sequence_bit_0 whenever applicable. We used to blindly reset it in log_t::set_archive(). (cherry picked from commit a848493)
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
from
August 10, 2026 11:56
1146eea to
1ef48c2
Compare
(cherry picked from commit 1370d5a)
…RENAME fil_name_process(): Simplify the logic. If no matching tablespace is found but file_name_t::create_lsn had been set in response to parsing a FILE_CREATE record, try to apply FILE_RENAME to deferred_spaces. fil_delete_apply(): A wrapper for fil_space_free(). When recovering a log in innodb_log_archive=ON format, we must apply FILE_DELETE records in order to avoid a future clash with FILE_CREATE or FILE_RENAME. (cherry picked from commit 7d106c2)
The doublewrite buffer in the system tablespace is only useful for crash recovery in case a data page had been incompletely written by the time the server was killed. If the server is killed during a backup, the backup will be incomplete and unusable anyway. Furthermore, the page range locking makes page writes and backup mutually exclusive.
file_name_t::page0_lsn: Keep track of the last applied recv_sys_t::parse_page0() so that a multi-batch recovery will not reset the file to a smaller size. (cherry picked from commit 0c4039b)
On top of the provisional Aria backup solution provisionally incorporated into MDEV-14992, the following improvements have been made: Aria data and index files are copied under DDL-locked lock level instead of commit-locked, making the backup operation less disruptive. Only log files are copied in the commit-locked phase. Writes to non-transactional Aria tables are blocked in the DDL-locked phase, while writes to transactional tables are written to the log file, allowing consistent point-in-time backup at the time of acquiring the commit lock. Data, index and log files are now copied as a "step" action rather than "end phase" action, allowing them to be copied in parallel using the CONCURRENT option. Non-Aria files, including common SQL-layer metadata and files from other storage engines are copied by the SQL layer rather than the Aria plugin. Note these files are at this time not copied concurrently when the concurrent option is used.
Non-resilient engine files need to be flushed before they are copied to backup at a time when they cannot be further written to. The method of purging table caches is not sufficient for this purpose, as it doesn't flush tables that are in use at the time of the purge. Although the backup lock ensures that they cannot be written to, they can still be opened for reading, in which case the purge does not flush them and the files may be copied incomplete. Instead of purging table caches directly, we call flush_tables(), which in addition to purging, also flushes tables using the HA_EXTRA_FLUSH handler call. This flusing is based on the type of table, only affecting "non-transactional" user tables, which exclude InnoDB tables and transactional Aria tables. The flushing has also been moved from Aria plugin to general SQL code.
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
from
August 18, 2026 07:54
1ef48c2 to
6c6299a
Compare
The rules for acquiring table locks are different for system tables than for user tables. System tables only become blocked for writing at the MDL_BACKUP_WAIT_COMMIT lock level. At least for statistics tables, which are non-transactional, this means that if they are copied at the same time as the user tables, the files may be copied torn resulting in a corrupt backup. The solution needs to be to flush these files and copy them in BACKUP_PHASE_NO_COMMIT. The actual solution is to flush all system tables at the beginning of that phase and to copy all Aria tables in "mysql" schema also in that phase. This somewhat suboptimal in that some tables in "mysql" are copied under MDL_BACKUP_WAIT_COMMIT, where they could be copied under a lower lock level; however the impact of this is limited by the small number and typically small size of these tables and the trade-off is the (also small) cost of determining their table category and transactionality.
mariadb-andrzejjarzabek
force-pushed
the
MDEV-39092
branch
from
August 19, 2026 14:51
6c6299a to
a4a20ea
Compare
dr-m
force-pushed
the
MDEV-14992
branch
2 times, most recently
from
August 24, 2026 13:59
e5a9d2d to
b625be2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An interim solution with some room for optimization: