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

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 431
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/xb21-bug1038127
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 125 lines (+70/-8)
2 files modified
src/xtrabackup.c (+29/-8)
test/t/bug1038127.sh (+41/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/xb21-bug1038127
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+122661@code.launchpad.net

Description of the change

Merge fix for bug 1038127 from 2.0

To post a comment you must log in.
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

please hold until jenkins build passed

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

The commit is missing the --fixes=lp:123 option.
s/compatable/compatible for the testcase header - applies for 2.0 fix too, not sure if we want to fix this now.

No need for another Jenkins run for these changes.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote :

The --fixes-lp:123 is not required as long as the branch is associated with the bug. It's OK to do it manually.

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

Typo in comment been fixed

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xtrabackup.c'
2--- src/xtrabackup.c 2012-08-03 05:14:45 +0000
3+++ src/xtrabackup.c 2012-09-05 08:37:22 +0000
4@@ -1499,10 +1499,14 @@
5 static my_bool
6 xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info)
7 {
8- FILE *fp;
9- my_bool r= TRUE;
10+ FILE* fp;
11+ char key[51];
12+ char value[51];
13+ my_bool r = TRUE;
14
15- memset(info, 0, sizeof(xb_delta_info_t));
16+ /* set defaults */
17+ info->page_size = ULINT_UNDEFINED;
18+ info->space_id = ULINT_UNDEFINED;
19
20 fp = fopen(filepath, "r");
21 if (!fp) {
22@@ -1510,12 +1514,28 @@
23 return(TRUE);
24 }
25
26- if (fscanf(fp, "page_size = %lu\nspace_id = %lu\n",
27- &info->page_size, &info->space_id) != 2)
28- r= FALSE;
29+ while (!feof(fp)) {
30+ if (fscanf(fp, "%50s = %50s\n", key, value) == 2) {
31+ if (strcmp(key, "page_size") == 0) {
32+ info->page_size = strtoul(value, NULL, 10);
33+ } else if (strcmp(key, "space_id") == 0) {
34+ info->space_id = strtoul(value, NULL, 10);
35+ }
36+ }
37+ }
38
39 fclose(fp);
40
41+ if (info->page_size == ULINT_UNDEFINED) {
42+ msg("xtrabackup: page_size is required in %s\n", filepath);
43+ r = FALSE;
44+ }
45+ if (info->space_id == ULINT_UNDEFINED) {
46+ msg("xtrabackup: Warning: This backup was taken with XtraBackup 2.0.1 "
47+ "or earlier, some DDL operations between full and incremental "
48+ "backups may be handled incorrectly\n");
49+ }
50+
51 return(r);
52 }
53
54@@ -3836,7 +3856,7 @@
55 os_file_t file = 0;
56 ulint tablespace_flags;
57
58- ut_a(dbname || space_id == 0);
59+ ut_a(dbname != NULL || space_id == 0 || space_id == ULINT_UNDEFINED);
60
61 *success = FALSE;
62
63@@ -3870,7 +3890,7 @@
64 mutex_exit(&fil_system->mutex);
65
66 if (fil_space != NULL) {
67- if (fil_space->id == space_id) {
68+ if (fil_space->id == space_id || space_id == ULINT_UNDEFINED) {
69 /* we found matching space */
70 goto found;
71 } else {
72@@ -3894,6 +3914,7 @@
73 }
74
75 mutex_enter(&fil_system->mutex);
76+ ut_a(space_id != ULINT_UNDEFINED);
77 fil_space = xb_space_get_by_id(space_id);
78 mutex_exit(&fil_system->mutex);
79 if (fil_space != NULL) {
80
81=== added file 'test/t/bug1038127.sh'
82--- test/t/bug1038127.sh 1970-01-01 00:00:00 +0000
83+++ test/t/bug1038127.sh 2012-09-05 08:37:22 +0000
84@@ -0,0 +1,41 @@
85+############################################################################
86+# Bug #1038127: XtraBackup 2.0.2 is not backwards compatible
87+# if no space_id found in .meta file, applying delta
88+# to full backup failing
89+############################################################################
90+
91+. inc/common.sh
92+
93+start_server --innodb_file_per_table
94+
95+run_cmd $MYSQL $MYSQL_ARGS test <<EOF
96+CREATE TABLE t1(a INT) ENGINE=InnoDB;
97+INSERT INTO t1 VALUES (1), (2), (3);
98+EOF
99+
100+# Full backup
101+# backup root directory
102+vlog "Starting backup"
103+innobackupex --no-timestamp $topdir/full
104+
105+vlog "Creating incremental backup"
106+
107+innobackupex --incremental --no-timestamp \
108+ --incremental-basedir=$topdir/full $topdir/inc
109+
110+# remove space_id = something line from .meta file
111+sed -ie '/space_id/ d' $topdir/inc/test/t1.ibd.meta
112+
113+vlog "Preparing backup"
114+
115+innobackupex --apply-log --redo-only $topdir/full
116+vlog "Log applied to full backup"
117+
118+innobackupex --apply-log --redo-only --incremental-dir=$topdir/inc \
119+ $topdir/full
120+vlog "Delta applied to full backup"
121+
122+innobackupex --apply-log $topdir/full
123+vlog "Data prepared for restore"
124+
125+grep -q "This backup was taken with XtraBackup 2.0.1" $OUTFILE

Subscribers

People subscribed via source and target branches