mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
f778a5d5e2
In commit 1c5ae99194
(MDEV-25666)
we had changed Mariabackup so that it would no longer skip files
whose names start with #sql. This turned out to be wrong.
Because operations on such named files are not protected by any
locks in the server, it is not safe to copy them.
Not copying the files may make the InnoDB data dictionary
inconsistent with the file system. So, we must do something
in InnoDB to adjust for that.
If InnoDB is being started up without the redo log (ib_logfile0)
or with a zero-length log file, we will assume that the server
was restored from a backup, and adjust things as follows:
dict_check_sys_tables(), fil_ibd_open(): Do not complain about
missing #sql files if they would be dropped a little later.
dict_stats_update_if_needed(): Never add #sql tables to
the recomputing queue. This avoids a potential race condition when
dropping the garbage tables.
drop_garbage_tables_after_restore(): Try to drop any garbage tables.
innodb_ddl_recovery_done(): Invoke drop_garbage_tables_after_restore()
if srv_start_after_restore (a new flag) was set and we are not in
read-only mode (innodb_read_only=ON or innodb_force_recovery>3).
The tests and dbug_mariabackup_event() instrumentation
were developed by Vladislav Vaintroub, who also reviewed this.
50 lines
1.7 KiB
Text
50 lines
1.7 KiB
Text
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
|
|
# The test demonstrates that intermediate tables (ALTER TABLE...ALGORITHM=COPY)
|
|
# are not always properly locked, e.g., can be dropped after
|
|
# BACKUP STAGE BLOCK_COMMIT
|
|
# succeeded.
|
|
# Thus mariabackup decides not to have them in backup at all,
|
|
# since they keep changing even after the backup LSN was determined.
|
|
|
|
echo # xtrabackup backup;
|
|
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
|
|
|
|
CREATE TABLE t1(i int) ENGINE=InnoDB;
|
|
INSERT into t1 values(1);
|
|
|
|
connect con2, localhost, root,,;
|
|
connection con2;
|
|
set lock_wait_timeout=1;
|
|
SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit';
|
|
SET debug_sync='alter_table_after_temp_table_drop SIGNAL temp_table_dropped';
|
|
DELIMITER |;
|
|
send SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;|
|
|
DELIMITER ;|
|
|
connection default;
|
|
|
|
# setup mariabackup events
|
|
let after_backup_stage_start=SET debug_sync='now SIGNAL after_backup_stage_start WAIT_FOR go';
|
|
let after_backup_stage_block_commit=SET debug_sync='now SIGNAL after_backup_stage_block_commit';
|
|
let backup_fix_ddl=SET debug_sync='now WAIT_FOR temp_table_dropped';
|
|
--disable_result_log
|
|
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events;
|
|
--enable_result_log
|
|
|
|
connection con2;
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
reap;
|
|
SET debug_sync='RESET';
|
|
disconnect con2;
|
|
|
|
connection default;
|
|
echo # xtrabackup prepare;
|
|
--disable_result_log
|
|
exec $XTRABACKUP --prepare --target-dir=$targetdir;
|
|
-- source include/restart_and_restore.inc
|
|
--enable_result_log
|
|
|
|
SELECT * FROM t1;
|
|
DROP TABLE t1;
|
|
rmdir $targetdir;
|