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

Proposed by Laurynas Biveinis on 2012-09-07
Status: Work in progress
Proposed branch: lp:~laurynas-biveinis/percona-xtrabackup/bug1043762-2.1
Merge into: lp:percona-xtrabackup/2.1
Prerequisite: lp:~laurynas-biveinis/percona-xtrabackup/bug1044398-2.1
Diff against target: 179 lines (+99/-33)
2 files modified
src/write_filt.c (+1/-17)
src/xtrabackup.c (+98/-16)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-xtrabackup/bug1043762-2.1
Reviewer Review Type Date Requested Status
Percona core 2012-09-07 Pending
Review via email: mp+123248@code.launchpad.net

Description of the change

To post a comment you must log in.

Unmerged revisions

431. By Laurynas Biveinis on 2012-09-05

Merge fix for bug 1043762 from 2.0.

430. By Laurynas Biveinis on 2012-09-05

Automerge prerequisite lp:~laurynas-biveinis/percona-xtrabackup/bug1044398-2.1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/write_filt.c'
2--- src/write_filt.c 2012-09-07 10:50:24 +0000
3+++ src/write_filt.c 2012-09-07 10:50:24 +0000
4@@ -32,21 +32,6 @@
5 #include "xtrabackup.h"
6
7 /************************************************************************
8-The common tablespace-offset-based page filter. This is a subroutine for all
9-other filters that will select additional pages to be written by their
10-tablespace position, regardless of the main filter logic.
11-
12-@return TRUE if the page with given id should be selected, FALSE otherwise. */
13-static my_bool wf_common_filter(ulint offset) {
14- /* We always copy the 1st FIL_IBD_INITIAL_SIZE *
15- UNIV_PAGE_SIZE bytes of any tablespace. These pages are
16- guaranteed to be flushed upon tablespace create and they are
17- needed so that we have a good minimal tablespace image before
18- doing anything further with it. */
19- return (offset < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE);
20-}
21-
22-/************************************************************************
23 Write-through page write filter. */
24 static my_bool wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
25 xb_fil_cur_t *cursor);
26@@ -153,8 +138,7 @@
27 for (i = 0, page = cursor->buf; i < cursor->buf_npages;
28 i++, page += page_size) {
29 if (ut_dulint_cmp(incremental_lsn,
30- MACH_READ_64(page + FIL_PAGE_LSN)) >= 0
31- && !wf_common_filter(cursor->buf_offset + i * page_size)) {
32+ MACH_READ_64(page + FIL_PAGE_LSN)) >= 0) {
33 continue;
34 }
35
36
37=== modified file 'src/xtrabackup.c'
38--- src/xtrabackup.c 2012-09-07 10:50:24 +0000
39+++ src/xtrabackup.c 2012-09-07 10:50:24 +0000
40@@ -3835,13 +3835,107 @@
41 return TRUE;
42 }
43
44+/****************************************************************//**
45+Create a new tablespace on disk and return the handle to its opened
46+file. Code adopted from fil_create_new_single_table_tablespace with
47+the main difference that only disk file is created without updating
48+the InnoDB in-memory dictionary data structures.
49+
50+@return TRUE on success, FALSE on error. */
51+static
52+ibool
53+xb_delta_create_space_file(
54+/*=======================*/
55+ const char* path, /*!<in: path to tablespace */
56+ ulint space_id, /*!<in: space id */
57+ ulint flags __attribute__((unused)),/*!<in: tablespace
58+ flags */
59+ os_file_t* file) /*!<out: file handle */
60+{
61+ ibool ret;
62+ byte* buf;
63+ byte* page;
64+
65+ *file = xb_file_create_no_error_handling(path, OS_FILE_CREATE,
66+ OS_FILE_READ_WRITE, &ret);
67+ if (!ret) {
68+ msg("xtrabackup: cannot create file %s\n", path);
69+ return ret;
70+ }
71+
72+ ret = os_file_set_size(path, *file,
73+ FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE, 0);
74+ if (!ret) {
75+ msg("xtrabackup: cannot set size for file %s\n", path);
76+ os_file_close(*file);
77+ os_file_delete(path);
78+ return ret;
79+ }
80+
81+ buf = ut_malloc(3 * UNIV_PAGE_SIZE);
82+ /* Align the memory for file i/o if we might have O_DIRECT set */
83+ page = ut_align(buf, UNIV_PAGE_SIZE);
84+
85+ memset(page, '\0', UNIV_PAGE_SIZE);
86+
87+#ifdef INNODB_VERSION_SHORT
88+ fsp_header_init_fields(page, space_id, flags);
89+ mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
90+
91+ if (!(flags & DICT_TF_ZSSIZE_MASK)) {
92+ buf_flush_init_for_writing(page, NULL, 0);
93+
94+ ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
95+ }
96+ else {
97+ page_zip_des_t page_zip;
98+ ulint zip_size;
99+
100+ zip_size = (PAGE_ZIP_MIN_SIZE >> 1)
101+ << ((flags & DICT_TF_ZSSIZE_MASK)
102+ >> DICT_TF_ZSSIZE_SHIFT);
103+ page_zip_set_size(&page_zip, zip_size);
104+ page_zip.data = page + UNIV_PAGE_SIZE;
105+ fprintf(stderr, "zip_size = %lu\n", zip_size);
106+
107+#ifdef UNIV_DEBUG
108+ page_zip.m_start =
109+#endif /* UNIV_DEBUG */
110+ page_zip.m_end = page_zip.m_nonempty =
111+ page_zip.n_blobs = 0;
112+
113+ buf_flush_init_for_writing(page, &page_zip, 0);
114+
115+ ret = os_file_write(path, *file, page_zip.data, 0, 0,
116+ zip_size);
117+ }
118+#else
119+ fsp_header_write_space_id(page, space_id);
120+
121+ buf_flush_init_for_writing(page, ut_dulint_zero, space_id, 0);
122+
123+ ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
124+#endif
125+
126+ ut_free(buf);
127+
128+ if (!ret) {
129+ msg("xtrabackup: could not write the first page to %s\n",
130+ path);
131+ os_file_close(*file);
132+ os_file_delete(path);
133+ return ret;
134+ }
135+
136+ return TRUE;
137+}
138
139 /***********************************************************************
140 Searches for matching tablespace file for given .delta file and space_id
141 in given directory. When matching tablespace found, renames it to match the
142 name of .delta file. If there was a tablespace with matching name and
143 mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
144-matching file, creates a placeholder for the new tablespace.
145+matching file, creates a new tablespace.
146 @return file handle of matched or created file */
147 static
148 os_file_t
149@@ -3942,12 +4036,7 @@
150 goto found;
151 }
152
153- /* No matching space found. create the new one. Note that this is not
154- a full-fledged tablespace create, as done by
155- fil_create_new_single_table_tablespace(): the minumum tablespace size
156- is not ensured and the 1st page fields are not set. We rely on backup
157- delta to contain the 1st FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
158- to ensure the correct tablespace image. */
159+ /* No matching space found. create the new one. */
160
161 #ifdef INNODB_VERSION_SHORT
162 /* Calculate correct tablespace flags for compressed tablespaces. Do
163@@ -3977,15 +4066,8 @@
164 goto exit;
165 }
166
167- file = xb_file_create_no_error_handling(real_name, OS_FILE_CREATE,
168- OS_FILE_READ_WRITE,
169- &ok);
170-
171- if (ok) {
172- *success = TRUE;
173- } else {
174- msg("xtrabackup: Cannot open file %s\n", real_name);
175- }
176+ *success = xb_delta_create_space_file(real_name, space_id,
177+ tablespace_flags, &file);
178
179 goto exit;
180

Subscribers

People subscribed via source and target branches