Merge lp:~sergei.glushchenko/percona-xtrabackup/xb20-bug1038127 into lp:percona-xtrabackup/2.0

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 466
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/xb20-bug1038127
Merge into: lp:percona-xtrabackup/2.0
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/xb20-bug1038127
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Laurynas Biveinis (community) Approve
Review via email: mp+121360@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) :
review: Approve
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Some comments on the fix and the test case:

  I think we should print a warning when space_id is not found in the
  metadata file, something along the lines of "This backup was taken
  with XtraBackup 2.0.1 or earlier, some DDL operations between full and
  incremental backups may be handled incorrectly".

  The if() statements in xb_read_delta_metadata() should really be "if
  () else ...". And InnoDB code uses braces around single-statement
  blocks.

  In the test case:

  - there's no need to do --copy-back, restart the server and calculate
    checksums. The test case must verify that prepare on specially
    formatted .delta files does not fail (and possibly issues a warning)
  - the "Inserting more data" step is meaningless, it doesn't affect the
    deltas, as there will be no changes in the data
  - there's no need for 'ls -al ..'
  - the construct with 'mv ...; grep ...' is equivalent to:

    sed -ie 's/space_id/ d' $topdir/inc/test/t1.ibd.meta

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

All comments were taken into attention.

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

The "inserting more data" step pointed out by Alexey is still there.

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

> The "inserting more data" step pointed out by Alexey is still there.
Ah, You're right!

Alexey, what do you mean by telling that inserting data does not make changes to data and does not affect delta? I can see opposite situation.

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

On 03.09.12 15:51, Sergei Glushchenko wrote:
>> The "inserting more data" step pointed out by Alexey is still there.
> Ah, You're right!
>
> Alexey, what do you mean by telling that inserting data does not make changes to data and does not affect delta? I can see opposite situation.
>

I mean that those 3 rows inserted after the full backup will be in redo
log, but not on disk and thus, not in delta. See bug #1021249.

The purpose of this test case is to make sure incremental apply doesn't
fail when space_id in .meta is missing. So it doesn't really matter if
the "inserting more data" step has any effect. That is, it can be
removed as it doesn't add anything to the test case objectives.

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

> I mean that those 3 rows inserted after the full backup will be in redo
> log, but not on disk and thus, not in delta. See bug #1021249.
>
I see. It depends on environment.

> The purpose of this test case is to make sure incremental apply doesn't
> fail when space_id in .meta is missing. So it doesn't really matter if
> the "inserting more data" step has any effect. That is, it can be
> removed as it doesn't add anything to the test case objectives.

The very first version of testcase also verified checksums in order to make sure that
matching by name worked correctly in this case. But now it really doesn't make sense.

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

Stage "insering more data" been completely removed.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) :
review: Approve
Revision history for this message
Alexey Kopytov (akopytov) :
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-02 04:21:33 +0000
3+++ src/xtrabackup.c 2012-09-05 08:34:20 +0000
4@@ -2848,10 +2848,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@@ -2859,12 +2863,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@@ -5657,7 +5677,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@@ -5691,7 +5711,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@@ -5715,6 +5735,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:34:20 +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