Merge lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.1 into lp:percona-xtrabackup/2.1

Proposed by Laurynas Biveinis on 2012-08-01
Status: Merged
Approved by: Stewart Smith on 2012-08-03
Approved revision: 416
Merged at revision: 416
Proposed branch: lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.1
Merge into: lp:percona-xtrabackup/2.1
Prerequisite: lp:~sergei.glushchenko/percona-xtrabackup/xb21-bug932623
Diff against target: 168 lines (+118/-3)
3 files modified
src/write_filt.c (+18/-1)
src/xtrabackup.c (+7/-2)
test/t/bug1022562.sh (+93/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-xtrabackup/bug1022562-2.1
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2012-08-01 Approve on 2012-08-03
Review via email: mp+117603@code.launchpad.net

Description of the change

Merge fix for bug 1022562 (Inc backup fails if a tablespace is created
between full and inc backups).

The code is different from 2.0: add a new function wf_common_filter()
in write_filt.c that provides page-offset-based filtering that is
common for all write filters.

Jenkins (with follow-up branches included): http://jenkins.percona.com/job/percona-xtrabackup-2.1-param/35/
Issue #16274

To post a comment you must log in.
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/write_filt.c'
--- src/write_filt.c 2012-08-01 10:18:22 +0000
+++ src/write_filt.c 2012-08-01 10:18:22 +0000
@@ -23,6 +23,7 @@
23/* Page write filters implementation */23/* Page write filters implementation */
2424
25#include <my_base.h>25#include <my_base.h>
26#include <fil0fil.h>
26#include <ut0mem.h>27#include <ut0mem.h>
27#include "common.h"28#include "common.h"
28#include "innodb_int.h"29#include "innodb_int.h"
@@ -31,6 +32,21 @@
31#include "xtrabackup.h"32#include "xtrabackup.h"
3233
33/************************************************************************34/************************************************************************
35The common tablespace-offset-based page filter. This is a subroutine for all
36other filters that will select additional pages to be written by their
37tablespace position, regardless of the main filter logic.
38
39@return TRUE if the page with given id should be selected, FALSE otherwise. */
40static my_bool wf_common_filter(ulint offset) {
41 /* We always copy the 1st FIL_IBD_INITIAL_SIZE *
42 UNIV_PAGE_SIZE bytes of any tablespace. These pages are
43 guaranteed to be flushed upon tablespace create and they are
44 needed so that we have a good minimal tablespace image before
45 doing anything further with it. */
46 return (offset < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE);
47}
48
49/************************************************************************
34Write-through page write filter. */50Write-through page write filter. */
35static my_bool wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,51static my_bool wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
36 xb_fil_cur_t *cursor);52 xb_fil_cur_t *cursor);
@@ -136,7 +152,8 @@
136 for (i = 0, page = cursor->buf; i < cursor->buf_npages;152 for (i = 0, page = cursor->buf; i < cursor->buf_npages;
137 i++, page += page_size) {153 i++, page += page_size) {
138 if (ut_dulint_cmp(incremental_lsn,154 if (ut_dulint_cmp(incremental_lsn,
139 MACH_READ_64(page + FIL_PAGE_LSN)) >= 0) {155 MACH_READ_64(page + FIL_PAGE_LSN)) >= 0
156 && !wf_common_filter(cursor->buf_offset + i * page_size)) {
140 continue;157 continue;
141 }158 }
142159
143160
=== modified file 'src/xtrabackup.c'
--- src/xtrabackup.c 2012-08-01 10:18:22 +0000
+++ src/xtrabackup.c 2012-08-01 10:18:22 +0000
@@ -3802,7 +3802,7 @@
3802in given directory. When matching tablespace found, renames it to match the3802in given directory. When matching tablespace found, renames it to match the
3803name of .delta file. If there was a tablespace with matching name and3803name of .delta file. If there was a tablespace with matching name and
3804mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no3804mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
3805matching file, creates the new one.3805matching file, creates a placeholder for the new tablespace.
3806@return file handle of matched or created file */3806@return file handle of matched or created file */
3807static3807static
3808os_file_t3808os_file_t
@@ -3901,7 +3901,12 @@
3901 goto found;3901 goto found;
3902 }3902 }
39033903
3904 /* no matching space found. create the new one */3904 /* No matching space found. create the new one. Note that this is not
3905 a full-fledged tablespace create, as done by
3906 fil_create_new_single_table_tablespace(): the minumum tablespace size
3907 is not ensured and the 1st page fields are not set. We rely on backup
3908 delta to contain the 1st FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
3909 to ensure the correct tablespace image. */
39053910
3906#ifdef INNODB_VERSION_SHORT3911#ifdef INNODB_VERSION_SHORT
3907 if (!fil_space_create(dest_space_name, space_id,3912 if (!fil_space_create(dest_space_name, space_id,
39083913
=== added file 'test/t/bug1022562.sh'
--- test/t/bug1022562.sh 1970-01-01 00:00:00 +0000
+++ test/t/bug1022562.sh 2012-08-01 10:18:22 +0000
@@ -0,0 +1,93 @@
1. inc/common.sh
2
3mysqld_additional_args="--innodb_file_per_table"
4
5start_server ${mysqld_additional_args}
6
7load_dbase_schema incremental_sample
8
9# Full backup
10
11# Full backup folder
12rm -rf $topdir/data/full
13mkdir -p $topdir/data/full
14# Incremental data
15rm -rf $topdir/data/delta
16mkdir -p $topdir/data/delta
17
18vlog "Starting backup"
19
20xtrabackup --datadir=$mysql_datadir --backup --target-dir=$topdir/data/full \
21 $mysqld_additional_args
22
23vlog "Full backup done"
24
25# Changing data in sakila
26
27vlog "Making changes to database"
28
29${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t2 (a INT(11) DEFAULT NULL, \
30 number INT(11) DEFAULT NULL) ENGINE=INNODB" incremental_sample
31${MYSQL} ${MYSQL_ARGS} -e "INSERT INTO t2 VALUES (1, 1)" incremental_sample
32
33vlog "Changes done"
34
35# Saving the checksum of original table
36checksum_t2_a=`checksum_table incremental_sample t2`
37
38vlog "Table 't2' checksum is $checksum_t2_a"
39
40vlog "Making incremental backup"
41
42# Incremental backup
43xtrabackup --datadir=$mysql_datadir --backup \
44 --target-dir=$topdir/data/delta --incremental-basedir=$topdir/data/full \
45 $mysqld_additional_args
46
47vlog "Incremental backup done"
48vlog "Preparing backup"
49
50# Prepare backup
51xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
52 --target-dir=$topdir/data/full $mysqld_additional_args
53vlog "Log applied to backup"
54
55xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
56 --target-dir=$topdir/data/full --incremental-dir=$topdir/data/delta \
57 $mysqld_additional_args
58vlog "Delta applied to backup"
59
60xtrabackup --datadir=$mysql_datadir --prepare --target-dir=$topdir/data/full \
61 $mysqld_additional_args
62vlog "Data prepared for restore"
63
64# removing rows
65${MYSQL} ${MYSQL_ARGS} -e "delete from t2;" incremental_sample
66vlog "Table cleared"
67
68# Restore backup
69
70stop_server
71
72vlog "Copying files"
73
74cd $topdir/data/full/
75cp -r * $mysql_datadir
76cd -
77
78vlog "Data restored"
79
80start_server ${mysqld_additional_args}
81
82vlog "Checking checksums"
83checksum_t2_b=`checksum_table incremental_sample t2`
84
85if [ "$checksum_t2_a" != "$checksum_t2_b" ]
86then
87 vlog "Checksums of table 't2' are not equal"
88 exit -1
89fi
90
91vlog "Checksums are OK"
92
93stop_server

Subscribers

People subscribed via source and target branches