mirror of
https://github.com/MariaDB/server.git
synced 2025-02-11 16:05:34 +01:00
![Marko Mäkelä](/assets/img/avatar_default.png)
In mariadb-backup --backup there are multiple mechanisms for ensuring that a sufficient amount of the InnoDB write-ahead log (ib_logfile0) is being copied at the end of the backup. The backup needs to include the latest committed transaction. While further transaction commits are blocked by BACKUP STAGE BLOCK_COMMIT, ongoing transactions may modify the database contents and write log records. We were unnecessarily copying such log, which would also cause further effort of rolling back incomplete transactions after the backup is restored. backup_wait_for_lsn(): Declare as static, and refactor some code to separate functions backup_wait_for_lsn_low() and backup_wait_timeout(). backup_wait_for_commit_lsn(): A new function to determine the current LSN (within BACKUP STAGE BLOCK_COMMIT) and to wait for the log to be copied until that. Invoked by BackupStages::stage_block_commit(). xtrabackup_backup_func(): Remove a condition that had already been checked by a caller of backup_wait_timeout(). server_lsn_after_lock: Declare as a local variable in BackupStages::stage_block_ddl(). log_copying_thread(), io_watching_thread(): Use metadata_last_lsn instead of metadata_to_lsn as the stop condition. BackupStages::stage_block_commit(): Ensure that the log tables (in particular, mysql.general_log) will have been copied before the BACKUP STAGE BLOCK_COMMIT is being followed by any further SQL statements. Reviewed by: Debarun Banerjee Tested by: Matthias Leich
45 lines
1.4 KiB
Text
45 lines
1.4 KiB
Text
# Test for copying log tables tail
|
|
--source include/have_aria.inc
|
|
--source include/have_debug.inc
|
|
|
|
--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup
|
|
|
|
CREATE TABLE t(i INT)
|
|
ENGINE ARIA TRANSACTIONAL=1 ROW_FORMAT=PAGE PAGE_CHECKSUM=1;
|
|
|
|
# Truncate the log in order to make the test ./mtr --repeat proof
|
|
SET GLOBAL general_log = 0;
|
|
TRUNCATE mysql.general_log;
|
|
SET GLOBAL general_log = 1;
|
|
SET GLOBAL log_output = 'TABLE';
|
|
|
|
INSERT INTO t VALUES (1);
|
|
|
|
--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID 5 Query
|
|
--sorted_result
|
|
SELECT * FROM mysql.general_log
|
|
WHERE argument LIKE "INSERT INTO %" AND
|
|
(command_type = "Query" OR command_type = "Execute") ;
|
|
|
|
--echo # Insert new row into general_log table after it has been copied on BLOCK_DDL.
|
|
--let after_stage_block_ddl=INSERT INTO test.t VALUES (2)
|
|
|
|
--echo # Backup to dir.
|
|
--disable_result_log
|
|
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=10 --target-dir=$targetdir --dbug=+d,mariabackup_events
|
|
--enable_result_log
|
|
|
|
--echo # Xtrabackup prepare.
|
|
--disable_result_log
|
|
--exec $XTRABACKUP --prepare --target-dir=$targetdir
|
|
--source include/restart_and_restore.inc
|
|
--enable_result_log
|
|
|
|
--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID 5 Query
|
|
--sorted_result
|
|
SELECT * FROM mysql.general_log
|
|
WHERE argument LIKE "INSERT INTO %" AND
|
|
(command_type = "Query" OR command_type = "Execute") ;
|
|
|
|
--rmdir $targetdir
|
|
DROP TABLE t;
|