-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PXB-3227 Dropped table is still in the backup
How to reproduce : 1 . Create table t1.ibd before the backup 2. Start backup with --lock-ddl=REDUCED 3. Pause at debug_sync_point("xtrabackup_suspend_at_start"); 4. RENAME t1.ibd -> t2.ibd 5. DROP t2.ibd 6. Run prepare 7. we end up with t1.ibd in the backup which should have been dropped PXB-3229 Can't create/write to file 't2.ibd.del' (OS errno 17 - File exists) How to reproduce : 1.Create tables t1.ibd t3.ibd before the backup 2.Start backup with --lock-ddl=REDUCED 3.Pause atdebug_sync_point("xtrabackup_suspend_at_start"); 4.RENAME t1.ibd -> t2.ibd 5.DROP t2.ibd 6.RENAME t3.ibd -> t2.ibd 7.DROP t2.ibd 8.Can't create/write to file 't2.ibd.del' (OS errno 17 - File exists) Fix: if dropped table was renamed from another table and original_table was created before backup started and have been copied then we should create `.del` file for original_table and skip creating `.del` file for renamed_table
- Loading branch information
Showing
3 changed files
with
136 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
99 changes: 99 additions & 0 deletions
99
storage/innobase/xtrabackup/test/suites/lockless/rename_then_drop_table.sh
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
######################################################################################### | ||
# PXB-3227: Rename table and then drop table, make sure that original table was deleted | ||
######################################################################################### | ||
|
||
. inc/common.sh | ||
|
||
require_debug_pxb_version | ||
start_server | ||
|
||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.original_table (id INT PRIMARY KEY AUTO_INCREMENT); INSERT INTO test.original_table VALUES(1);" test | ||
innodb_wait_for_flush_all | ||
|
||
xtrabackup --backup --target-dir=$topdir/backup \ | ||
--debug-sync="xtrabackup_suspend_at_start" --lock-ddl=REDUCED \ | ||
2> >( tee $topdir/backup.log)& | ||
|
||
job_pid=$! | ||
pid_file=$topdir/backup/xtrabackup_debug_sync | ||
wait_for_xb_to_suspend $pid_file | ||
xb_pid=`cat $pid_file` | ||
echo "backup pid is $job_pid" | ||
|
||
# Rename table and generate redo | ||
$MYSQL $MYSQL_ARGS -Ns -e "RENAME TABLE test.original_table TO test.renamed_table; INSERT INTO test.renamed_table VALUES (2);" test | ||
# Drop table | ||
$MYSQL $MYSQL_ARGS -Ns -e "DROP TABLE test.renamed_table;" test | ||
|
||
# Resume the xtrabackup process | ||
vlog "Resuming xtrabackup" | ||
kill -SIGCONT $xb_pid | ||
run_cmd wait $job_pid | ||
|
||
if ! egrep -q "Done: Writing file $topdir/backup/test/original_table.ibd.del" $topdir/backup.log ; then | ||
die "xtrabackup did not create .del file for original_table" | ||
fi | ||
|
||
xtrabackup --prepare --target-dir=$topdir/backup | ||
record_db_state test | ||
stop_server | ||
rm -rf $mysql_datadir/* | ||
xtrabackup --copy-back --target-dir=$topdir/backup | ||
start_server | ||
verify_db_state test | ||
|
||
if [ -f $mysql_datadir/test/original_table.ibd ] ; then | ||
die 'dropped original_table.ibd file has been copied to the datadir' | ||
fi | ||
|
||
stop_server | ||
rm -rf $topdir/backup | ||
|
||
######################################################################################################### | ||
# PXB-3229: Make sure backup does not fail with `File exists` error trying to create .del file twice | ||
######################################################################################################### | ||
|
||
start_server | ||
|
||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.t1 (id INT PRIMARY KEY AUTO_INCREMENT); INSERT INTO test.t1 VALUES(1);" test | ||
$MYSQL $MYSQL_ARGS -Ns -e "CREATE TABLE test.t2 (id INT PRIMARY KEY AUTO_INCREMENT); INSERT INTO test.t2 VALUES(1);" test | ||
innodb_wait_for_flush_all | ||
|
||
xtrabackup --backup --target-dir=$topdir/backup \ | ||
--debug-sync="xtrabackup_suspend_at_start" --lock-ddl=REDUCED \ | ||
2> >( tee $topdir/backup.log)& | ||
|
||
job_pid=$! | ||
pid_file=$topdir/backup/xtrabackup_debug_sync | ||
wait_for_xb_to_suspend $pid_file | ||
xb_pid=`cat $pid_file` | ||
echo "backup pid is $job_pid" | ||
|
||
# Rename table and generate redo | ||
$MYSQL $MYSQL_ARGS -Ns -e "RENAME TABLE test.t1 TO test.t3; INSERT INTO test.t3 VALUES (2);" test | ||
# Drop table | ||
$MYSQL $MYSQL_ARGS -Ns -e "DROP TABLE test.t3;" test | ||
# Rename table and generate redo | ||
$MYSQL $MYSQL_ARGS -Ns -e "RENAME TABLE test.t2 TO test.t3; INSERT INTO test.t3 VALUES (2);" test | ||
# Drop table | ||
$MYSQL $MYSQL_ARGS -Ns -e "DROP TABLE test.t3;" test | ||
|
||
# Resume the xtrabackup process | ||
vlog "Resuming xtrabackup" | ||
kill -SIGCONT $xb_pid | ||
run_cmd wait $job_pid | ||
|
||
xtrabackup --prepare --target-dir=$topdir/backup | ||
record_db_state test | ||
stop_server | ||
rm -rf $mysql_datadir/* | ||
xtrabackup --copy-back --target-dir=$topdir/backup | ||
start_server | ||
verify_db_state test | ||
stop_server | ||
rm -rf $mysql_datadir $topdir/backup | ||
|
||
|
||
|
||
|
||
|