Inc backup fails if a tablespace is created between full and inc backups
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona XtraBackup moved to https://jira.percona.com/projects/PXB |
Fix Released
|
High
|
Laurynas Biveinis | ||
2.0 |
Fix Released
|
High
|
Laurynas Biveinis | ||
2.1 |
Fix Released
|
High
|
Laurynas Biveinis |
Bug Description
If the xb_incremental_
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Error: tablespace id 184467440737095
120709 16:07:22 InnoDB: Error creating file './incremental_
120709 16:07:22 InnoDB: Operating system error number 17 in a file operation.
InnoDB: Error number 17 means 'File exists'.
This error will cascade to a same error message on the 3rd prepare step and then to a restored from backup server error:
120709 16:07:30 [ERROR] Cannot find or open table incremental_
the internal data dictionary of InnoDB though the .frm file for the
table exists. Maybe you have deleted and recreated InnoDB data
files but have forgotten to delete the corresponding .frm files
of InnoDB tables, or you have moved .frm files to another database?
or, the table contains indexes that this version of the engine
doesn't support.
Tests xb_incremental and ib_incremental pass with the same change. Tested with xtradb51.
The testcase changes:
=== modified file 'test/t/
--- test/t/
+++ test/t/
@@ -79,31 +79,45 @@
vlog "Making changes to database"
+ ${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t2 (a INT(11) DEFAULT NULL, \
+number INT(11) DEFAULT NULL) ENGINE=INNODB \
+ROW_FORMAT=
+
let "count=numrow+1"
let "numrow=15000"
while [ "$numrow" -gt "$count" ]; do
- sql="INSERT INTO test VALUES ($count, $numrow)"
+ sql="VALUES ($count, $numrow)"
let "count=count+1"
for ((i=0; $i<99; i++)); do
let "count=count+1"
done
- ${MYSQL} ${MYSQL_ARGS} -e "$sql" incremental_sample
+ ${MYSQL} ${MYSQL_ARGS} -e "INSERT INTO test $sql" incremental_sample
+ ${MYSQL} ${MYSQL_ARGS} -e "INSERT INTO t2 $sql" incremental_sample
done
rows=`${MYSQL} ${MYSQL_ARGS} -Ns -e "SELECT COUNT(*) FROM test" \
incremental_
if [ "$rows" != "15000" ]; then
- vlog "Failed to add more rows"
+ vlog "Failed to add more rows to 'test'"
exit -1
fi
+ rows=`${MYSQL} ${MYSQL_ARGS} -Ns -e "SELECT COUNT(*) FROM t2" \
+incremental_
+ if [ "$rows" != "5000" ]; then
+ vlog "Failed to add more rows to 't2'"
+ exit -1
+ fi
+
vlog "Changes done"
# Saving the checksum of original table
- checksum_
+ checksum_
+ checksum_
- vlog "Table checksum is $checksum_a"
+ vlog "Table 'test' checksum is $checksum_test_a"
+ vlog "Table 't2' checksum is $checksum_t2_a"
vlog "Making incremental backup"
@@ -127,8 +141,9 @@
vlog "Data prepared for restore"
# removing rows
- vlog "Table cleared"
${MYSQL} ${MYSQL_ARGS} -e "delete from test;" incremental_sample
+ ${MYSQL} ${MYSQL_ARGS} -e "delete from t2;" incremental_sample
+ vlog "Tables cleared"
# Restore backup
@@ -144,12 +159,19 @@
start_server ${mysqld_
- vlog "Cheking checksums"
- checksum_
-
- if [ "$checksum_a" != "$checksum_b" ]
- then
- vlog "Checksums are not equal"
+ vlog "Checking checksums"
+ checksum_
+ checksum_
+
+ if [ "$checksum_test_a" != "$checksum_test_b" ]
+ then
+ vlog "Checksums of table 'test' are not equal"
+ exit -1
+ fi
+
+ if [ "$checksum_t2_a" != "$checksum_t2_b" ]
+ then
+ vlog "Checksums of table 't2' are not equal"
exit -1
fi
Related branches
- Stewart Smith (community): Approve
-
Diff: 168 lines (+118/-3)3 files modifiedsrc/write_filt.c (+18/-1)
src/xtrabackup.c (+7/-2)
test/t/bug1022562.sh (+93/-0)
- Stewart Smith (community): Approve
-
Diff: 145 lines (+111/-4)2 files modifiedsrc/xtrabackup.c (+18/-4)
test/t/bug1022562.sh (+93/-0)
A reduced test case. It seems that the bug happens when innodb- file-per- table is enabled and a table is created and inserted to between full and incremental backups.
. inc/common.sh
mysqld_ additional_ args="- -innodb_ file_per_ table"
start_server ${mysqld_ additional_ args}
load_dbase_schema incremental_sample
# Full backup
# Full backup folder
rm -rf $topdir/data/full
mkdir -p $topdir/data/full
# Incremental data
rm -rf $topdir/data/delta
mkdir -p $topdir/data/delta
vlog "Starting backup"
xtrabackup --datadir= $mysql_ datadir --backup --target- dir=$topdir/ data/full \ additional_ args
$mysqld_
vlog "Full backup done"
# Changing data in sakila
vlog "Making changes to database"
${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t2 (a INT(11) DEFAULT NULL, \
number INT(11) DEFAULT NULL) ENGINE=INNODB" incremental_sample
${MYSQL} ${MYSQL_ARGS} -e "INSERT INTO t2 VALUES (1, 1)" incremental_sample
vlog "Changes done"
# Saving the checksum of original table t2_a=`checksum_ table incremental_sample t2`
checksum_
vlog "Table 't2' checksum is $checksum_t2_a"
vlog "Making incremental backup"
# Incremental backup $mysql_ datadir --backup \ dir=$topdir/ data/delta --incremental- basedir= $topdir/ data/full \ additional_ args
xtrabackup --datadir=
--target-
$mysqld_
vlog "Incremental backup done"
vlog "Preparing backup"
# Prepare backup $mysql_ datadir --prepare --apply-log-only \ dir=$topdir/ data/full $mysqld_ additional_ args
xtrabackup --datadir=
--target-
vlog "Log applied to backup"
xtrabackup --datadir= $mysql_ datadir --prepare --apply-log-only \ dir=$topdir/ data/full --incremental- dir=$topdir/ data/delta \ additional_ args
--target-
$mysqld_
vlog "Delta applied to backup"
xtrabackup --datadir= $mysql_ datadir --prepare --target- dir=$topdir/ data/full \ additional_ args
$mysqld_
vlog "Data prepared for restore"
# removing rows
${MYSQL} ${MYSQL_ARGS} -e "delete from t2;" incremental_sample
vlog "Table cleared"
# Restore backup
stop_server
vlog "Copying files"
cd $topdir/data/full/
cp -r * $mysql_datadir
cd -
vlog "Data restored"
start_server ${mysqld_ additional_ args}
vlog "Checking checksums" t2_b=`checksum_ table incremental_sample t2`
checksum_
if [ "$checksum_t2_a" != "$checksum_t2_b" ]
then
vlog "Checksums of table 't2' are not equal"
exit -1
fi
vlog "Checksums are OK"
stop_server