Merge lp:~akopytov/percona-xtrabackup/bug1213036-2.1 into lp:percona-xtrabackup/2.1

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 664
Proposed branch: lp:~akopytov/percona-xtrabackup/bug1213036-2.1
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 318 lines (+50/-137)
8 files modified
test/inc/common.sh (+29/-0)
test/inc/ib_incremental_common.sh (+10/-36)
test/t/bug1182726.sh (+1/-9)
test/t/bug810269.sh (+1/-22)
test/t/ib_slave_info.sh (+1/-9)
test/t/ib_stream_incremental.sh (+2/-19)
test/t/xb_export.sh (+1/-9)
test/t/xb_incremental_compressed.inc (+5/-33)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug1213036-2.1
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Registry Administrators Pending
Review via email: mp+180763@code.launchpad.net

Description of the change

    Bug #1213036: ib_incremental_* tests are too slow

    Changed ib_incremental_* tests and a few other ones to use multi-row
    INSERT statements instead of inserting multiple rows by calling mysql
    command line client for each row. Introduced a convenience function
    insert_rows() in common.sh to avoid code repetition in multiple tests.

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.1-param/436/

To post a comment you must log in.
Revision history for this message
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 'test/inc/common.sh'
2--- test/inc/common.sh 2013-07-25 15:04:49 +0000
3+++ test/inc/common.sh 2013-08-19 04:08:39 +0000
4@@ -721,5 +721,34 @@
5 fi
6 }
7
8+##############################################################################
9+# Execute a multi-row INSERT into a specified table.
10+#
11+# Arguments:
12+#
13+# $1 -- table specification
14+#
15+# all subsequent arguments represent tuples to insert in the form:
16+# (value1, ..., valueN)
17+#
18+# Notes:
19+#
20+# 1. Bash special characters in the arguments must be quoted to screen them
21+# from interpreting by Bash, i.e. \(1,...,\'a'\)
22+#
23+# 2. you can use Bash brace expansion to generate multiple tuples, e.g.:
24+# \({1..1000},\'a'\) will generate 1000 tuples (1,'a'), ..., (1000, 'a')
25+##############################################################################
26+function multi_row_insert()
27+{
28+ local table=$1
29+ shift
30+
31+ vlog "Inserting $# rows into $table..."
32+ (IFS=,; echo "INSERT INTO $table VALUES $*") | \
33+ $MYSQL $MYSQL_ARGS
34+ vlog "Done."
35+}
36+
37 # To avoid unbound variable error when no server have been started
38 SRV_MYSQLD_IDS=
39
40=== modified file 'test/inc/ib_incremental_common.sh'
41--- test/inc/ib_incremental_common.sh 2013-07-25 15:04:49 +0000
42+++ test/inc/ib_incremental_common.sh 2013-08-19 04:08:39 +0000
43@@ -15,50 +15,25 @@
44 load_dbase_schema incremental_sample
45
46 # Adding initial rows
47-vlog "Adding initial rows to database..."
48-numrow=100
49-count=0
50-while [ "$numrow" -gt "$count" ]
51-do
52- ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
53- let "count=count+1"
54-done
55-vlog "Initial rows added"
56-
57-# Full backup
58-# backup root directory
59-mkdir -p $topdir/backup
60+multi_row_insert incremental_sample.test \({1..100},100\)
61
62 vlog "Starting backup"
63-innobackupex $topdir/backup
64-full_backup_dir=`grep "innobackupex: Backup created in directory" $OUTFILE | awk -F\' '{print $2}'`
65-vlog "Full backup done to directory $full_backup_dir"
66+full_backup_dir=$topdir/full_backup
67+innobackupex --no-timestamp $full_backup_dir
68
69 # Changing data
70
71 vlog "Making changes to database"
72 ${MYSQL} ${MYSQL_ARGS} -e "create table t2 (a int(11) default null, number int(11) default null) engine=innodb" incremental_sample
73-let "count=numrow+1"
74-let "numrow=1000"
75-while [ "$numrow" -gt "$count" ]
76-do
77- ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
78- ${MYSQL} ${MYSQL_ARGS} -e "insert into t2 values ($count, $numrow);" incremental_sample
79- let "count=count+1"
80-done
81+
82+multi_row_insert incremental_sample.test \({101..1000},1000\)
83+multi_row_insert incremental_sample.t2 \({101..1000},1000\)
84
85 # Rotate bitmap file here and force checkpoint at the same time
86 shutdown_server
87 start_server
88
89-i=1001
90-while [ "$i" -lt "7500" ]
91-do
92- ${MYSQL} ${MYSQL_ARGS} -e "insert into t2 values ($i, repeat(\"ab\", 32500));" incremental_sample
93- let "i=i+1"
94-done
95-
96-vlog "Changes done"
97+multi_row_insert incremental_sample.t2 \({1001..7500},REPEAT\(\'ab\',32500\)\)
98
99 # Saving the checksum of original table
100 checksum_test_a=`checksum_table incremental_sample test`
101@@ -73,10 +48,9 @@
102 vlog "###############"
103
104 # Incremental backup
105-innobackupex --incremental --incremental-basedir=$full_backup_dir \
106- $topdir/backup $ib_inc_extra_args
107-inc_backup_dir=`grep "innobackupex: Backup created in directory" $OUTFILE | tail -n 1 | awk -F\' '{print $2}'`
108-vlog "Incremental backup done to directory $inc_backup_dir"
109+inc_backup_dir=$topdir/backup_incremental
110+innobackupex --no-timestamp --incremental --incremental-basedir=$full_backup_dir \
111+ $inc_backup_dir $ib_inc_extra_args
112
113 vlog "Preparing backup"
114 # Prepare backup
115
116=== modified file 'test/t/bug1182726.sh'
117--- test/t/bug1182726.sh 2013-07-08 09:28:05 +0000
118+++ test/t/bug1182726.sh 2013-08-19 04:08:39 +0000
119@@ -19,15 +19,7 @@
120 load_dbase_schema incremental_sample
121
122 # Adding initial rows
123-vlog "Adding initial rows to database..."
124-numrow=100
125-count=0
126-while [ "$numrow" -gt "$count" ]
127-do
128- ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
129- let "count=count+1"
130-done
131-vlog "Initial rows added"
132+multi_row_insert incremental_sample.test \({1..100},100\)
133
134 # Full backup of the slave server
135 switch_server $slave_id
136
137=== modified file 'test/t/bug810269.sh'
138--- test/t/bug810269.sh 2013-07-25 15:04:49 +0000
139+++ test/t/bug810269.sh 2013-08-19 04:08:39 +0000
140@@ -20,28 +20,7 @@
141 "ALTER TABLE test ENGINE=InnoDB ROW_FORMAT=compressed \
142 KEY_BLOCK_SIZE=4" incremental_sample
143
144-vlog "Adding initial rows to table"
145-
146-numrow=10000
147-count=0
148-while [ "$numrow" -gt "$count" ]; do
149- sql="INSERT INTO test VALUES ($count, $numrow)"
150- let "count=count+1"
151- for ((i=0; $i<99; i++)); do
152- sql="$sql,($count, $numrow)"
153- let "count=count+1"
154- done
155- ${MYSQL} ${MYSQL_ARGS} -e "$sql" incremental_sample
156-done
157-
158-rows=`${MYSQL} ${MYSQL_ARGS} -Ns -e "SELECT COUNT(*) FROM test" \
159- incremental_sample`
160-if [ "$rows" != "10000" ]; then
161- vlog "Failed to add initial rows"
162- exit -1
163-fi
164-
165-vlog "Initial rows added"
166+multi_row_insert incremental_sample.test \({1..10000},10000\)
167
168 checksum_a=`checksum_table incremental_sample test`
169
170
171=== modified file 'test/t/ib_slave_info.sh'
172--- test/t/ib_slave_info.sh 2013-04-27 18:46:54 +0000
173+++ test/t/ib_slave_info.sh 2013-08-19 04:08:39 +0000
174@@ -12,15 +12,7 @@
175 load_dbase_schema incremental_sample
176
177 # Adding initial rows
178-vlog "Adding initial rows to database..."
179-numrow=100
180-count=0
181-while [ "$numrow" -gt "$count" ]
182-do
183- ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
184- let "count=count+1"
185-done
186-vlog "Initial rows added"
187+multi_row_insert incremental_sample.test \({1..100},100\)
188
189 # Full backup of the slave server
190 switch_server $slave_id
191
192=== modified file 'test/t/ib_stream_incremental.sh'
193--- test/t/ib_stream_incremental.sh 2013-07-03 18:30:28 +0000
194+++ test/t/ib_stream_incremental.sh 2013-08-19 04:08:39 +0000
195@@ -22,15 +22,7 @@
196 load_dbase_schema incremental_sample
197
198 # Adding initial rows
199- vlog "Adding initial rows to database..."
200- numrow=100
201- count=0
202- while [ "$numrow" -gt "$count" ]
203- do
204- ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
205- let "count=count+1"
206- done
207- vlog "Initial rows added"
208+ multi_row_insert incremental_sample.test \({1..100},100\)
209
210 full_backup_dir=$topdir/full_backup
211
212@@ -38,16 +30,7 @@
213 innobackupex --no-timestamp $full_backup_dir
214
215 # Changing data
216-
217- vlog "Making changes to database"
218- let "count=numrow+1"
219- let "numrow=500"
220- while [ "$numrow" -gt "$count" ]
221- do
222- ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
223- let "count=count+1"
224- done
225- vlog "Changes done"
226+ multi_row_insert incremental_sample.test \({101..500},500\)
227
228 # Saving the checksum of original table
229 checksum_a=`checksum_table incremental_sample test`
230
231=== modified file 'test/t/xb_export.sh'
232--- test/t/xb_export.sh 2013-07-25 15:04:49 +0000
233+++ test/t/xb_export.sh 2013-08-19 04:08:39 +0000
234@@ -35,15 +35,7 @@
235 load_dbase_schema incremental_sample
236
237 # Adding some data to database
238-vlog "Adding initial rows to database..."
239-numrow=100
240-count=0
241-while [ "$numrow" -gt "$count" ]
242-do
243- ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
244- let "count=count+1"
245-done
246-vlog "Initial rows added"
247+multi_row_insert incremental_sample.test \({1..100},100\)
248
249 checksum_1=`checksum_table incremental_sample test`
250 rowsnum_1=`${MYSQL} ${MYSQL_ARGS} -Ns -e "select count(*) from test" incremental_sample`
251
252=== modified file 'test/t/xb_incremental_compressed.inc'
253--- test/t/xb_incremental_compressed.inc 2013-07-25 15:04:49 +0000
254+++ test/t/xb_incremental_compressed.inc 2013-08-19 04:08:39 +0000
255@@ -12,23 +12,6 @@
256
257 . inc/common.sh
258
259-function add_rows()
260-{
261- local table=$1
262- local start=$2
263- local limit=$3
264-
265- while [ "$limit" -gt "$start" ]; do
266- sql="INSERT INTO $table VALUES ($start, $limit)"
267- let "start=start+1"
268- for ((i=0; $i<99; i++)); do
269- sql="${sql},($start, $limit)"
270- let "start=start+1"
271- done
272- ${MYSQL} ${MYSQL_ARGS} -e "$sql" incremental_sample
273- done
274-}
275-
276 #
277 # Test incremental backup of a compressed tablespace with a specific page size
278 #
279@@ -61,18 +44,7 @@
280
281 # Adding 10k rows
282
283- vlog "Adding initial rows to database..."
284-
285- add_rows test 0 10000
286-
287- rows=`${MYSQL} ${MYSQL_ARGS} -Ns -e "SELECT COUNT(*) FROM test" \
288-incremental_sample`
289- if [ "$rows" != "10000" ]; then
290- vlog "Failed to add initial rows"
291- exit -1
292- fi
293-
294- vlog "Initial rows added"
295+ multi_row_insert incremental_sample.test \({1..10000},10000\)
296
297 # Full backup
298
299@@ -97,15 +69,15 @@
300 number INT(11) DEFAULT NULL) ENGINE=INNODB \
301 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=$page_size" incremental_sample
302
303- add_rows test 10001 12500
304- add_rows t2 10001 12500
305+ multi_row_insert incremental_sample.test \({10001..12500},12500\)
306+ multi_row_insert incremental_sample.t2 \({10001..12500},12500\)
307
308 # Rotate bitmap file here and force checkpoint at the same time
309 shutdown_server
310 start_server
311
312- add_rows test 12501 15000
313- add_rows t2 12501 15000
314+ multi_row_insert incremental_sample.test \({12501..15000},15000\)
315+ multi_row_insert incremental_sample.t2 \({12501..15000},15000\)
316
317 rows=`${MYSQL} ${MYSQL_ARGS} -Ns -e "SELECT COUNT(*) FROM test" \
318 incremental_sample`

Subscribers

People subscribed via source and target branches

to all changes: