Merge lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.0 into lp:percona-xtrabackup/2.0

Proposed by Laurynas Biveinis on 2012-07-25
Status: Merged
Approved by: Stewart Smith on 2012-08-01
Approved revision: 450
Merged at revision: 453
Proposed branch: lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.0
Merge into: lp:percona-xtrabackup/2.0
Prerequisite: lp:~sergei.glushchenko/percona-xtrabackup/xb20-bug932623
Diff against target: 145 lines (+111/-4)
2 files modified
src/xtrabackup.c (+18/-4)
test/t/bug1022562.sh (+93/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.0
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2012-07-25 Approve on 2012-08-01
Review via email: mp+116624@code.launchpad.net

Description of the change

Fix bug 1022562 (Inc backup fails if a tablespace is created between
full and inc backups).

The issue is that with the testcase workload, the 1st 4
(FIL_IBD_FILE_INITIAL_SIZE) pages of a new tablespace were not flushed
from the buffer pool between the full and incremental backups, thus
they were not a part of the delta and on backup prepare a new
tablespace was created from scratch. But that tablespace did not have
its 1st page flags initialized properly, resulting in InnoDB errors.

Fixed by always storing the 1st FIL_IBD_FILE_INITIAL_SIZE pages in the
incremental backup delta. Also added a comment to
xb_delta_open_matching_space() that this function does not create a
"regular" tablespace but only its file. Added a testcase for this
bug.

Jenkins: http://jenkins.percona.com/job/percona-xtrabackup-2.0-param/228/

I used lp:~sergei.glushchenko/percona-xtrabackup/xb20-bug932623 as a prerequisite branch as it refactored out the tablespace load/open code and is already approved for merge.

To post a comment you must log in.

Issue #16274

450. By Laurynas Biveinis on 2012-07-26

Fix bug 1022562 (Inc backup fails if a tablespace is created between
full and inc backups).

The issue is that with the testcase workload, the 1st four
(FIL_IBD_FILE_INITIAL_SIZE) pages of a new tablespace were not flushed
from the buffer pool between the full and incremental backups, thus
they were not a part of the delta and on backup prepare a new
tablespace was created from scratch. But that tablespace did not have
its 1st page flags initialized properly, resulting in InnoDB errors.

Fixed by always storing the 1st block of pages that is sized
FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE bytes in the incremental
backup delta. UNIV_PAGE_SIZE is used because the minimum tablespace
size requirement is the same in bytes for compressed tablespaces too,
so for them more than FIL_IBD_FIL_INITIAL_SIZE number of pages must be
copied. Also added a comment to xb_delta_open_matching_space() that
this function does not create a "regular" tablespace but only its
file. Added a testcase for this bug.

Stewart Smith (stewart) :
review: Approve
451. By Laurynas Biveinis on 2012-08-01

Automerge trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xtrabackup.c'
2--- src/xtrabackup.c 2012-08-01 10:24:19 +0000
3+++ src/xtrabackup.c 2012-08-01 10:24:19 +0000
4@@ -3388,9 +3388,18 @@
5 if (xtrabackup_incremental) {
6 for (chunk_offset = 0; chunk_offset < chunk; chunk_offset += page_size) {
7 /* newer page */
8- /* This condition may be OK for header, ibuf and fsp */
9+ /* This condition may be OK for header, ibuf and fsp
10+ We always copy the 1st
11+ FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
12+ bytes of any tablespace, regardless of the LSNs
13+ of the pages there. These pages are guaranteed
14+ to be flushed upon tablespace create and they
15+ are required for InnoDB to recognize the
16+ tablespace. */
17 if (ut_dulint_cmp(incremental_lsn,
18- MACH_READ_64(page + chunk_offset + FIL_PAGE_LSN)) < 0) {
19+ MACH_READ_64(page + chunk_offset + FIL_PAGE_LSN)) < 0
20+ || (offset + chunk_offset
21+ < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE)) {
22 /* ========================================= */
23 IB_INT64 offset_on_page;
24
25@@ -5614,7 +5623,7 @@
26 in given directory. When matching tablespace found, renames it to match the
27 name of .delta file. If there was a tablespace with matching name and
28 mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
29-matching file, creates the new one.
30+matching file, creates a placeholder for the new tablespace.
31 @return file handle of matched or created file */
32 static
33 os_file_t
34@@ -5713,7 +5722,12 @@
35 goto found;
36 }
37
38- /* no matching space found. create the new one */
39+ /* No matching space found. create the new one. Note that this is not
40+ a full-fledged tablespace create, as done by
41+ fil_create_new_single_table_tablespace(): the minumum tablespace size
42+ is not ensured and the 1st page fields are not set. We rely on backup
43+ delta to contain the 1st FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
44+ to ensure the correct tablespace image. */
45
46 #ifdef INNODB_VERSION_SHORT
47 if (!fil_space_create(dest_space_name, space_id,
48
49=== added file 'test/t/bug1022562.sh'
50--- test/t/bug1022562.sh 1970-01-01 00:00:00 +0000
51+++ test/t/bug1022562.sh 2012-08-01 10:24:19 +0000
52@@ -0,0 +1,93 @@
53+. inc/common.sh
54+
55+mysqld_additional_args="--innodb_file_per_table"
56+
57+start_server ${mysqld_additional_args}
58+
59+load_dbase_schema incremental_sample
60+
61+# Full backup
62+
63+# Full backup folder
64+rm -rf $topdir/data/full
65+mkdir -p $topdir/data/full
66+# Incremental data
67+rm -rf $topdir/data/delta
68+mkdir -p $topdir/data/delta
69+
70+vlog "Starting backup"
71+
72+xtrabackup --datadir=$mysql_datadir --backup --target-dir=$topdir/data/full \
73+ $mysqld_additional_args
74+
75+vlog "Full backup done"
76+
77+# Changing data in sakila
78+
79+vlog "Making changes to database"
80+
81+${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t2 (a INT(11) DEFAULT NULL, \
82+ number INT(11) DEFAULT NULL) ENGINE=INNODB" incremental_sample
83+${MYSQL} ${MYSQL_ARGS} -e "INSERT INTO t2 VALUES (1, 1)" incremental_sample
84+
85+vlog "Changes done"
86+
87+# Saving the checksum of original table
88+checksum_t2_a=`checksum_table incremental_sample t2`
89+
90+vlog "Table 't2' checksum is $checksum_t2_a"
91+
92+vlog "Making incremental backup"
93+
94+# Incremental backup
95+xtrabackup --datadir=$mysql_datadir --backup \
96+ --target-dir=$topdir/data/delta --incremental-basedir=$topdir/data/full \
97+ $mysqld_additional_args
98+
99+vlog "Incremental backup done"
100+vlog "Preparing backup"
101+
102+# Prepare backup
103+xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
104+ --target-dir=$topdir/data/full $mysqld_additional_args
105+vlog "Log applied to backup"
106+
107+xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
108+ --target-dir=$topdir/data/full --incremental-dir=$topdir/data/delta \
109+ $mysqld_additional_args
110+vlog "Delta applied to backup"
111+
112+xtrabackup --datadir=$mysql_datadir --prepare --target-dir=$topdir/data/full \
113+ $mysqld_additional_args
114+vlog "Data prepared for restore"
115+
116+# removing rows
117+${MYSQL} ${MYSQL_ARGS} -e "delete from t2;" incremental_sample
118+vlog "Table cleared"
119+
120+# Restore backup
121+
122+stop_server
123+
124+vlog "Copying files"
125+
126+cd $topdir/data/full/
127+cp -r * $mysql_datadir
128+cd -
129+
130+vlog "Data restored"
131+
132+start_server ${mysqld_additional_args}
133+
134+vlog "Checking checksums"
135+checksum_t2_b=`checksum_table incremental_sample t2`
136+
137+if [ "$checksum_t2_a" != "$checksum_t2_b" ]
138+then
139+ vlog "Checksums of table 't2' are not equal"
140+ exit -1
141+fi
142+
143+vlog "Checksums are OK"
144+
145+stop_server

Subscribers

People subscribed via source and target branches