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

Proposed by Laurynas Biveinis on 2012-08-01
Status: Merged
Approved by: Stewart Smith on 2012-08-03
Approved revision: 416
Merged at revision: 416
Proposed branch: lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.1
Merge into: lp:percona-xtrabackup/2.1
Prerequisite: lp:~sergei.glushchenko/percona-xtrabackup/xb21-bug932623
Diff against target: 168 lines (+118/-3)
3 files modified
src/write_filt.c (+18/-1)
src/xtrabackup.c (+7/-2)
test/t/bug1022562.sh (+93/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.1
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2012-08-01 Approve on 2012-08-03
Review via email: mp+117603@code.launchpad.net

Description of the change

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

The code is different from 2.0: add a new function wf_common_filter()
in write_filt.c that provides page-offset-based filtering that is
common for all write filters.

Jenkins (with follow-up branches included): http://jenkins.percona.com/job/percona-xtrabackup-2.1-param/35/
Issue #16274

To post a comment you must log in.
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/write_filt.c'
2--- src/write_filt.c 2012-08-01 10:18:22 +0000
3+++ src/write_filt.c 2012-08-01 10:18:22 +0000
4@@ -23,6 +23,7 @@
5 /* Page write filters implementation */
6
7 #include <my_base.h>
8+#include <fil0fil.h>
9 #include <ut0mem.h>
10 #include "common.h"
11 #include "innodb_int.h"
12@@ -31,6 +32,21 @@
13 #include "xtrabackup.h"
14
15 /************************************************************************
16+The common tablespace-offset-based page filter. This is a subroutine for all
17+other filters that will select additional pages to be written by their
18+tablespace position, regardless of the main filter logic.
19+
20+@return TRUE if the page with given id should be selected, FALSE otherwise. */
21+static my_bool wf_common_filter(ulint offset) {
22+ /* We always copy the 1st FIL_IBD_INITIAL_SIZE *
23+ UNIV_PAGE_SIZE bytes of any tablespace. These pages are
24+ guaranteed to be flushed upon tablespace create and they are
25+ needed so that we have a good minimal tablespace image before
26+ doing anything further with it. */
27+ return (offset < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE);
28+}
29+
30+/************************************************************************
31 Write-through page write filter. */
32 static my_bool wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
33 xb_fil_cur_t *cursor);
34@@ -136,7 +152,8 @@
35 for (i = 0, page = cursor->buf; i < cursor->buf_npages;
36 i++, page += page_size) {
37 if (ut_dulint_cmp(incremental_lsn,
38- MACH_READ_64(page + FIL_PAGE_LSN)) >= 0) {
39+ MACH_READ_64(page + FIL_PAGE_LSN)) >= 0
40+ && !wf_common_filter(cursor->buf_offset + i * page_size)) {
41 continue;
42 }
43
44
45=== modified file 'src/xtrabackup.c'
46--- src/xtrabackup.c 2012-08-01 10:18:22 +0000
47+++ src/xtrabackup.c 2012-08-01 10:18:22 +0000
48@@ -3802,7 +3802,7 @@
49 in given directory. When matching tablespace found, renames it to match the
50 name of .delta file. If there was a tablespace with matching name and
51 mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
52-matching file, creates the new one.
53+matching file, creates a placeholder for the new tablespace.
54 @return file handle of matched or created file */
55 static
56 os_file_t
57@@ -3901,7 +3901,12 @@
58 goto found;
59 }
60
61- /* no matching space found. create the new one */
62+ /* No matching space found. create the new one. Note that this is not
63+ a full-fledged tablespace create, as done by
64+ fil_create_new_single_table_tablespace(): the minumum tablespace size
65+ is not ensured and the 1st page fields are not set. We rely on backup
66+ delta to contain the 1st FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
67+ to ensure the correct tablespace image. */
68
69 #ifdef INNODB_VERSION_SHORT
70 if (!fil_space_create(dest_space_name, space_id,
71
72=== added file 'test/t/bug1022562.sh'
73--- test/t/bug1022562.sh 1970-01-01 00:00:00 +0000
74+++ test/t/bug1022562.sh 2012-08-01 10:18:22 +0000
75@@ -0,0 +1,93 @@
76+. inc/common.sh
77+
78+mysqld_additional_args="--innodb_file_per_table"
79+
80+start_server ${mysqld_additional_args}
81+
82+load_dbase_schema incremental_sample
83+
84+# Full backup
85+
86+# Full backup folder
87+rm -rf $topdir/data/full
88+mkdir -p $topdir/data/full
89+# Incremental data
90+rm -rf $topdir/data/delta
91+mkdir -p $topdir/data/delta
92+
93+vlog "Starting backup"
94+
95+xtrabackup --datadir=$mysql_datadir --backup --target-dir=$topdir/data/full \
96+ $mysqld_additional_args
97+
98+vlog "Full backup done"
99+
100+# Changing data in sakila
101+
102+vlog "Making changes to database"
103+
104+${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t2 (a INT(11) DEFAULT NULL, \
105+ number INT(11) DEFAULT NULL) ENGINE=INNODB" incremental_sample
106+${MYSQL} ${MYSQL_ARGS} -e "INSERT INTO t2 VALUES (1, 1)" incremental_sample
107+
108+vlog "Changes done"
109+
110+# Saving the checksum of original table
111+checksum_t2_a=`checksum_table incremental_sample t2`
112+
113+vlog "Table 't2' checksum is $checksum_t2_a"
114+
115+vlog "Making incremental backup"
116+
117+# Incremental backup
118+xtrabackup --datadir=$mysql_datadir --backup \
119+ --target-dir=$topdir/data/delta --incremental-basedir=$topdir/data/full \
120+ $mysqld_additional_args
121+
122+vlog "Incremental backup done"
123+vlog "Preparing backup"
124+
125+# Prepare backup
126+xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
127+ --target-dir=$topdir/data/full $mysqld_additional_args
128+vlog "Log applied to backup"
129+
130+xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
131+ --target-dir=$topdir/data/full --incremental-dir=$topdir/data/delta \
132+ $mysqld_additional_args
133+vlog "Delta applied to backup"
134+
135+xtrabackup --datadir=$mysql_datadir --prepare --target-dir=$topdir/data/full \
136+ $mysqld_additional_args
137+vlog "Data prepared for restore"
138+
139+# removing rows
140+${MYSQL} ${MYSQL_ARGS} -e "delete from t2;" incremental_sample
141+vlog "Table cleared"
142+
143+# Restore backup
144+
145+stop_server
146+
147+vlog "Copying files"
148+
149+cd $topdir/data/full/
150+cp -r * $mysql_datadir
151+cd -
152+
153+vlog "Data restored"
154+
155+start_server ${mysqld_additional_args}
156+
157+vlog "Checking checksums"
158+checksum_t2_b=`checksum_table incremental_sample t2`
159+
160+if [ "$checksum_t2_a" != "$checksum_t2_b" ]
161+then
162+ vlog "Checksums of table 't2' are not equal"
163+ exit -1
164+fi
165+
166+vlog "Checksums are OK"
167+
168+stop_server

Subscribers

People subscribed via source and target branches