Skip to content

MDEV-14992 BACKUP SERVER to mounted file system#4817

Draft
dr-m wants to merge 6 commits into
mainfrom
MDEV-14992
Draft

MDEV-14992 BACKUP SERVER to mounted file system#4817
dr-m wants to merge 6 commits into
mainfrom
MDEV-14992

Conversation

@dr-m

@dr-m dr-m commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@dr-m dr-m self-assigned this Mar 17, 2026
@CLAassistant

CLAassistant commented Mar 17, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ grooverdan
❌ dr-m
You have signed the CLA already but the status is still pending? Let us recheck it.

@dr-m dr-m force-pushed the MDEV-14992 branch 2 times, most recently from 2723322 to 1703796 Compare March 18, 2026 11:01
Comment thread sql/sql_backup.cc
@dr-m dr-m force-pushed the MDEV-14992 branch 2 times, most recently from 9a529de to 857edeb Compare March 23, 2026 08:28
@dr-m dr-m changed the base branch from 11.4 to 12.3 March 24, 2026 11:51
@dr-m dr-m force-pushed the MDEV-14992 branch 3 times, most recently from 8149b3d to c08d121 Compare March 27, 2026 09:48
Comment thread storage/innobase/handler/backup_innodb.cc Outdated
Comment thread mysql-test/suite/backup/backup_innodb.test
@dr-m dr-m changed the base branch from 12.3 to main May 5, 2026 10:49
Comment thread sql/sql_backup.cc Outdated
Comment thread storage/innobase/handler/backup_innodb.cc Outdated
Comment thread storage/innobase/buf/buf0flu.cc
dr-m and others added 2 commits June 17, 2026 08:43
recv_sys_t::parse_mmap(): When the current mini-transaction spans two
log files and we run out of memory while attempting to store the parsed
records into recv_sys.pages, the next log file would already have been
closed by recv_sys_t::rewind(). Handle this condition specially.
…Lists.txt (fix)

-fPIC was erronously removed in 526f076. Replaced with the
POSITION_INDEPENDENT_CODE target property.
dr-m added 3 commits June 18, 2026 09:20
There was a race condition between log_t::write_checkpoint() and
the execution of SET GLOBAL innodb_log_archive=ON (enabling log archiving).
We had wrongly allowed the concurrent execution of log_t::set_archive()
and log_t::write_checkpoint(). The result was that
log_sys.next_checkpoint_no was corrupted. This could have broken
crash recovery.

log_t::write_checkpoint(): When we are releasing log_sys.latch while
durably writing the checkpoint header block, assign log_sys.resize_log
to log_sys.log to inform other threads that a checkpoint is in progress.
Previously, we only did this when innodb_log_archive=ON holds.

log_t::resize_start(): Relax a debug assertion for the logic change.

Tested by: Matthias Leich
This introduces a basic driver Sql_cmd_backup, storage engine interfaces,
and basic copying of InnoDB data files.

TODO: Complete the implementation of streaming backup
in GNU tar --format=oldgnu

backup_target: A structured data type to represent a target directory.
On Microsoft Windows, we must use directory paths because there is
no variant of CopyFileEx() that would work on file handles.

backup_sink: Wraps a per-thread output stream as well as storage engine
specific context.

handlerton::backup_start(), handlerton::backup_end(): Invoked at the
start or end of a backup phase, in the thread that executes a
BACKUP SERVER statement.

handlerton::backup_step(): A backup step that can be invoked from
multiple threads concurrently, between the execution of the corresponding
handlerton::backup_start() and handlerton::backup_end() of the same
phase.

copy_entire_file(): A file copying service for POSIX systems.

copy_file(): A sparse file-copying service for all systems.

InnoDB_backup::context: Backup context, attached to backup_sink
so that context can continue to exist between the time a
BACKUP SERVER releases all locks and another BACKUP SERVER starts
executing, with innodb_backup pointing to the new backup, while
the old backup is still being finished.

fil_space_t::write_or_backup: Keep track of in-flight page writes and
pending backup operation. We must not allow them concurrently, because
that could lead into torn pages in the backup.

fil_space_t::backup_end: The first page number that is not being backed up
(by default 0, to indicate that no backup is in progress).

fil_space_t::BACKUP_BATCH_SIZE: The number of preceding pages that will be
covered by fil_space_t::backup_end. This is the unit of "page range locking"
during InnoDB backup.

log_sys.backup: Whether BACKUP SERVER is in progress. The purpose of this
is to make BACKUP SERVER prevent the concurrent execution of
SET GLOBAL innodb_log_archive=OFF or SET GLOBAL innodb_log_file_size
when innodb_log_archive=OFF.

log_sys.archived_checkpoint: Keep track of the earliest available
checkpoint, corresponding to log_sys.archived_lsn. This reflects
SET GLOBAL innodb_log_recovery_start (which is settable now), for
incremental backup.

buf_flush_list_space(): Check for concurrent backup before writing each
page. This is inefficient, but this function may be invoked from multiple
threads concurrently, and it cannot be changed easily, especially for
fil_crypt_thread().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants