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

Proposed by Laurynas Biveinis
Status: Work in progress
Proposed branch: lp:~laurynas-biveinis/percona-xtrabackup/bug1043762-2.0
Merge into: lp:percona-xtrabackup/2.0
Prerequisite: lp:~laurynas-biveinis/percona-xtrabackup/bug1044398-2.0
Diff against target: 166 lines (+103/-27)
1 file modified
src/xtrabackup.c (+103/-27)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-xtrabackup/bug1043762-2.0
Reviewer Review Type Date Requested Status
Percona core Pending
Review via email: mp+123247@code.launchpad.net

Description of the change

Fix bug 1043762 (Incremental backups may take up to 5x more space
after the fix for bug #1022562).

Fix for bug 1022562 unconditionally copied first 64K of every
tablespace for incremental backups. In case of many tablespaces, that
creates huge deltas even in the absence of any changes.

Fixed by not requiring to copy the first 64K, but rather by creating
any missing tablespaces from scratch. Introduce new function
xb_delta_create_space_file() that is adopted from
fil_create_new_single_table_tablespace().

Non-functional change, no testsuite changes necessary.

Jenkins: http://jenkins.percona.com/job/percona-xtrabackup-2.0-param/254/

To post a comment you must log in.

Unmerged revisions

466. By Laurynas Biveinis

Fix bug 1043762 (Incremental backups may take up to 5x more space
after the fix for bug #1022562).

Fix for bug 1022562 unconditionally copied first 64K of every
tablespace for incremental backups. In case of many tablespaces, that
creates huge deltas even in the absence of any changes.

Fixed by not requiring to copy the first 64K, but rather by creating
any missing tablespaces from scratch. Introduce new function
xb_delta_create_space_file() that is adopted from
fil_create_new_single_table_tablespace().

Non-functional change, no testsuite changes necessary.

465. By Laurynas Biveinis

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

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-09-07 10:46:35 +0000
3+++ src/xtrabackup.c 2012-09-07 10:46:35 +0000
4@@ -3423,18 +3423,11 @@
5 if (xtrabackup_incremental) {
6 for (chunk_offset = 0; chunk_offset < chunk; chunk_offset += page_size) {
7 /* newer page */
8- /* This condition may be OK for header, ibuf and fsp
9- We always copy the 1st
10- FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
11- bytes of any tablespace, regardless of the LSNs
12- of the pages there. These pages are guaranteed
13- to be flushed upon tablespace create and they
14- are required for InnoDB to recognize the
15- tablespace. */
16+ /* This condition may be OK for header, ibuf
17+ and fsp. */
18 if (ut_dulint_cmp(incremental_lsn,
19- MACH_READ_64(page + chunk_offset + FIL_PAGE_LSN)) < 0
20- || (offset + chunk_offset
21- < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE)) {
22+ MACH_READ_64(page + chunk_offset
23+ + FIL_PAGE_LSN)) < 0) {
24 /* ========================================= */
25 IB_INT64 offset_on_page;
26
27@@ -5657,12 +5650,107 @@
28 return TRUE;
29 }
30
31+/****************************************************************//**
32+Create a new tablespace on disk and return the handle to its opened
33+file. Code adopted from fil_create_new_single_table_tablespace with
34+the main difference that only disk file is created without updating
35+the InnoDB in-memory dictionary data structures.
36+
37+@return TRUE on success, FALSE on error. */
38+static
39+ibool
40+xb_delta_create_space_file(
41+/*=======================*/
42+ const char* path, /*!<in: path to tablespace */
43+ ulint space_id, /*!<in: space id */
44+ ulint flags __attribute__((unused)),/*!<in: tablespace
45+ flags */
46+ os_file_t* file) /*!<out: file handle */
47+{
48+ ibool ret;
49+ byte* buf;
50+ byte* page;
51+
52+ *file = xb_file_create_no_error_handling(path, OS_FILE_CREATE,
53+ OS_FILE_READ_WRITE, &ret);
54+ if (!ret) {
55+ msg("xtrabackup: cannot create file %s\n", path);
56+ return ret;
57+ }
58+
59+ ret = os_file_set_size(path, *file,
60+ FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE, 0);
61+ if (!ret) {
62+ msg("xtrabackup: cannot set size for file %s\n", path);
63+ os_file_close(*file);
64+ os_file_delete(path);
65+ return ret;
66+ }
67+
68+ buf = ut_malloc(3 * UNIV_PAGE_SIZE);
69+ /* Align the memory for file i/o if we might have O_DIRECT set */
70+ page = ut_align(buf, UNIV_PAGE_SIZE);
71+
72+ memset(page, '\0', UNIV_PAGE_SIZE);
73+
74+#ifdef INNODB_VERSION_SHORT
75+ fsp_header_init_fields(page, space_id, flags);
76+ mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
77+
78+ if (!(flags & DICT_TF_ZSSIZE_MASK)) {
79+ buf_flush_init_for_writing(page, NULL, 0);
80+
81+ ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
82+ }
83+ else {
84+ page_zip_des_t page_zip;
85+ ulint zip_size;
86+
87+ zip_size = (PAGE_ZIP_MIN_SIZE >> 1)
88+ << ((flags & DICT_TF_ZSSIZE_MASK)
89+ >> DICT_TF_ZSSIZE_SHIFT);
90+ page_zip_set_size(&page_zip, zip_size);
91+ page_zip.data = page + UNIV_PAGE_SIZE;
92+ fprintf(stderr, "zip_size = %lu\n", zip_size);
93+
94+#ifdef UNIV_DEBUG
95+ page_zip.m_start =
96+#endif /* UNIV_DEBUG */
97+ page_zip.m_end = page_zip.m_nonempty =
98+ page_zip.n_blobs = 0;
99+
100+ buf_flush_init_for_writing(page, &page_zip, 0);
101+
102+ ret = os_file_write(path, *file, page_zip.data, 0, 0,
103+ zip_size);
104+ }
105+#else
106+ fsp_header_write_space_id(page, space_id);
107+
108+ buf_flush_init_for_writing(page, ut_dulint_zero, space_id, 0);
109+
110+ ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
111+#endif
112+
113+ ut_free(buf);
114+
115+ if (!ret) {
116+ msg("xtrabackup: could not write the first page to %s\n",
117+ path);
118+ os_file_close(*file);
119+ os_file_delete(path);
120+ return ret;
121+ }
122+
123+ return TRUE;
124+}
125+
126 /***********************************************************************
127 Searches for matching tablespace file for given .delta file and space_id
128 in given directory. When matching tablespace found, renames it to match the
129 name of .delta file. If there was a tablespace with matching name and
130 mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
131-matching file, creates a placeholder for the new tablespace.
132+matching file, creates a new tablespace.
133 @return file handle of matched or created file */
134 static
135 os_file_t
136@@ -5763,12 +5851,7 @@
137 goto found;
138 }
139
140- /* No matching space found. create the new one. Note that this is not
141- a full-fledged tablespace create, as done by
142- fil_create_new_single_table_tablespace(): the minumum tablespace size
143- is not ensured and the 1st page fields are not set. We rely on backup
144- delta to contain the 1st FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
145- to ensure the correct tablespace image. */
146+ /* No matching space found. create the new one. */
147
148 #ifdef INNODB_VERSION_SHORT
149 /* Calculate correct tablespace flags for compressed tablespaces. Do
150@@ -5798,15 +5881,8 @@
151 goto exit;
152 }
153
154- file = xb_file_create_no_error_handling(real_name, OS_FILE_CREATE,
155- OS_FILE_READ_WRITE,
156- &ok);
157-
158- if (ok) {
159- *success = TRUE;
160- } else {
161- msg("xtrabackup: Cannot open file %s\n", real_name);
162- }
163+ *success = xb_delta_create_space_file(real_name, space_id,
164+ tablespace_flags, &file);
165
166 goto exit;
167

Subscribers

People subscribed via source and target branches