Merge lp:~sergei.glushchenko/percona-xtrabackup/bug711166_part-1.6 into lp:percona-xtrabackup/2.0

Proposed by Sergei Glushchenko on 2012-02-01
Status: Rejected
Rejected by: Alexey Kopytov on 2012-09-07
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/bug711166_part-1.6
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 194 lines (+163/-0)
4 files modified
innobackupex (+2/-0)
test/t/bug711166-innodb.sh (+77/-0)
test/t/bug711166-myisam.sh (+79/-0)
xtrabackup.c (+5/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/bug711166_part-1.6
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) 2012-02-01 Needs Resubmitting on 2012-02-01
Review via email: mp+91014@code.launchpad.net

Description of the change

Merge of fix for 1.6 series

To post a comment you must log in.
Alexey Kopytov (akopytov) wrote :

Sergei,

Please merge to a separate trunk-based tree, and run it through Jenkins before submitting a MP.

I also have some comments on the 1.6 version of the fix.

review: Needs Resubmitting

Unmerged revisions

348. By Sergei Glushchenko on 2012-09-18

Partitioned tables are not correctly handled by the --databases, --include,
--tables-file options of innobackupex, and by the --tables and
--tables-file options of xtrabackup.
Solution is to remove partition suffix (#P#...) before doing filtering.
Testcases cover variants of using filtering options with MyISAM and
InnoDB tables (to test both innobackupex and xtrabackup) with either stream
mode turned on and turned off.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'innobackupex'
2--- innobackupex 2012-01-31 01:46:10 +0000
3+++ innobackupex 2012-02-01 04:33:50 +0000
4@@ -2345,6 +2345,8 @@
5 $filename = (reverse(split(/\//, $table_path)))[0];
6 # get name of the table by removing file suffix
7 $table = (split(/\./, $filename))[0];
8+ # and partition suffix
9+ $table = (split('#P#', $table))[0];
10 }
11 }
12
13
14=== added file 'test/t/bug711166-innodb.sh'
15--- test/t/bug711166-innodb.sh 1970-01-01 00:00:00 +0000
16+++ test/t/bug711166-innodb.sh 2012-02-01 04:33:50 +0000
17@@ -0,0 +1,77 @@
18+########################################################################
19+# Bug #711166: If xtrabackup is being used with --tables-file option
20+# (and the table list contains partitioned table) - only
21+# *.par files are being backed up.
22+########################################################################
23+
24+. inc/common.sh
25+
26+init
27+run_mysqld --innodb_file_per_table
28+
29+mkdir -p $topdir/ext
30+
31+# Create InnoDB partitioned table
32+run_cmd $MYSQL $MYSQL_ARGS test <<EOF
33+CREATE TABLE test (
34+ a int(11) DEFAULT NULL
35+) ENGINE=InnoDB DEFAULT CHARSET=latin1
36+PARTITION BY RANGE (a)
37+(PARTITION p0 VALUES LESS THAN (100) ENGINE = InnoDB,
38+ PARTITION P1 VALUES LESS THAN (200) ENGINE = InnoDB,
39+ PARTITION p2 VALUES LESS THAN (300) ENGINE = InnoDB,
40+ PARTITION p3 VALUES LESS THAN (400) ENGINE = InnoDB,
41+ PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
42+EOF
43+
44+# Adding 500 rows
45+
46+vlog "Adding initial rows to database..."
47+
48+numrow=500
49+count=0
50+while [ "$numrow" -gt "$count" ]
51+do
52+ ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count);" test
53+ let "count=count+1"
54+done
55+
56+# Saving the checksum of original table
57+checksum_a=`checksum_table test test`
58+
59+# Take a backup
60+# Only backup of test.test table will be taken
61+cat >$topdir/tables <<EOF
62+test.test
63+EOF
64+xtrabackup --datadir=$mysql_datadir --backup --target-dir=$topdir/backup \
65+ --tables-file=$topdir/tables
66+vlog "Backup taken"
67+xtrabackup --datadir=$mysql_datadir --prepare --target-dir=$topdir/backup
68+vlog "Backup prepared"
69+
70+stop_mysqld
71+
72+# Remove original table
73+rm $mysql_datadir/test/test*.ibd
74+rm -rf $topdir/ext/*
75+vlog "Original test.test removed"
76+
77+# Restore test.test from backup
78+cp -r $topdir/backup/* $mysql_datadir
79+vlog "test.test copied from backup"
80+
81+run_mysqld
82+
83+vlog "Cheking checksums"
84+checksum_b=`checksum_table test test`
85+
86+vlog "Checksums are $checksum_a and $checksum_b"
87+
88+if [ "$checksum_a" != "$checksum_b" ]
89+then
90+ vlog "Checksums are not equal"
91+ exit -1
92+fi
93+
94+vlog "Checksums are OK"
95
96=== added file 'test/t/bug711166-myisam.sh'
97--- test/t/bug711166-myisam.sh 1970-01-01 00:00:00 +0000
98+++ test/t/bug711166-myisam.sh 2012-02-01 04:33:50 +0000
99@@ -0,0 +1,79 @@
100+########################################################################
101+# Bug #711166: If innobackupex is being used with --tables-file option
102+# (and the table list contains partitioned table) - only
103+# *.par files are being backed up.
104+########################################################################
105+
106+. inc/common.sh
107+
108+init
109+run_mysqld
110+
111+mkdir -p $topdir/ext
112+
113+# Create MyISAM partitioned table with some partitions in
114+# different location
115+run_cmd $MYSQL $MYSQL_ARGS test <<EOF
116+CREATE TABLE test (
117+ a int(11) DEFAULT NULL
118+) ENGINE=MyISAM DEFAULT CHARSET=latin1
119+PARTITION BY RANGE (a)
120+(PARTITION p0 VALUES LESS THAN (100) ENGINE = MyISAM,
121+ PARTITION P1 VALUES LESS THAN (200) ENGINE = MyISAM,
122+ PARTITION p2 VALUES LESS THAN (300)
123+ DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
124+ ENGINE = MyISAM,
125+ PARTITION p3 VALUES LESS THAN (400)
126+ DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
127+ ENGINE = MyISAM,
128+ PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = MyISAM);
129+EOF
130+
131+# Adding 500 rows
132+
133+vlog "Adding initial rows to database..."
134+
135+numrow=500
136+count=0
137+while [ "$numrow" -gt "$count" ]
138+do
139+ ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count);" test
140+ let "count=count+1"
141+done
142+
143+# Saving the checksum of original table
144+checksum_a=`checksum_table test test`
145+
146+# Take a backup
147+# Only backup of test.test table will be taken
148+cat >$topdir/tables <<EOF
149+test.test
150+EOF
151+$IB_BIN $IB_ARGS --no-timestamp --tables-file=$topdir/tables $topdir/backup
152+vlog "Backup taken"
153+
154+stop_mysqld
155+
156+# Remove original table
157+rm $mysql_datadir/test/test*
158+rm -rf $topdir/ext/*
159+vlog "Original test.test removed"
160+
161+# Restore test.test from backup
162+cp -r $topdir/backup/* $mysql_datadir
163+vlog "test.test copied from backup"
164+
165+run_mysqld
166+
167+vlog "Cheking checksums"
168+checksum_b=`checksum_table test test`
169+
170+vlog "Checksums are $checksum_a and $checksum_b"
171+
172+if [ "$checksum_a" != "$checksum_b" ]
173+then
174+ vlog "Checksums are not equal"
175+ exit -1
176+fi
177+
178+vlog "Checksums are OK"
179
180=== modified file 'xtrabackup.c'
181--- xtrabackup.c 2012-01-31 01:46:10 +0000
182+++ xtrabackup.c 2012-02-01 04:33:50 +0000
183@@ -2877,6 +2877,11 @@
184 p = next + 1;
185 }
186 p_len = strlen(p) - strlen(".ibd");
187+ /* in case file is parttition of a table it contains #P# magic
188+ after the table name.
189+ */
190+ if ((next = strstr(p, "#P#")) != NULL)
191+ p_len = next - p;
192
193 if (p_len < 1) {
194 /* unknown situation: skip filtering */

Subscribers

People subscribed via source and target branches