Merge lp:~sergei.glushchenko/percona-xtrabackup/xb21-partial into lp:percona-xtrabackup/2.1

Proposed by Sergei Glushchenko
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
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.

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://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.1-param/89/

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Conflicts. 2.1 already has check_if_skip_table, you just need to merge your version with it.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve
Revision history for this message
Stewart Smith (stewart) wrote :

Many test failures when trying to merge: http://jenkins.percona.com/job/merge-XB-2.1-staging/1/

review: Needs Fixing
Revision history for this message
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://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.0-param/312/
http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.1-param/123/

Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve
Revision history for this message
Stewart Smith (stewart) :
review: Approve
Revision history for this message
Stewart Smith (stewart) wrote :

http://jenkins.percona.com/job/merge-XB-2.1-staging/5/BUILD_TYPE=release,Host=centos5-64,xtrabackuptarget=innodb51/
and
http://jenkins.percona.com/job/merge-XB-2.1-staging/4/BUILD_TYPE=release,Host=centos5-64,xtrabackuptarget=innodb51/

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_fast_shutdown = 1
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

review: Needs Fixing
Revision history for this message
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.

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.1-param/133/BUILD_TYPE=release,Host=centos5-64,xtrabackuptarget=innodb51/

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'innobackupex'
--- innobackupex 2013-01-02 04:23:18 +0000
+++ innobackupex 2013-01-02 16:10:36 +0000
@@ -1992,7 +1992,8 @@
1992 next unless check_if_required($database, $file);1992 next unless check_if_required($database, $file);
19931993
1994 if($option_include) {1994 if($option_include) {
1995 if (!("$database.$file" =~ /$option_include/)) {1995 my $table_name = get_table_name($file);
1996 if (!("$database.$table_name" =~ /$option_include/)) {
1996 print STDERR "$database.$file is skipped because it does not match $option_include.\n";1997 print STDERR "$database.$file is skipped because it does not match $option_include.\n";
1997 next;1998 next;
1998 }1999 }
@@ -2314,6 +2315,26 @@
2314 return ${$group_hash_ref}{$option_name};2315 return ${$group_hash_ref}{$option_name};
2315}2316}
23162317
2318# get_table_name subroutine returns table name of specified file.
2319# Parameters:
2320# $_[0] table path
2321# Return value:
2322# 1 table name
2323#
2324sub get_table_name {
2325 my $table_path = shift;
2326 my $filename;
2327 my $table;
2328
2329 # get the last component in the table pathname
2330 $filename = (reverse(split(/\//, $table_path)))[0];
2331 # get name of the table by removing file suffix
2332 $table = (split(/\./, $filename))[0];
2333 # and partition suffix
2334 $table = (split('#P#', $table))[0];
2335
2336 return $table;
2337}
23172338
2318# check_if_required subroutine returns 1 if the specified database and2339# check_if_required subroutine returns 1 if the specified database and
2319# table needs to be backed up.2340# table needs to be backed up.
@@ -2327,7 +2348,6 @@
2327 my ( $db, $table_path ) = @_;2348 my ( $db, $table_path ) = @_;
2328 my $db_count = scalar keys %databases_list;2349 my $db_count = scalar keys %databases_list;
2329 my $tbl_count = scalar keys %table_list;2350 my $tbl_count = scalar keys %table_list;
2330 my $filename;
2331 my $table;2351 my $table;
23322352
2333 if ( $db_count == 0 && $tbl_count == 0 ) {2353 if ( $db_count == 0 && $tbl_count == 0 ) {
@@ -2337,10 +2357,7 @@
2337 }2357 }
2338 else {2358 else {
2339 if ( $table_path ) {2359 if ( $table_path ) {
2340 # get the last component in the table pathname 2360 $table = get_table_name($table_path);
2341 $filename = (reverse(split(/\//, $table_path)))[0];
2342 # get name of the table by removing file suffix
2343 $table = (split(/\./, $filename))[0];
2344 }2361 }
2345 }2362 }
23462363
23472364
=== modified file 'src/xtrabackup.c'
--- src/xtrabackup.c 2012-11-21 13:51:49 +0000
+++ src/xtrabackup.c 2013-01-02 16:10:36 +0000
@@ -1509,71 +1509,71 @@
1509my_bool1509my_bool
1510check_if_skip_table(1510check_if_skip_table(
1511/******************/1511/******************/
1512 char* path) /*!< in: path to the table */1512 char* path, /*!< in: path to the table */
1513 char* suffix) /*!< in: suffix */
1513{1514{
1514 char* p = path;1515 char buf[FN_REFLEN];
1515 char* next;1516 const char *dbname, *tbname;
1516 char* prev = NULL;1517 const char *ptr;
1517 int p_len;1518 char *eptr;
1518 int regres = REG_NOMATCH;1519 int dbname_len;
1519 char tmp;
1520 int i;
15211520
1522 if (xtrabackup_tables == NULL && xtrabackup_tables_file == NULL) {1521 if (xtrabackup_tables == NULL && xtrabackup_tables_file == NULL) {
1523 return(FALSE);1522 return(FALSE);
1524 }1523 }
15251524
1526 while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL)1525 dbname = NULL;
1527 {1526 tbname = path;
1528 prev = p;1527 while ((ptr = strstr(tbname, SRV_PATH_SEPARATOR_STR)) != NULL) {
1529 p = next + 1;1528 dbname = tbname;
1530 }1529 tbname = ptr + 1;
1531 p_len = strlen(p) - sizeof(".ibd") + 1;1530 }
15321531
1533 if (p_len < 1) {1532 if (dbname == NULL) {
1534 /* shouldn't happen with a valid path, assume the1533 return(FALSE);
1535 table should not be filtered */1534 }
1536 return(FALSE);1535
1537 }1536 strncpy(buf, dbname, FN_REFLEN);
15381537 buf[FN_REFLEN - 1] = 0;
1539 /* Make "database.table" string */1538 buf[tbname - 1 - dbname] = '.';
1540 tmp = p[p_len];1539
1541 p[p_len] = 0;1540 dbname_len = strlen(dbname) - strlen(suffix);
1542 *(p - 1) = '.';1541 if (dbname_len < 1) {
1542 return(FALSE);
1543 }
1544 buf[dbname_len - 1] = 0;
1545
1546 if ((eptr = strstr(buf, "#P#")) != NULL) {
1547 *eptr = 0;
1548 }
15431549
1544 if (xtrabackup_tables) {1550 if (xtrabackup_tables) {
1551 int regres = REG_NOMATCH;
1552 int i;
1545 for (i = 0; i < tables_regex_num; i++) {1553 for (i = 0; i < tables_regex_num; i++) {
1546 regres = xb_regexec(&tables_regex[i], prev, 1,1554 regres = xb_regexec(&tables_regex[i], buf, 1,
1547 tables_regmatch, 0);1555 tables_regmatch, 0);
1548 if (regres != REG_NOMATCH) {1556 if (regres != REG_NOMATCH) {
1549 break;1557 break;
1550 }1558 }
1551 }1559 }
1552 if (regres == REG_NOMATCH) {1560 if (regres == REG_NOMATCH) {
1553 goto skip;1561 return(TRUE);
1554 }1562 }
1555 }1563 }
15561564
1557 if (xtrabackup_tables_file) {1565 if (xtrabackup_tables_file) {
1558 xtrabackup_tables_t* table;1566 xtrabackup_tables_t* table;
15591567
1560 *(p - 1) = SRV_PATH_SEPARATOR;1568 XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(buf),
1561 XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(prev),
1562 table, ut_ad(table->name),1569 table, ut_ad(table->name),
1563 !strcmp(table->name, prev));1570 !strcmp(table->name, buf));
1564 if (!table) {1571 if (!table) {
1565 goto skip;1572 return(TRUE);
1566 }1573 }
1567 }1574 }
15681575
1569 p[p_len] = tmp;
1570 *(p - 1) = SRV_PATH_SEPARATOR;
1571 return(FALSE);1576 return(FALSE);
1572
1573skip:
1574 p[p_len] = tmp;
1575 *(p - 1) = SRV_PATH_SEPARATOR;
1576 return(TRUE);
1577}1577}
15781578
1579/***********************************************************************1579/***********************************************************************
@@ -1619,7 +1619,7 @@
1619 xb_write_filt_ctxt_t write_filt_ctxt;1619 xb_write_filt_ctxt_t write_filt_ctxt;
16201620
1621 if (!trx_sys_sys_space(node->space->id) && /* don't skip system space */1621 if (!trx_sys_sys_space(node->space->id) && /* don't skip system space */
1622 check_if_skip_table(node->name)) {1622 check_if_skip_table(node->name, "ibd")) {
1623 msg("[%02u] Skipping %s\n", thread_n, node->name);1623 msg("[%02u] Skipping %s\n", thread_n, node->name);
1624 return(FALSE);1624 return(FALSE);
1625 }1625 }
@@ -2341,6 +2341,129 @@
2341 return(FALSE);2341 return(FALSE);
2342}2342}
23432343
2344static
2345void
2346xb_filters_init()
2347{
2348 if (xtrabackup_tables) {
2349 /* init regexp */
2350 char *p, *next;
2351 int i;
2352 char errbuf[100];
2353
2354 tables_regex_num = 1;
2355
2356 p = xtrabackup_tables;
2357 while ((p = strchr(p, ',')) != NULL) {
2358 p++;
2359 tables_regex_num++;
2360 }
2361
2362 tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num);
2363
2364 p = xtrabackup_tables;
2365 for (i=0; i < tables_regex_num; i++) {
2366 next = strchr(p, ',');
2367 ut_a(next || i == tables_regex_num - 1);
2368
2369 next++;
2370 if (i != tables_regex_num - 1)
2371 *(next - 1) = '\0';
2372
2373 xb_regerror(xb_regcomp(&tables_regex[i], p,
2374 REG_EXTENDED),
2375 &tables_regex[i], errbuf, sizeof(errbuf));
2376 msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf);
2377
2378 if (i != tables_regex_num - 1)
2379 *(next - 1) = ',';
2380 p = next;
2381 }
2382 }
2383
2384 if (xtrabackup_tables_file) {
2385 char name_buf[NAME_LEN*2+2];
2386 FILE *fp;
2387
2388 name_buf[NAME_LEN*2+1] = '\0';
2389
2390 /* init tables_hash */
2391 tables_hash = hash_create(1000);
2392
2393 /* read and store the filenames */
2394 fp = fopen(xtrabackup_tables_file,"r");
2395 if (!fp) {
2396 msg("xtrabackup: cannot open %s\n",
2397 xtrabackup_tables_file);
2398 exit(EXIT_FAILURE);
2399 }
2400 for (;;) {
2401 xtrabackup_tables_t* table;
2402 char* p = name_buf;
2403
2404 if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) {
2405 break;
2406 }
2407
2408 p = strchr(name_buf, '\n');
2409 if (p)
2410 {
2411 *p = '\0';
2412 }
2413
2414 table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
2415 memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
2416 table->name = ((char*)table) + sizeof(xtrabackup_tables_t);
2417 strcpy(table->name, name_buf);
2418
2419 HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash,
2420 ut_fold_string(table->name), table);
2421
2422 msg("xtrabackup: table '%s' is registered to the "
2423 "list.\n", table->name);
2424 }
2425 }
2426}
2427
2428static
2429void
2430xb_filters_free()
2431{
2432 if (xtrabackup_tables) {
2433 /* free regexp */
2434 int i;
2435
2436 for (i = 0; i < tables_regex_num; i++) {
2437 xb_regfree(&tables_regex[i]);
2438 }
2439 ut_free(tables_regex);
2440 }
2441
2442 if (xtrabackup_tables_file) {
2443 ulint i;
2444
2445 /* free the hash elements */
2446 for (i = 0; i < hash_get_n_cells(tables_hash); i++) {
2447 xtrabackup_tables_t* table;
2448
2449 table = HASH_GET_FIRST(tables_hash, i);
2450
2451 while (table) {
2452 xtrabackup_tables_t* prev_table = table;
2453
2454 table = HASH_GET_NEXT(name_hash, prev_table);
2455
2456 HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash,
2457 ut_fold_string(prev_table->name), prev_table);
2458 free(prev_table);
2459 }
2460 }
2461
2462 /* free tables_hash */
2463 hash_table_free(tables_hash);
2464 }
2465}
2466
2344static void2467static void
2345xtrabackup_backup_func(void)2468xtrabackup_backup_func(void)
2346{2469{
@@ -2451,6 +2574,8 @@
2451 os_sync_mutex = NULL;2574 os_sync_mutex = NULL;
2452 srv_general_init();2575 srv_general_init();
24532576
2577 xb_filters_init();
2578
2454 {2579 {
2455 ibool log_file_created;2580 ibool log_file_created;
2456 ibool log_created = FALSE;2581 ibool log_created = FALSE;
@@ -2782,6 +2907,8 @@
2782 msg("xtrabackup: Transaction log of lsn (%llu) to (%llu) was copied.\n",2907 msg("xtrabackup: Transaction log of lsn (%llu) to (%llu) was copied.\n",
2783 checkpoint_lsn_start, log_copy_scanned_lsn);2908 checkpoint_lsn_start, log_copy_scanned_lsn);
27842909
2910 xb_filters_free();
2911
2785 xb_data_files_close();2912 xb_data_files_close();
2786}2913}
27872914
@@ -3066,6 +3193,8 @@
3066 if(innodb_init())3193 if(innodb_init())
3067 exit(EXIT_FAILURE);3194 exit(EXIT_FAILURE);
30683195
3196 xb_filters_init();
3197
3069 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");3198 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");
30703199
3071 /* gather stats */3200 /* gather stats */
@@ -3140,43 +3269,8 @@
3140 mem_free(table_name);3269 mem_free(table_name);
31413270
31423271
3143 if (xtrabackup_tables) {3272 if (table && check_if_skip_table(table->name, ""))
3144 char *p;3273 goto skip;
3145 int regres = REG_NOMATCH;
3146 int i;
3147
3148 p = strstr(table->name, SRV_PATH_SEPARATOR_STR);
3149
3150 if (p)
3151 *p = '.';
3152
3153 for (i = 0; i < tables_regex_num; i++) {
3154 regres = xb_regexec(&tables_regex[i],
3155 table->name, 1,
3156 tables_regmatch, 0);
3157 if (regres != REG_NOMATCH)
3158 break;
3159 }
3160
3161 if (p)
3162 *p = SRV_PATH_SEPARATOR;
3163
3164 if ( regres == REG_NOMATCH )
3165 goto skip;
3166 }
3167
3168 if (xtrabackup_tables_file) {
3169 xtrabackup_tables_t* xtable;
3170
3171 XB_HASH_SEARCH(name_hash, tables_hash,
3172 ut_fold_string(table->name),
3173 xtable,
3174 ut_ad(xtable->name),
3175 !strcmp(xtable->name, table->name));
3176
3177 if (!xtable)
3178 goto skip;
3179 }
31803274
31813275
3182 if (table == NULL) {3276 if (table == NULL) {
@@ -3272,6 +3366,8 @@
3272end:3366end:
3273 putc('\n', stdout);3367 putc('\n', stdout);
32743368
3369 xb_filters_free();
3370
3275 /* shutdown InnoDB */3371 /* shutdown InnoDB */
3276 if(innodb_end())3372 if(innodb_end())
3277 exit(EXIT_FAILURE);3373 exit(EXIT_FAILURE);
@@ -4695,91 +4791,6 @@
4695 my_load_path(xtrabackup_real_target_dir, xtrabackup_target_dir, NULL);4791 my_load_path(xtrabackup_real_target_dir, xtrabackup_target_dir, NULL);
4696 xtrabackup_target_dir= xtrabackup_real_target_dir;4792 xtrabackup_target_dir= xtrabackup_real_target_dir;
46974793
4698 if (xtrabackup_tables) {
4699 /* init regexp */
4700 char *p, *next;
4701 int i;
4702 char errbuf[100];
4703
4704 tables_regex_num = 1;
4705
4706 p = xtrabackup_tables;
4707 while ((p = strchr(p, ',')) != NULL) {
4708 p++;
4709 tables_regex_num++;
4710 }
4711
4712 tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num);
4713
4714 p = xtrabackup_tables;
4715 for (i=0; i < tables_regex_num; i++) {
4716 next = strchr(p, ',');
4717 ut_a(next || i == tables_regex_num - 1);
4718
4719 next++;
4720 if (i != tables_regex_num - 1)
4721 *(next - 1) = '\0';
4722
4723 xb_regerror(xb_regcomp(&tables_regex[i], p,
4724 REG_EXTENDED),
4725 &tables_regex[i], errbuf, sizeof(errbuf));
4726 msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf);
4727
4728 if (i != tables_regex_num - 1)
4729 *(next - 1) = ',';
4730 p = next;
4731 }
4732 }
4733
4734 if (xtrabackup_tables_file) {
4735 char name_buf[NAME_LEN*2+2];
4736 FILE *fp;
4737
4738 name_buf[NAME_LEN*2+1] = '\0';
4739
4740 /* init tables_hash */
4741 tables_hash = hash_create(1000);
4742
4743 /* read and store the filenames */
4744 fp = fopen(xtrabackup_tables_file,"r");
4745 if (!fp) {
4746 msg("xtrabackup: cannot open %s\n",
4747 xtrabackup_tables_file);
4748 exit(EXIT_FAILURE);
4749 }
4750 for (;;) {
4751 xtrabackup_tables_t* table;
4752 char* p = name_buf;
4753
4754 if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) {
4755 break;
4756 }
4757
4758 while (*p != '\0') {
4759 if (*p == '.') {
4760 *p = '/';
4761 }
4762 p++;
4763 }
4764 p = strchr(name_buf, '\n');
4765 if (p)
4766 {
4767 *p = '\0';
4768 }
4769
4770 table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
4771 memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
4772 table->name = ((char*)table) + sizeof(xtrabackup_tables_t);
4773 strcpy(table->name, name_buf);
4774
4775 HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash,
4776 ut_fold_string(table->name), table);
4777
4778 msg("xtrabackup: table '%s' is registered to the "
4779 "list.\n", table->name);
4780 }
4781 }
4782
4783#ifdef XTRADB_BASED4794#ifdef XTRADB_BASED
4784 /* temporary setting of enough size */4795 /* temporary setting of enough size */
4785 srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX;4796 srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX;
@@ -4933,40 +4944,6 @@
4933 if (xtrabackup_prepare)4944 if (xtrabackup_prepare)
4934 xtrabackup_prepare_func();4945 xtrabackup_prepare_func();
49354946
4936 if (xtrabackup_tables) {
4937 /* free regexp */
4938 int i;
4939
4940 for (i = 0; i < tables_regex_num; i++) {
4941 xb_regfree(&tables_regex[i]);
4942 }
4943 ut_free(tables_regex);
4944 }
4945
4946 if (xtrabackup_tables_file) {
4947 ulint i;
4948
4949 /* free the hash elements */
4950 for (i = 0; i < hash_get_n_cells(tables_hash); i++) {
4951 xtrabackup_tables_t* table;
4952
4953 table = HASH_GET_FIRST(tables_hash, i);
4954
4955 while (table) {
4956 xtrabackup_tables_t* prev_table = table;
4957
4958 table = HASH_GET_NEXT(name_hash, prev_table);
4959
4960 HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash,
4961 ut_fold_string(prev_table->name), prev_table);
4962 free(prev_table);
4963 }
4964 }
4965
4966 /* free tables_hash */
4967 hash_table_free(tables_hash);
4968 }
4969
4970 xb_regex_end();4947 xb_regex_end();
49714948
4972 exit(EXIT_SUCCESS);4949 exit(EXIT_SUCCESS);
49734950
=== added file 'test/inc/ib_part.sh'
--- test/inc/ib_part.sh 1970-01-01 00:00:00 +0000
+++ test/inc/ib_part.sh 2013-01-02 16:10:36 +0000
@@ -0,0 +1,92 @@
1
2
3function check_partitioning()
4{
5 $MYSQL $MYSQL_ARGS -Ns -e "show variables like 'have_partitioning'"
6}
7
8function require_partitioning()
9{
10 PARTITION_CHECK=`check_partitioning`
11
12 if [ -z "$PARTITION_CHECK" ]; then
13 echo "Requires Partitioning." > $SKIPPED_REASON
14 exit $SKIPPED_EXIT_CODE
15 fi
16}
17
18function ib_part_schema()
19{
20 topdir=$1
21 engine=$2
22
23 cat <<EOF
24CREATE TABLE test (
25 a int(11) DEFAULT NULL
26) ENGINE=$engine DEFAULT CHARSET=latin1
27PARTITION BY RANGE (a)
28(PARTITION p0 VALUES LESS THAN (100) ENGINE = $engine,
29 PARTITION P1 VALUES LESS THAN (200) ENGINE = $engine,
30 PARTITION p2 VALUES LESS THAN (300)
31 DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
32 ENGINE = $engine,
33 PARTITION p3 VALUES LESS THAN (400)
34 DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
35 ENGINE = $engine,
36 PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = $engine);
37EOF
38}
39
40function ib_part_data()
41{
42 echo 'INSERT INTO test VALUES (1), (101), (201), (301), (401);';
43}
44
45function ib_part_init()
46{
47 topdir=$1
48 engine=$2
49
50 if [ -d $topdir/ext ] ; then
51 rm -rf $topdir/ext
52 fi
53 mkdir -p $topdir/ext
54
55 ib_part_schema $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test
56 ib_part_data $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test
57}
58
59function ib_part_restore()
60{
61 topdir=$1
62 mysql_datadir=$2
63
64 # Remove database
65 rm -rf $mysql_datadir/test/*
66 rm -rf $topdir/ext/*
67 vlog "Original database removed"
68
69 # Restore database from backup
70 cp -rv $topdir/backup/test/* $mysql_datadir/test
71 vlog "database restored from backup"
72
73}
74
75function ib_part_assert_checksum()
76{
77 checksum_a=$1
78
79 vlog "Checking checksums"
80 checksum_b=`checksum_table test test`
81
82 vlog "Checksums are $checksum_a and $checksum_b"
83
84 if [ "$checksum_a" != "$checksum_b" ]
85 then
86 vlog "Checksums are not equal"
87 exit -1
88 fi
89
90 vlog "Checksums are OK"
91
92}
093
=== added file 'test/t/ib_part_databases.sh'
--- test/t/ib_part_databases.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_databases.sh 2013-01-02 16:10:36 +0000
@@ -0,0 +1,39 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --databases option with MyISAM
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server
13
14require_partitioning
15
16# Create MyISAM partitioned table with some partitions in
17# different location
18ib_part_init $topdir MyISAM
19
20# Saving the checksum of original table
21checksum_a=`checksum_table test test`
22
23# Take a backup
24cat >$topdir/databases_file <<EOF
25test.test
26EOF
27innobackupex --no-timestamp --databases=$topdir/databases_file $topdir/backup
28innobackupex --apply-log $topdir/backup
29vlog "Backup taken"
30
31stop_server
32
33# Restore partial backup
34ib_part_restore $topdir $mysql_datadir
35
36start_server
37
38# compare checksum
39ib_part_assert_checksum $checksum_a
040
=== added file 'test/t/ib_part_include.sh'
--- test/t/ib_part_include.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_include.sh 2013-01-02 16:10:36 +0000
@@ -0,0 +1,47 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --include option with InnoDB
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create InnoDB partitioned table
17ib_part_init $topdir InnoDB
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23# Only backup of test.test table will be taken
24cat >$topdir/tables <<EOF
25test.test
26EOF
27innobackupex --no-timestamp --include='test.test$' $topdir/backup
28innobackupex --apply-log $topdir/backup
29vlog "Backup taken"
30
31# also test xtrabackup --stats work with --tables-file
32COUNT=`xtrabackup --stats --tables='test.test$' --datadir=$topdir/backup \
33 | grep table: | awk '{print $2}' | sort -u | wc -l`
34
35if [ $COUNT != 7 ] ; then
36 vlog "xtrabackup --stats does not work"
37 exit -1
38fi
39
40stop_server
41
42# Restore partial backup
43ib_part_restore $topdir $mysql_datadir
44
45start_server
46
47ib_part_assert_checksum $checksum_a
048
=== added file 'test/t/ib_part_include_stream.sh'
--- test/t/ib_part_include_stream.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_include_stream.sh 2013-01-02 16:10:36 +0000
@@ -0,0 +1,39 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --include option with InnoDB
6# database and --stream mode
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create MyISAM partitioned table
17ib_part_init $topdir MyISAM
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23mkdir -p $topdir/backup
24innobackupex --stream=tar --include='test.test$' $topdir/backup > $topdir/backup/backup.tar
25$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup
26$TAR cvhf $topdir/backup/backup11.tar $mysql_datadir/test/*
27
28innobackupex --apply-log $topdir/backup
29
30vlog "Backup taken"
31
32stop_server
33
34# Restore partial backup
35ib_part_restore $topdir $mysql_datadir
36
37start_server
38
39ib_part_assert_checksum $checksum_a
040
=== added file 'test/t/ib_part_tf_innodb.sh'
--- test/t/ib_part_tf_innodb.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_tf_innodb.sh 2013-01-02 16:10:36 +0000
@@ -0,0 +1,46 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --tables-file option with InnoDB
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create InnoDB partitioned table
17ib_part_init $topdir InnoDB
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23# Only backup of test.test table will be taken
24cat >$topdir/tables <<EOF
25test.test
26EOF
27innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup
28innobackupex --apply-log $topdir/backup
29vlog "Backup taken"
30
31COUNT=`xtrabackup --stats --tables-file=$topdir/tables --datadir=$topdir/backup \
32 | grep table: | awk '{print $2}' | sort -u | wc -l`
33echo "COUNT = $COUNT"
34if [ $COUNT != 7 ] ; then
35 vlog "xtrabackup --stats does not work"
36 exit -1
37fi
38
39stop_server
40
41# Restore partial backup
42ib_part_restore $topdir $mysql_datadir
43
44start_server
45
46ib_part_assert_checksum $checksum_a
047
=== added file 'test/t/ib_part_tf_innodb_stream.sh'
--- test/t/ib_part_tf_innodb_stream.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_tf_innodb_stream.sh 2013-01-02 16:10:36 +0000
@@ -0,0 +1,40 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --tables-file option with InnoDB
6# database and --stream mode
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create InnoDB partitioned table
17ib_part_init $topdir InnoDB
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23# Only backup of test.test table will be taken
24cat >$topdir/tables <<EOF
25test.test
26EOF
27mkdir -p $topdir/backup
28innobackupex --stream=tar --no-timestamp --tables-file=$topdir/tables $topdir/backup > $topdir/backup/backup.tar
29$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup
30innobackupex --apply-log $topdir/backup
31vlog "Backup taken"
32
33stop_server
34
35# Restore partial backup
36ib_part_restore $topdir $mysql_datadir
37
38start_server
39
40ib_part_assert_checksum $checksum_a
041
=== added file 'test/t/ib_part_tf_myisam.sh'
--- test/t/ib_part_tf_myisam.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_tf_myisam.sh 2013-01-02 16:10:36 +0000
@@ -0,0 +1,39 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --tables-file option with MyISAM
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server
13
14require_partitioning
15
16# Create MyISAM partitioned table with some partitions in
17# different location
18ib_part_init $topdir MyISAM
19
20# Saving the checksum of original table
21checksum_a=`checksum_table test test`
22
23# Take a backup
24# Only backup of test.test table will be taken
25cat >$topdir/tables <<EOF
26test.test
27EOF
28innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup
29innobackupex --apply-log $topdir/backup
30vlog "Backup taken"
31
32stop_server
33
34# Restore partial backup
35ib_part_restore $topdir $mysql_datadir
36
37start_server
38
39ib_part_assert_checksum $checksum_a

Subscribers

People subscribed via source and target branches