Merge lp:~sergei.glushchenko/percona-xtrabackup/xb21-partial into lp:percona-xtrabackup/2.1
- xb21-partial
- Merge into 2.1
Status: | Merged |
---|---|
Approved by: | Alexey Kopytov |
Approved revision: | no longer in the source branch. |
Merged at revision: | 469 |
Proposed branch: | lp:~sergei.glushchenko/percona-xtrabackup/xb21-partial |
Merge into: | lp:percona-xtrabackup/2.1 |
Diff against target: |
905 lines (+537/-201) 9 files modified
innobackupex (+23/-6) src/xtrabackup.c (+172/-195) test/inc/ib_part.sh (+92/-0) test/t/ib_part_databases.sh (+39/-0) test/t/ib_part_include.sh (+47/-0) test/t/ib_part_include_stream.sh (+39/-0) test/t/ib_part_tf_innodb.sh (+46/-0) test/t/ib_part_tf_innodb_stream.sh (+40/-0) test/t/ib_part_tf_myisam.sh (+39/-0) |
To merge this branch: | bzr merge lp:~sergei.glushchenko/percona-xtrabackup/xb21-partial |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stewart Smith (community) | Needs Fixing | ||
Alexey Kopytov (community) | Approve | ||
Review via email: mp+138713@code.launchpad.net |
This proposal supersedes a proposal from 2012-11-24.
Commit message
Description of the change
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.
http://
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal | # |
Alexey Kopytov (akopytov) wrote : | # |
Conflicts. 2.1 already has check_if_
Alexey Kopytov (akopytov) : | # |
Stewart Smith (stewart) wrote : | # |
Many test failures when trying to merge: http://
Sergei Glushchenko (sergei.glushchenko) wrote : | # |
Failures were caused by changed check_if_skip_table behavior in case of database part of table name is empty. This change force xtrabackup --stats to include also SYS_FOREIGN and SYS_FOREIGN_COLS in it's report.
Tests been fixed simply by changing check COUNT==5 to COUNT==7 both for 2.0 and 2.1 patch.
Jenkins runs:
http://
http://
Alexey Kopytov (akopytov) : | # |
Stewart Smith (stewart) : | # |
Stewart Smith (stewart) wrote : | # |
http://
and
http://
failes on centos5-64 pretty consistently.
tail of log is:
121228 8:01:44 InnoDB Plugin 1.0.17 started; log sequence number 59404
[notice (again)]
If you use binary log and don't use any hack of group commit,
the binary log position seems to be:
InnoDB: Last MySQL binlog file position 0 1295, file name ./mysql-bin.000001
xtrabackup: starting shutdown with innodb_
121228 8:01:44 InnoDB: Starting shutdown...
121228 8:01:50 InnoDB: Shutdown completed; log sequence number 59404
121228 08:01:50 innobackupex: completed OK!
2012-12-28 08:01:50: ib_part_include.sh: Backup taken
2012-12-28 08:01:55: ib_part_include.sh: xtrabackup --stats does not work
2012-12-28 08:01:55: run.sh: Found a leftover mysqld processes with PID 22558, stopping it
2012-12-28 08:01:55: run.sh: Found a leftover mysqld processes with PID 11276, stopping it
Sergei Glushchenko (sergei.glushchenko) wrote : | # |
For some weird reason 2>&1 doesn't work nice on Centos 5 with innodb51 flavor. Possibly --stats mix output to stderr and stout or something else happened. Anyways this bug is something different from we are trying to fix here. So, workaround is omit 2&>1. This leaves other parts of test untouched (i.e. 2>&1 was unnecessary). This is what I did.
Sergei Glushchenko (sergei.glushchenko) wrote : | # |
No have failures on Centos 5 x64. Centos 5 32 failed all the tests however. But it is kind of stuff that sometimes happens with Jenkins job.
Preview Diff
1 | === modified file 'innobackupex' |
2 | --- innobackupex 2013-01-02 04:23:18 +0000 |
3 | +++ innobackupex 2013-01-02 16:10:36 +0000 |
4 | @@ -1992,7 +1992,8 @@ |
5 | next unless check_if_required($database, $file); |
6 | |
7 | if($option_include) { |
8 | - if (!("$database.$file" =~ /$option_include/)) { |
9 | + my $table_name = get_table_name($file); |
10 | + if (!("$database.$table_name" =~ /$option_include/)) { |
11 | print STDERR "$database.$file is skipped because it does not match $option_include.\n"; |
12 | next; |
13 | } |
14 | @@ -2314,6 +2315,26 @@ |
15 | return ${$group_hash_ref}{$option_name}; |
16 | } |
17 | |
18 | +# get_table_name subroutine returns table name of specified file. |
19 | +# Parameters: |
20 | +# $_[0] table path |
21 | +# Return value: |
22 | +# 1 table name |
23 | +# |
24 | +sub get_table_name { |
25 | + my $table_path = shift; |
26 | + my $filename; |
27 | + my $table; |
28 | + |
29 | + # get the last component in the table pathname |
30 | + $filename = (reverse(split(/\//, $table_path)))[0]; |
31 | + # get name of the table by removing file suffix |
32 | + $table = (split(/\./, $filename))[0]; |
33 | + # and partition suffix |
34 | + $table = (split('#P#', $table))[0]; |
35 | + |
36 | + return $table; |
37 | +} |
38 | |
39 | # check_if_required subroutine returns 1 if the specified database and |
40 | # table needs to be backed up. |
41 | @@ -2327,7 +2348,6 @@ |
42 | my ( $db, $table_path ) = @_; |
43 | my $db_count = scalar keys %databases_list; |
44 | my $tbl_count = scalar keys %table_list; |
45 | - my $filename; |
46 | my $table; |
47 | |
48 | if ( $db_count == 0 && $tbl_count == 0 ) { |
49 | @@ -2337,10 +2357,7 @@ |
50 | } |
51 | else { |
52 | if ( $table_path ) { |
53 | - # get the last component in the table pathname |
54 | - $filename = (reverse(split(/\//, $table_path)))[0]; |
55 | - # get name of the table by removing file suffix |
56 | - $table = (split(/\./, $filename))[0]; |
57 | + $table = get_table_name($table_path); |
58 | } |
59 | } |
60 | |
61 | |
62 | === modified file 'src/xtrabackup.c' |
63 | --- src/xtrabackup.c 2012-11-21 13:51:49 +0000 |
64 | +++ src/xtrabackup.c 2013-01-02 16:10:36 +0000 |
65 | @@ -1509,71 +1509,71 @@ |
66 | my_bool |
67 | check_if_skip_table( |
68 | /******************/ |
69 | - char* path) /*!< in: path to the table */ |
70 | + char* path, /*!< in: path to the table */ |
71 | + char* suffix) /*!< in: suffix */ |
72 | { |
73 | - char* p = path; |
74 | - char* next; |
75 | - char* prev = NULL; |
76 | - int p_len; |
77 | - int regres = REG_NOMATCH; |
78 | - char tmp; |
79 | - int i; |
80 | + char buf[FN_REFLEN]; |
81 | + const char *dbname, *tbname; |
82 | + const char *ptr; |
83 | + char *eptr; |
84 | + int dbname_len; |
85 | |
86 | if (xtrabackup_tables == NULL && xtrabackup_tables_file == NULL) { |
87 | return(FALSE); |
88 | } |
89 | |
90 | - while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL) |
91 | - { |
92 | - prev = p; |
93 | - p = next + 1; |
94 | - } |
95 | - p_len = strlen(p) - sizeof(".ibd") + 1; |
96 | - |
97 | - if (p_len < 1) { |
98 | - /* shouldn't happen with a valid path, assume the |
99 | - table should not be filtered */ |
100 | - return(FALSE); |
101 | - } |
102 | - |
103 | - /* Make "database.table" string */ |
104 | - tmp = p[p_len]; |
105 | - p[p_len] = 0; |
106 | - *(p - 1) = '.'; |
107 | + dbname = NULL; |
108 | + tbname = path; |
109 | + while ((ptr = strstr(tbname, SRV_PATH_SEPARATOR_STR)) != NULL) { |
110 | + dbname = tbname; |
111 | + tbname = ptr + 1; |
112 | + } |
113 | + |
114 | + if (dbname == NULL) { |
115 | + return(FALSE); |
116 | + } |
117 | + |
118 | + strncpy(buf, dbname, FN_REFLEN); |
119 | + buf[FN_REFLEN - 1] = 0; |
120 | + buf[tbname - 1 - dbname] = '.'; |
121 | + |
122 | + dbname_len = strlen(dbname) - strlen(suffix); |
123 | + if (dbname_len < 1) { |
124 | + return(FALSE); |
125 | + } |
126 | + buf[dbname_len - 1] = 0; |
127 | + |
128 | + if ((eptr = strstr(buf, "#P#")) != NULL) { |
129 | + *eptr = 0; |
130 | + } |
131 | |
132 | if (xtrabackup_tables) { |
133 | + int regres = REG_NOMATCH; |
134 | + int i; |
135 | for (i = 0; i < tables_regex_num; i++) { |
136 | - regres = xb_regexec(&tables_regex[i], prev, 1, |
137 | + regres = xb_regexec(&tables_regex[i], buf, 1, |
138 | tables_regmatch, 0); |
139 | if (regres != REG_NOMATCH) { |
140 | break; |
141 | } |
142 | } |
143 | if (regres == REG_NOMATCH) { |
144 | - goto skip; |
145 | + return(TRUE); |
146 | } |
147 | } |
148 | |
149 | if (xtrabackup_tables_file) { |
150 | xtrabackup_tables_t* table; |
151 | |
152 | - *(p - 1) = SRV_PATH_SEPARATOR; |
153 | - XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(prev), |
154 | + XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(buf), |
155 | table, ut_ad(table->name), |
156 | - !strcmp(table->name, prev)); |
157 | + !strcmp(table->name, buf)); |
158 | if (!table) { |
159 | - goto skip; |
160 | + return(TRUE); |
161 | } |
162 | } |
163 | |
164 | - p[p_len] = tmp; |
165 | - *(p - 1) = SRV_PATH_SEPARATOR; |
166 | return(FALSE); |
167 | - |
168 | -skip: |
169 | - p[p_len] = tmp; |
170 | - *(p - 1) = SRV_PATH_SEPARATOR; |
171 | - return(TRUE); |
172 | } |
173 | |
174 | /*********************************************************************** |
175 | @@ -1619,7 +1619,7 @@ |
176 | xb_write_filt_ctxt_t write_filt_ctxt; |
177 | |
178 | if (!trx_sys_sys_space(node->space->id) && /* don't skip system space */ |
179 | - check_if_skip_table(node->name)) { |
180 | + check_if_skip_table(node->name, "ibd")) { |
181 | msg("[%02u] Skipping %s\n", thread_n, node->name); |
182 | return(FALSE); |
183 | } |
184 | @@ -2341,6 +2341,129 @@ |
185 | return(FALSE); |
186 | } |
187 | |
188 | +static |
189 | +void |
190 | +xb_filters_init() |
191 | +{ |
192 | + if (xtrabackup_tables) { |
193 | + /* init regexp */ |
194 | + char *p, *next; |
195 | + int i; |
196 | + char errbuf[100]; |
197 | + |
198 | + tables_regex_num = 1; |
199 | + |
200 | + p = xtrabackup_tables; |
201 | + while ((p = strchr(p, ',')) != NULL) { |
202 | + p++; |
203 | + tables_regex_num++; |
204 | + } |
205 | + |
206 | + tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num); |
207 | + |
208 | + p = xtrabackup_tables; |
209 | + for (i=0; i < tables_regex_num; i++) { |
210 | + next = strchr(p, ','); |
211 | + ut_a(next || i == tables_regex_num - 1); |
212 | + |
213 | + next++; |
214 | + if (i != tables_regex_num - 1) |
215 | + *(next - 1) = '\0'; |
216 | + |
217 | + xb_regerror(xb_regcomp(&tables_regex[i], p, |
218 | + REG_EXTENDED), |
219 | + &tables_regex[i], errbuf, sizeof(errbuf)); |
220 | + msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf); |
221 | + |
222 | + if (i != tables_regex_num - 1) |
223 | + *(next - 1) = ','; |
224 | + p = next; |
225 | + } |
226 | + } |
227 | + |
228 | + if (xtrabackup_tables_file) { |
229 | + char name_buf[NAME_LEN*2+2]; |
230 | + FILE *fp; |
231 | + |
232 | + name_buf[NAME_LEN*2+1] = '\0'; |
233 | + |
234 | + /* init tables_hash */ |
235 | + tables_hash = hash_create(1000); |
236 | + |
237 | + /* read and store the filenames */ |
238 | + fp = fopen(xtrabackup_tables_file,"r"); |
239 | + if (!fp) { |
240 | + msg("xtrabackup: cannot open %s\n", |
241 | + xtrabackup_tables_file); |
242 | + exit(EXIT_FAILURE); |
243 | + } |
244 | + for (;;) { |
245 | + xtrabackup_tables_t* table; |
246 | + char* p = name_buf; |
247 | + |
248 | + if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) { |
249 | + break; |
250 | + } |
251 | + |
252 | + p = strchr(name_buf, '\n'); |
253 | + if (p) |
254 | + { |
255 | + *p = '\0'; |
256 | + } |
257 | + |
258 | + table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1); |
259 | + memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1); |
260 | + table->name = ((char*)table) + sizeof(xtrabackup_tables_t); |
261 | + strcpy(table->name, name_buf); |
262 | + |
263 | + HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash, |
264 | + ut_fold_string(table->name), table); |
265 | + |
266 | + msg("xtrabackup: table '%s' is registered to the " |
267 | + "list.\n", table->name); |
268 | + } |
269 | + } |
270 | +} |
271 | + |
272 | +static |
273 | +void |
274 | +xb_filters_free() |
275 | +{ |
276 | + if (xtrabackup_tables) { |
277 | + /* free regexp */ |
278 | + int i; |
279 | + |
280 | + for (i = 0; i < tables_regex_num; i++) { |
281 | + xb_regfree(&tables_regex[i]); |
282 | + } |
283 | + ut_free(tables_regex); |
284 | + } |
285 | + |
286 | + if (xtrabackup_tables_file) { |
287 | + ulint i; |
288 | + |
289 | + /* free the hash elements */ |
290 | + for (i = 0; i < hash_get_n_cells(tables_hash); i++) { |
291 | + xtrabackup_tables_t* table; |
292 | + |
293 | + table = HASH_GET_FIRST(tables_hash, i); |
294 | + |
295 | + while (table) { |
296 | + xtrabackup_tables_t* prev_table = table; |
297 | + |
298 | + table = HASH_GET_NEXT(name_hash, prev_table); |
299 | + |
300 | + HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash, |
301 | + ut_fold_string(prev_table->name), prev_table); |
302 | + free(prev_table); |
303 | + } |
304 | + } |
305 | + |
306 | + /* free tables_hash */ |
307 | + hash_table_free(tables_hash); |
308 | + } |
309 | +} |
310 | + |
311 | static void |
312 | xtrabackup_backup_func(void) |
313 | { |
314 | @@ -2451,6 +2574,8 @@ |
315 | os_sync_mutex = NULL; |
316 | srv_general_init(); |
317 | |
318 | + xb_filters_init(); |
319 | + |
320 | { |
321 | ibool log_file_created; |
322 | ibool log_created = FALSE; |
323 | @@ -2782,6 +2907,8 @@ |
324 | msg("xtrabackup: Transaction log of lsn (%llu) to (%llu) was copied.\n", |
325 | checkpoint_lsn_start, log_copy_scanned_lsn); |
326 | |
327 | + xb_filters_free(); |
328 | + |
329 | xb_data_files_close(); |
330 | } |
331 | |
332 | @@ -3066,6 +3193,8 @@ |
333 | if(innodb_init()) |
334 | exit(EXIT_FAILURE); |
335 | |
336 | + xb_filters_init(); |
337 | + |
338 | fprintf(stdout, "\n\n<INDEX STATISTICS>\n"); |
339 | |
340 | /* gather stats */ |
341 | @@ -3140,43 +3269,8 @@ |
342 | mem_free(table_name); |
343 | |
344 | |
345 | - if (xtrabackup_tables) { |
346 | - char *p; |
347 | - int regres = REG_NOMATCH; |
348 | - int i; |
349 | - |
350 | - p = strstr(table->name, SRV_PATH_SEPARATOR_STR); |
351 | - |
352 | - if (p) |
353 | - *p = '.'; |
354 | - |
355 | - for (i = 0; i < tables_regex_num; i++) { |
356 | - regres = xb_regexec(&tables_regex[i], |
357 | - table->name, 1, |
358 | - tables_regmatch, 0); |
359 | - if (regres != REG_NOMATCH) |
360 | - break; |
361 | - } |
362 | - |
363 | - if (p) |
364 | - *p = SRV_PATH_SEPARATOR; |
365 | - |
366 | - if ( regres == REG_NOMATCH ) |
367 | - goto skip; |
368 | - } |
369 | - |
370 | - if (xtrabackup_tables_file) { |
371 | - xtrabackup_tables_t* xtable; |
372 | - |
373 | - XB_HASH_SEARCH(name_hash, tables_hash, |
374 | - ut_fold_string(table->name), |
375 | - xtable, |
376 | - ut_ad(xtable->name), |
377 | - !strcmp(xtable->name, table->name)); |
378 | - |
379 | - if (!xtable) |
380 | - goto skip; |
381 | - } |
382 | + if (table && check_if_skip_table(table->name, "")) |
383 | + goto skip; |
384 | |
385 | |
386 | if (table == NULL) { |
387 | @@ -3272,6 +3366,8 @@ |
388 | end: |
389 | putc('\n', stdout); |
390 | |
391 | + xb_filters_free(); |
392 | + |
393 | /* shutdown InnoDB */ |
394 | if(innodb_end()) |
395 | exit(EXIT_FAILURE); |
396 | @@ -4695,91 +4791,6 @@ |
397 | my_load_path(xtrabackup_real_target_dir, xtrabackup_target_dir, NULL); |
398 | xtrabackup_target_dir= xtrabackup_real_target_dir; |
399 | |
400 | - if (xtrabackup_tables) { |
401 | - /* init regexp */ |
402 | - char *p, *next; |
403 | - int i; |
404 | - char errbuf[100]; |
405 | - |
406 | - tables_regex_num = 1; |
407 | - |
408 | - p = xtrabackup_tables; |
409 | - while ((p = strchr(p, ',')) != NULL) { |
410 | - p++; |
411 | - tables_regex_num++; |
412 | - } |
413 | - |
414 | - tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num); |
415 | - |
416 | - p = xtrabackup_tables; |
417 | - for (i=0; i < tables_regex_num; i++) { |
418 | - next = strchr(p, ','); |
419 | - ut_a(next || i == tables_regex_num - 1); |
420 | - |
421 | - next++; |
422 | - if (i != tables_regex_num - 1) |
423 | - *(next - 1) = '\0'; |
424 | - |
425 | - xb_regerror(xb_regcomp(&tables_regex[i], p, |
426 | - REG_EXTENDED), |
427 | - &tables_regex[i], errbuf, sizeof(errbuf)); |
428 | - msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf); |
429 | - |
430 | - if (i != tables_regex_num - 1) |
431 | - *(next - 1) = ','; |
432 | - p = next; |
433 | - } |
434 | - } |
435 | - |
436 | - if (xtrabackup_tables_file) { |
437 | - char name_buf[NAME_LEN*2+2]; |
438 | - FILE *fp; |
439 | - |
440 | - name_buf[NAME_LEN*2+1] = '\0'; |
441 | - |
442 | - /* init tables_hash */ |
443 | - tables_hash = hash_create(1000); |
444 | - |
445 | - /* read and store the filenames */ |
446 | - fp = fopen(xtrabackup_tables_file,"r"); |
447 | - if (!fp) { |
448 | - msg("xtrabackup: cannot open %s\n", |
449 | - xtrabackup_tables_file); |
450 | - exit(EXIT_FAILURE); |
451 | - } |
452 | - for (;;) { |
453 | - xtrabackup_tables_t* table; |
454 | - char* p = name_buf; |
455 | - |
456 | - if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) { |
457 | - break; |
458 | - } |
459 | - |
460 | - while (*p != '\0') { |
461 | - if (*p == '.') { |
462 | - *p = '/'; |
463 | - } |
464 | - p++; |
465 | - } |
466 | - p = strchr(name_buf, '\n'); |
467 | - if (p) |
468 | - { |
469 | - *p = '\0'; |
470 | - } |
471 | - |
472 | - table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1); |
473 | - memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1); |
474 | - table->name = ((char*)table) + sizeof(xtrabackup_tables_t); |
475 | - strcpy(table->name, name_buf); |
476 | - |
477 | - HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash, |
478 | - ut_fold_string(table->name), table); |
479 | - |
480 | - msg("xtrabackup: table '%s' is registered to the " |
481 | - "list.\n", table->name); |
482 | - } |
483 | - } |
484 | - |
485 | #ifdef XTRADB_BASED |
486 | /* temporary setting of enough size */ |
487 | srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX; |
488 | @@ -4933,40 +4944,6 @@ |
489 | if (xtrabackup_prepare) |
490 | xtrabackup_prepare_func(); |
491 | |
492 | - if (xtrabackup_tables) { |
493 | - /* free regexp */ |
494 | - int i; |
495 | - |
496 | - for (i = 0; i < tables_regex_num; i++) { |
497 | - xb_regfree(&tables_regex[i]); |
498 | - } |
499 | - ut_free(tables_regex); |
500 | - } |
501 | - |
502 | - if (xtrabackup_tables_file) { |
503 | - ulint i; |
504 | - |
505 | - /* free the hash elements */ |
506 | - for (i = 0; i < hash_get_n_cells(tables_hash); i++) { |
507 | - xtrabackup_tables_t* table; |
508 | - |
509 | - table = HASH_GET_FIRST(tables_hash, i); |
510 | - |
511 | - while (table) { |
512 | - xtrabackup_tables_t* prev_table = table; |
513 | - |
514 | - table = HASH_GET_NEXT(name_hash, prev_table); |
515 | - |
516 | - HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash, |
517 | - ut_fold_string(prev_table->name), prev_table); |
518 | - free(prev_table); |
519 | - } |
520 | - } |
521 | - |
522 | - /* free tables_hash */ |
523 | - hash_table_free(tables_hash); |
524 | - } |
525 | - |
526 | xb_regex_end(); |
527 | |
528 | exit(EXIT_SUCCESS); |
529 | |
530 | === added file 'test/inc/ib_part.sh' |
531 | --- test/inc/ib_part.sh 1970-01-01 00:00:00 +0000 |
532 | +++ test/inc/ib_part.sh 2013-01-02 16:10:36 +0000 |
533 | @@ -0,0 +1,92 @@ |
534 | + |
535 | + |
536 | +function check_partitioning() |
537 | +{ |
538 | + $MYSQL $MYSQL_ARGS -Ns -e "show variables like 'have_partitioning'" |
539 | +} |
540 | + |
541 | +function require_partitioning() |
542 | +{ |
543 | + PARTITION_CHECK=`check_partitioning` |
544 | + |
545 | + if [ -z "$PARTITION_CHECK" ]; then |
546 | + echo "Requires Partitioning." > $SKIPPED_REASON |
547 | + exit $SKIPPED_EXIT_CODE |
548 | + fi |
549 | +} |
550 | + |
551 | +function ib_part_schema() |
552 | +{ |
553 | + topdir=$1 |
554 | + engine=$2 |
555 | + |
556 | + cat <<EOF |
557 | +CREATE TABLE test ( |
558 | + a int(11) DEFAULT NULL |
559 | +) ENGINE=$engine DEFAULT CHARSET=latin1 |
560 | +PARTITION BY RANGE (a) |
561 | +(PARTITION p0 VALUES LESS THAN (100) ENGINE = $engine, |
562 | + PARTITION P1 VALUES LESS THAN (200) ENGINE = $engine, |
563 | + PARTITION p2 VALUES LESS THAN (300) |
564 | + DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext' |
565 | + ENGINE = $engine, |
566 | + PARTITION p3 VALUES LESS THAN (400) |
567 | + DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext' |
568 | + ENGINE = $engine, |
569 | + PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = $engine); |
570 | +EOF |
571 | +} |
572 | + |
573 | +function ib_part_data() |
574 | +{ |
575 | + echo 'INSERT INTO test VALUES (1), (101), (201), (301), (401);'; |
576 | +} |
577 | + |
578 | +function ib_part_init() |
579 | +{ |
580 | + topdir=$1 |
581 | + engine=$2 |
582 | + |
583 | + if [ -d $topdir/ext ] ; then |
584 | + rm -rf $topdir/ext |
585 | + fi |
586 | + mkdir -p $topdir/ext |
587 | + |
588 | + ib_part_schema $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test |
589 | + ib_part_data $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test |
590 | +} |
591 | + |
592 | +function ib_part_restore() |
593 | +{ |
594 | + topdir=$1 |
595 | + mysql_datadir=$2 |
596 | + |
597 | + # Remove database |
598 | + rm -rf $mysql_datadir/test/* |
599 | + rm -rf $topdir/ext/* |
600 | + vlog "Original database removed" |
601 | + |
602 | + # Restore database from backup |
603 | + cp -rv $topdir/backup/test/* $mysql_datadir/test |
604 | + vlog "database restored from backup" |
605 | + |
606 | +} |
607 | + |
608 | +function ib_part_assert_checksum() |
609 | +{ |
610 | + checksum_a=$1 |
611 | + |
612 | + vlog "Checking checksums" |
613 | + checksum_b=`checksum_table test test` |
614 | + |
615 | + vlog "Checksums are $checksum_a and $checksum_b" |
616 | + |
617 | + if [ "$checksum_a" != "$checksum_b" ] |
618 | + then |
619 | + vlog "Checksums are not equal" |
620 | + exit -1 |
621 | + fi |
622 | + |
623 | + vlog "Checksums are OK" |
624 | + |
625 | +} |
626 | |
627 | === added file 'test/t/ib_part_databases.sh' |
628 | --- test/t/ib_part_databases.sh 1970-01-01 00:00:00 +0000 |
629 | +++ test/t/ib_part_databases.sh 2013-01-02 16:10:36 +0000 |
630 | @@ -0,0 +1,39 @@ |
631 | +######################################################################## |
632 | +# Bug #711166: Partitioned tables are not correctly handled by the |
633 | +# --databases and --tables-file options of innobackupex, |
634 | +# and by the --tables option of xtrabackup. |
635 | +# Testcase covers using --databases option with MyISAM |
636 | +# database |
637 | +######################################################################## |
638 | + |
639 | +. inc/common.sh |
640 | +. inc/ib_part.sh |
641 | + |
642 | +start_server |
643 | + |
644 | +require_partitioning |
645 | + |
646 | +# Create MyISAM partitioned table with some partitions in |
647 | +# different location |
648 | +ib_part_init $topdir MyISAM |
649 | + |
650 | +# Saving the checksum of original table |
651 | +checksum_a=`checksum_table test test` |
652 | + |
653 | +# Take a backup |
654 | +cat >$topdir/databases_file <<EOF |
655 | +test.test |
656 | +EOF |
657 | +innobackupex --no-timestamp --databases=$topdir/databases_file $topdir/backup |
658 | +innobackupex --apply-log $topdir/backup |
659 | +vlog "Backup taken" |
660 | + |
661 | +stop_server |
662 | + |
663 | +# Restore partial backup |
664 | +ib_part_restore $topdir $mysql_datadir |
665 | + |
666 | +start_server |
667 | + |
668 | +# compare checksum |
669 | +ib_part_assert_checksum $checksum_a |
670 | |
671 | === added file 'test/t/ib_part_include.sh' |
672 | --- test/t/ib_part_include.sh 1970-01-01 00:00:00 +0000 |
673 | +++ test/t/ib_part_include.sh 2013-01-02 16:10:36 +0000 |
674 | @@ -0,0 +1,47 @@ |
675 | +######################################################################## |
676 | +# Bug #711166: Partitioned tables are not correctly handled by the |
677 | +# --databases and --tables-file options of innobackupex, |
678 | +# and by the --tables option of xtrabackup. |
679 | +# Testcase covers using --include option with InnoDB |
680 | +# database |
681 | +######################################################################## |
682 | + |
683 | +. inc/common.sh |
684 | +. inc/ib_part.sh |
685 | + |
686 | +start_server --innodb_file_per_table |
687 | + |
688 | +require_partitioning |
689 | + |
690 | +# Create InnoDB partitioned table |
691 | +ib_part_init $topdir InnoDB |
692 | + |
693 | +# Saving the checksum of original table |
694 | +checksum_a=`checksum_table test test` |
695 | + |
696 | +# Take a backup |
697 | +# Only backup of test.test table will be taken |
698 | +cat >$topdir/tables <<EOF |
699 | +test.test |
700 | +EOF |
701 | +innobackupex --no-timestamp --include='test.test$' $topdir/backup |
702 | +innobackupex --apply-log $topdir/backup |
703 | +vlog "Backup taken" |
704 | + |
705 | +# also test xtrabackup --stats work with --tables-file |
706 | +COUNT=`xtrabackup --stats --tables='test.test$' --datadir=$topdir/backup \ |
707 | + | grep table: | awk '{print $2}' | sort -u | wc -l` |
708 | + |
709 | +if [ $COUNT != 7 ] ; then |
710 | + vlog "xtrabackup --stats does not work" |
711 | + exit -1 |
712 | +fi |
713 | + |
714 | +stop_server |
715 | + |
716 | +# Restore partial backup |
717 | +ib_part_restore $topdir $mysql_datadir |
718 | + |
719 | +start_server |
720 | + |
721 | +ib_part_assert_checksum $checksum_a |
722 | |
723 | === added file 'test/t/ib_part_include_stream.sh' |
724 | --- test/t/ib_part_include_stream.sh 1970-01-01 00:00:00 +0000 |
725 | +++ test/t/ib_part_include_stream.sh 2013-01-02 16:10:36 +0000 |
726 | @@ -0,0 +1,39 @@ |
727 | +######################################################################## |
728 | +# Bug #711166: Partitioned tables are not correctly handled by the |
729 | +# --databases and --tables-file options of innobackupex, |
730 | +# and by the --tables option of xtrabackup. |
731 | +# Testcase covers using --include option with InnoDB |
732 | +# database and --stream mode |
733 | +######################################################################## |
734 | + |
735 | +. inc/common.sh |
736 | +. inc/ib_part.sh |
737 | + |
738 | +start_server --innodb_file_per_table |
739 | + |
740 | +require_partitioning |
741 | + |
742 | +# Create MyISAM partitioned table |
743 | +ib_part_init $topdir MyISAM |
744 | + |
745 | +# Saving the checksum of original table |
746 | +checksum_a=`checksum_table test test` |
747 | + |
748 | +# Take a backup |
749 | +mkdir -p $topdir/backup |
750 | +innobackupex --stream=tar --include='test.test$' $topdir/backup > $topdir/backup/backup.tar |
751 | +$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup |
752 | +$TAR cvhf $topdir/backup/backup11.tar $mysql_datadir/test/* |
753 | + |
754 | +innobackupex --apply-log $topdir/backup |
755 | + |
756 | +vlog "Backup taken" |
757 | + |
758 | +stop_server |
759 | + |
760 | +# Restore partial backup |
761 | +ib_part_restore $topdir $mysql_datadir |
762 | + |
763 | +start_server |
764 | + |
765 | +ib_part_assert_checksum $checksum_a |
766 | |
767 | === added file 'test/t/ib_part_tf_innodb.sh' |
768 | --- test/t/ib_part_tf_innodb.sh 1970-01-01 00:00:00 +0000 |
769 | +++ test/t/ib_part_tf_innodb.sh 2013-01-02 16:10:36 +0000 |
770 | @@ -0,0 +1,46 @@ |
771 | +######################################################################## |
772 | +# Bug #711166: Partitioned tables are not correctly handled by the |
773 | +# --databases and --tables-file options of innobackupex, |
774 | +# and by the --tables option of xtrabackup. |
775 | +# Testcase covers using --tables-file option with InnoDB |
776 | +# database |
777 | +######################################################################## |
778 | + |
779 | +. inc/common.sh |
780 | +. inc/ib_part.sh |
781 | + |
782 | +start_server --innodb_file_per_table |
783 | + |
784 | +require_partitioning |
785 | + |
786 | +# Create InnoDB partitioned table |
787 | +ib_part_init $topdir InnoDB |
788 | + |
789 | +# Saving the checksum of original table |
790 | +checksum_a=`checksum_table test test` |
791 | + |
792 | +# Take a backup |
793 | +# Only backup of test.test table will be taken |
794 | +cat >$topdir/tables <<EOF |
795 | +test.test |
796 | +EOF |
797 | +innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup |
798 | +innobackupex --apply-log $topdir/backup |
799 | +vlog "Backup taken" |
800 | + |
801 | +COUNT=`xtrabackup --stats --tables-file=$topdir/tables --datadir=$topdir/backup \ |
802 | + | grep table: | awk '{print $2}' | sort -u | wc -l` |
803 | +echo "COUNT = $COUNT" |
804 | +if [ $COUNT != 7 ] ; then |
805 | + vlog "xtrabackup --stats does not work" |
806 | + exit -1 |
807 | +fi |
808 | + |
809 | +stop_server |
810 | + |
811 | +# Restore partial backup |
812 | +ib_part_restore $topdir $mysql_datadir |
813 | + |
814 | +start_server |
815 | + |
816 | +ib_part_assert_checksum $checksum_a |
817 | |
818 | === added file 'test/t/ib_part_tf_innodb_stream.sh' |
819 | --- test/t/ib_part_tf_innodb_stream.sh 1970-01-01 00:00:00 +0000 |
820 | +++ test/t/ib_part_tf_innodb_stream.sh 2013-01-02 16:10:36 +0000 |
821 | @@ -0,0 +1,40 @@ |
822 | +######################################################################## |
823 | +# Bug #711166: Partitioned tables are not correctly handled by the |
824 | +# --databases and --tables-file options of innobackupex, |
825 | +# and by the --tables option of xtrabackup. |
826 | +# Testcase covers using --tables-file option with InnoDB |
827 | +# database and --stream mode |
828 | +######################################################################## |
829 | + |
830 | +. inc/common.sh |
831 | +. inc/ib_part.sh |
832 | + |
833 | +start_server --innodb_file_per_table |
834 | + |
835 | +require_partitioning |
836 | + |
837 | +# Create InnoDB partitioned table |
838 | +ib_part_init $topdir InnoDB |
839 | + |
840 | +# Saving the checksum of original table |
841 | +checksum_a=`checksum_table test test` |
842 | + |
843 | +# Take a backup |
844 | +# Only backup of test.test table will be taken |
845 | +cat >$topdir/tables <<EOF |
846 | +test.test |
847 | +EOF |
848 | +mkdir -p $topdir/backup |
849 | +innobackupex --stream=tar --no-timestamp --tables-file=$topdir/tables $topdir/backup > $topdir/backup/backup.tar |
850 | +$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup |
851 | +innobackupex --apply-log $topdir/backup |
852 | +vlog "Backup taken" |
853 | + |
854 | +stop_server |
855 | + |
856 | +# Restore partial backup |
857 | +ib_part_restore $topdir $mysql_datadir |
858 | + |
859 | +start_server |
860 | + |
861 | +ib_part_assert_checksum $checksum_a |
862 | |
863 | === added file 'test/t/ib_part_tf_myisam.sh' |
864 | --- test/t/ib_part_tf_myisam.sh 1970-01-01 00:00:00 +0000 |
865 | +++ test/t/ib_part_tf_myisam.sh 2013-01-02 16:10:36 +0000 |
866 | @@ -0,0 +1,39 @@ |
867 | +######################################################################## |
868 | +# Bug #711166: Partitioned tables are not correctly handled by the |
869 | +# --databases and --tables-file options of innobackupex, |
870 | +# and by the --tables option of xtrabackup. |
871 | +# Testcase covers using --tables-file option with MyISAM |
872 | +# database |
873 | +######################################################################## |
874 | + |
875 | +. inc/common.sh |
876 | +. inc/ib_part.sh |
877 | + |
878 | +start_server |
879 | + |
880 | +require_partitioning |
881 | + |
882 | +# Create MyISAM partitioned table with some partitions in |
883 | +# different location |
884 | +ib_part_init $topdir MyISAM |
885 | + |
886 | +# Saving the checksum of original table |
887 | +checksum_a=`checksum_table test test` |
888 | + |
889 | +# Take a backup |
890 | +# Only backup of test.test table will be taken |
891 | +cat >$topdir/tables <<EOF |
892 | +test.test |
893 | +EOF |
894 | +innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup |
895 | +innobackupex --apply-log $topdir/backup |
896 | +vlog "Backup taken" |
897 | + |
898 | +stop_server |
899 | + |
900 | +# Restore partial backup |
901 | +ib_part_restore $topdir $mysql_datadir |
902 | + |
903 | +start_server |
904 | + |
905 | +ib_part_assert_checksum $checksum_a |
See comments in https:/ /code.launchpad .net/~sergei. glushchenko/ percona- xtrabackup/ xb20-partial/ +merge/ 136015