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

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 436
Proposed branch: lp:~laurynas-biveinis/percona-xtrabackup/bug1049174-2.1
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 370 lines (+181/-61)
5 files modified
src/innodb_int.c (+116/-0)
src/innodb_int.h (+35/-1)
src/write_filt.c (+2/-17)
src/xtrabackup.c (+25/-41)
src/xtrabackup.h (+3/-2)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-xtrabackup/bug1049174-2.1
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+124412@code.launchpad.net

Description of the change

Merge bug 1049174, bug 1044398, bug 1043762 fixes from 2.0.

Differences from 2.0 version:
- xb_delta_create_space_file() is named xb_space_create_file() and put
  into innodb_int.[hc].
- dict_table_flags_to_zip_size() definition provided for pre-InnoDB
  plugin configurations, to remove #ifndef INNODB_VERSION_SHORT in
  xb_delta_open_matching_space().
- The compression flag constants are defined in innodb_int.h instead
  of xtrabackup.c.
- Define fil_space_create() wrapper xb_fil_space_create() in
  innodb_int.h that accepts but ignores zip_size arg on pre-InnoDB
  plugin configurations.
- Moved SRV_SHUTDOWN_NONE definition to the main compatibility #define
  section in innodb_int.h.
- The suboptimal fix for bug 1022562 is reverted by removing
  wf_common_filter() function and updating its caller.

Jenkins: http://jenkins.percona.com/job/percona-xtrabackup-2.1-param/46/

Issue #16274

To post a comment you must log in.
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
=== modified file 'src/innodb_int.c'
--- src/innodb_int.c 2012-07-11 07:55:58 +0000
+++ src/innodb_int.c 2012-09-14 13:04:19 +0000
@@ -200,8 +200,124 @@
200 return(space);200 return(space);
201}201}
202202
203/****************************************************************//**
204Create a new tablespace on disk and return the handle to its opened
205file. Code adopted from fil_create_new_single_table_tablespace with
206the main difference that only disk file is created without updating
207the InnoDB in-memory dictionary data structures.
208
209@return TRUE on success, FALSE on error. */
210ibool
211xb_space_create_file(
212/*==================*/
213 const char* path, /*!<in: path to tablespace */
214 ulint space_id, /*!<in: space id */
215 ulint flags __attribute__((unused)),/*!<in: tablespace
216 flags */
217 os_file_t* file) /*!<out: file handle */
218{
219 ibool ret;
220 byte* buf;
221 byte* page;
222
223 *file = xb_file_create_no_error_handling(path, OS_FILE_CREATE,
224 OS_FILE_READ_WRITE, &ret);
225 if (!ret) {
226 msg("xtrabackup: cannot create file %s\n", path);
227 return ret;
228 }
229
230 ret = os_file_set_size(path, *file,
231 FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE, 0);
232 if (!ret) {
233 msg("xtrabackup: cannot set size for file %s\n", path);
234 os_file_close(*file);
235 os_file_delete(path);
236 return ret;
237 }
238
239 buf = ut_malloc(3 * UNIV_PAGE_SIZE);
240 /* Align the memory for file i/o if we might have O_DIRECT set */
241 page = ut_align(buf, UNIV_PAGE_SIZE);
242
243 memset(page, '\0', UNIV_PAGE_SIZE);
244
245#ifdef INNODB_VERSION_SHORT
246 fsp_header_init_fields(page, space_id, flags);
247 mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
248
249 if (!(flags & DICT_TF_ZSSIZE_MASK)) {
250 buf_flush_init_for_writing(page, NULL, 0);
251
252 ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
253 }
254 else {
255 page_zip_des_t page_zip;
256 ulint zip_size;
257
258 zip_size = (PAGE_ZIP_MIN_SIZE >> 1)
259 << ((flags & DICT_TF_ZSSIZE_MASK)
260 >> DICT_TF_ZSSIZE_SHIFT);
261 page_zip_set_size(&page_zip, zip_size);
262 page_zip.data = page + UNIV_PAGE_SIZE;
263 fprintf(stderr, "zip_size = %lu\n", zip_size);
264
265#ifdef UNIV_DEBUG
266 page_zip.m_start =
267#endif /* UNIV_DEBUG */
268 page_zip.m_end = page_zip.m_nonempty =
269 page_zip.n_blobs = 0;
270
271 buf_flush_init_for_writing(page, &page_zip, 0);
272
273 ret = os_file_write(path, *file, page_zip.data, 0, 0,
274 zip_size);
275 }
276#else
277 fsp_header_write_space_id(page, space_id);
278
279 buf_flush_init_for_writing(page, ut_dulint_zero, space_id, 0);
280
281 ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
282#endif
283
284 ut_free(buf);
285
286 if (!ret) {
287 msg("xtrabackup: could not write the first page to %s\n",
288 path);
289 os_file_close(*file);
290 os_file_delete(path);
291 return ret;
292 }
293
294 return TRUE;
295}
296
297
203#ifndef INNODB_VERSION_SHORT298#ifndef INNODB_VERSION_SHORT
204299
300/********************************************************************//**
301Extract the compressed page size from table flags.
302@return compressed page size, or 0 if not compressed */
303ulint
304dict_table_flags_to_zip_size(
305/*=========================*/
306 ulint flags) /*!< in: flags */
307{
308 ulint zip_size = flags & DICT_TF_ZSSIZE_MASK;
309
310 if (UNIV_UNLIKELY(zip_size)) {
311 zip_size = ((PAGE_ZIP_MIN_SIZE >> 1)
312 << (zip_size >> DICT_TF_ZSSIZE_SHIFT));
313
314 ut_ad(zip_size <= UNIV_PAGE_SIZE);
315 }
316
317 return(zip_size);
318}
319
320
205/*******************************************************************//**321/*******************************************************************//**
206Free all spaces in space_list. */322Free all spaces in space_list. */
207void323void
208324
=== modified file 'src/innodb_int.h'
--- src/innodb_int.h 2012-07-11 07:55:58 +0000
+++ src/innodb_int.h 2012-09-14 13:04:19 +0000
@@ -42,6 +42,15 @@
42# define MACH_WRITE_64 mach_write_to_842# define MACH_WRITE_64 mach_write_to_8
43# define OS_MUTEX_CREATE() os_mutex_create(NULL)43# define OS_MUTEX_CREATE() os_mutex_create(NULL)
44# define xb_buf_page_is_corrupted(page, zip_size) buf_page_is_corrupted(page)44# define xb_buf_page_is_corrupted(page, zip_size) buf_page_is_corrupted(page)
45# define xb_fil_space_create(name, space_id, zip_size, purpose) \
46 fil_space_create(name, space_id, purpose)
47# define PAGE_ZIP_MIN_SIZE_SHIFT 10
48# define PAGE_ZIP_MIN_SIZE (1 << PAGE_ZIP_MIN_SIZE_SHIFT)
49# define DICT_TF_ZSSIZE_SHIFT 1
50# define DICT_TF_ZSSIZE_MASK (15 << DICT_TF_ZSSIZE_SHIFT)
51# define DICT_TF_FORMAT_ZIP 1
52# define DICT_TF_FORMAT_SHIFT 5
53# define SRV_SHUTDOWN_NONE 0
45#else54#else
46# define IB_INT64 ib_int64_t55# define IB_INT64 ib_int64_t
47# define LSN64 ib_uint64_t56# define LSN64 ib_uint64_t
@@ -56,6 +65,8 @@
56# endif65# endif
57# define xb_buf_page_is_corrupted(page, zip_size) \66# define xb_buf_page_is_corrupted(page, zip_size) \
58 buf_page_is_corrupted(page, zip_size)67 buf_page_is_corrupted(page, zip_size)
68# define xb_fil_space_create(name, space_id, zip_size, purpose) \
69 fil_space_create(name, space_id, zip_size, purpose)
59# define ut_dulint_zero 070# define ut_dulint_zero 0
60# define ut_dulint_cmp(A, B) (A > B ? 1 : (A == B ? 0 : -1))71# define ut_dulint_cmp(A, B) (A > B ? 1 : (A == B ? 0 : -1))
61# define ut_dulint_add(A, B) (A + B)72# define ut_dulint_add(A, B) (A + B)
@@ -598,9 +609,32 @@
598/*==================*/609/*==================*/
599 const char* name); /*!< in: space name */610 const char* name); /*!< in: space name */
600611
612/****************************************************************//**
613Create a new tablespace on disk and return the handle to its opened
614file. Code adopted from fil_create_new_single_table_tablespace with
615the main difference that only disk file is created without updating
616the InnoDB in-memory dictionary data structures.
617
618@return TRUE on success, FALSE on error. */
619ibool
620xb_space_create_file(
621/*==================*/
622 const char* path, /*!<in: path to tablespace */
623 ulint space_id, /*!<in: space id */
624 ulint flags __attribute__((unused)),/*!<in: tablespace
625 flags */
626 os_file_t* file); /*!<out: file handle */
627
601#ifndef INNODB_VERSION_SHORT628#ifndef INNODB_VERSION_SHORT
602629
603#define SRV_SHUTDOWN_NONE 0630/********************************************************************//**
631Extract the compressed page size from table flags.
632@return compressed page size, or 0 if not compressed */
633ulint
634dict_table_flags_to_zip_size(
635/*=========================*/
636 ulint flags); /*!< in: flags */
637
604638
605/*******************************************************************//**639/*******************************************************************//**
606Free all spaces in space_list. */640Free all spaces in space_list. */
607641
=== modified file 'src/write_filt.c'
--- src/write_filt.c 2012-08-01 10:10:44 +0000
+++ src/write_filt.c 2012-09-14 13:04:19 +0000
@@ -32,21 +32,6 @@
32#include "xtrabackup.h"32#include "xtrabackup.h"
3333
34/************************************************************************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/************************************************************************
50Write-through page write filter. */35Write-through page write filter. */
51static my_bool wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,36static my_bool wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
52 xb_fil_cur_t *cursor);37 xb_fil_cur_t *cursor);
@@ -118,6 +103,7 @@
118 snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name,103 snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name,
119 XB_DELTA_INFO_SUFFIX);104 XB_DELTA_INFO_SUFFIX);
120 info.page_size = cursor->page_size;105 info.page_size = cursor->page_size;
106 info.zip_size = cursor->zip_size;
121 info.space_id = cursor->space_id;107 info.space_id = cursor->space_id;
122 if (!xb_write_delta_metadata(meta_name, &info)) {108 if (!xb_write_delta_metadata(meta_name, &info)) {
123 msg("[%02lu] xtrabackup: Error: "109 msg("[%02lu] xtrabackup: Error: "
@@ -152,8 +138,7 @@
152 for (i = 0, page = cursor->buf; i < cursor->buf_npages;138 for (i = 0, page = cursor->buf; i < cursor->buf_npages;
153 i++, page += page_size) {139 i++, page += page_size) {
154 if (ut_dulint_cmp(incremental_lsn,140 if (ut_dulint_cmp(incremental_lsn,
155 MACH_READ_64(page + FIL_PAGE_LSN)) >= 0141 MACH_READ_64(page + FIL_PAGE_LSN)) >= 0) {
156 && !wf_common_filter(cursor->buf_offset + i * page_size)) {
157 continue;142 continue;
158 }143 }
159144
160145
=== modified file 'src/xtrabackup.c'
--- src/xtrabackup.c 2012-09-05 08:35:45 +0000
+++ src/xtrabackup.c 2012-09-14 13:04:19 +0000
@@ -1506,6 +1506,7 @@
15061506
1507 /* set defaults */1507 /* set defaults */
1508 info->page_size = ULINT_UNDEFINED;1508 info->page_size = ULINT_UNDEFINED;
1509 info->zip_size = ULINT_UNDEFINED;
1509 info->space_id = ULINT_UNDEFINED;1510 info->space_id = ULINT_UNDEFINED;
15101511
1511 fp = fopen(filepath, "r");1512 fp = fopen(filepath, "r");
@@ -1518,6 +1519,8 @@
1518 if (fscanf(fp, "%50s = %50s\n", key, value) == 2) {1519 if (fscanf(fp, "%50s = %50s\n", key, value) == 2) {
1519 if (strcmp(key, "page_size") == 0) {1520 if (strcmp(key, "page_size") == 0) {
1520 info->page_size = strtoul(value, NULL, 10);1521 info->page_size = strtoul(value, NULL, 10);
1522 } else if (strcmp(key, "zip_size") == 0) {
1523 info->zip_size = strtoul(value, NULL, 10);
1521 } else if (strcmp(key, "space_id") == 0) {1524 } else if (strcmp(key, "space_id") == 0) {
1522 info->space_id = strtoul(value, NULL, 10);1525 info->space_id = strtoul(value, NULL, 10);
1523 }1526 }
@@ -1552,8 +1555,10 @@
1552 MY_STAT mystat;1555 MY_STAT mystat;
15531556
1554 snprintf(buf, sizeof(buf),1557 snprintf(buf, sizeof(buf),
1555 "page_size = %lu\nspace_id = %lu\n",1558 "page_size = %lu\n"
1556 info->page_size, info->space_id);1559 "zip_size = %lu\n"
1560 "space_id = %lu\n",
1561 info->page_size, info->zip_size, info->space_id);
1557 len = strlen(buf);1562 len = strlen(buf);
15581563
1559 mystat.st_size = len;1564 mystat.st_size = len;
@@ -3836,7 +3841,7 @@
3836in given directory. When matching tablespace found, renames it to match the3841in given directory. When matching tablespace found, renames it to match the
3837name of .delta file. If there was a tablespace with matching name and3842name of .delta file. If there was a tablespace with matching name and
3838mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no3843mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
3839matching file, creates a placeholder for the new tablespace.3844matching file, creates a new tablespace.
3840@return file handle of matched or created file */3845@return file handle of matched or created file */
3841static3846static
3842os_file_t3847os_file_t
@@ -3937,19 +3942,17 @@
3937 goto found;3942 goto found;
3938 }3943 }
39393944
3940 /* No matching space found. create the new one. Note that this is not3945 /* No matching space found. create the new one. */
3941 a full-fledged tablespace create, as done by3946
3942 fil_create_new_single_table_tablespace(): the minumum tablespace size3947 if (!xb_fil_space_create(dest_space_name, space_id, 0,
3943 is not ensured and the 1st page fields are not set. We rely on backup3948 FIL_TABLESPACE)) {
3944 delta to contain the 1st FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE3949 msg("xtrabackup: Cannot create tablespace %s\n",
3945 to ensure the correct tablespace image. */3950 dest_space_name);
39463951 goto exit;
3947#ifdef INNODB_VERSION_SHORT3952 }
3948 /* Calculate correct tablespace flags for compressed tablespaces. Do3953
3949 not bother to set all flags correctly, just enough for3954 /* Calculate correct tablespace flags for compressed tablespaces. */
3950 fil_space_create() to work. The full flags will be restored from the3955 if (!zip_size || zip_size == ULINT_UNDEFINED) {
3951 delta later. */
3952 if (!zip_size) {
3953 tablespace_flags = 0;3956 tablespace_flags = 0;
3954 }3957 }
3955 else {3958 else {
@@ -3959,29 +3962,11 @@
3959 << DICT_TF_ZSSIZE_SHIFT)3962 << DICT_TF_ZSSIZE_SHIFT)
3960 | DICT_TF_COMPACT3963 | DICT_TF_COMPACT
3961 | (DICT_TF_FORMAT_ZIP << DICT_TF_FORMAT_SHIFT);3964 | (DICT_TF_FORMAT_ZIP << DICT_TF_FORMAT_SHIFT);
3962 }3965 ut_a(dict_table_flags_to_zip_size(tablespace_flags)
3963 ut_a(dict_table_flags_to_zip_size(tablespace_flags) == zip_size);3966 == zip_size);
3964 if (!fil_space_create(dest_space_name, space_id, tablespace_flags,3967 }
3965 FIL_TABLESPACE)) {3968 *success = xb_space_create_file(real_name, space_id, tablespace_flags,
3966#else3969 &file);
3967 if (!fil_space_create(dest_space_name, space_id,
3968 FIL_TABLESPACE)) {
3969#endif
3970 msg("xtrabackup: Cannot create tablespace %s\n",
3971 dest_space_name);
3972 goto exit;
3973 }
3974
3975 file = xb_file_create_no_error_handling(real_name, OS_FILE_CREATE,
3976 OS_FILE_READ_WRITE,
3977 &ok);
3978
3979 if (ok) {
3980 *success = TRUE;
3981 } else {
3982 msg("xtrabackup: Cannot open file %s\n", real_name);
3983 }
3984
3985 goto exit;3970 goto exit;
39863971
3987found:3972found:
@@ -4088,8 +4073,7 @@
4088 xb_file_set_nocache(src_file, src_path, "OPEN");4073 xb_file_set_nocache(src_file, src_path, "OPEN");
40894074
4090 dst_file = xb_delta_open_matching_space(4075 dst_file = xb_delta_open_matching_space(
4091 dbname, space_name, info.space_id,4076 dbname, space_name, info.space_id, info.zip_size,
4092 info.page_size == UNIV_PAGE_SIZE ? 0 : info.page_size,
4093 dst_path, sizeof(dst_path), &success);4077 dst_path, sizeof(dst_path), &success);
4094 if (!success) {4078 if (!success) {
4095 msg("xtrabackup: error: cannot open %s\n", dst_path);4079 msg("xtrabackup: error: cannot open %s\n", dst_path);
40964080
=== modified file 'src/xtrabackup.h'
--- src/xtrabackup.h 2012-07-11 07:55:58 +0000
+++ src/xtrabackup.h 2012-09-14 13:04:19 +0000
@@ -22,8 +22,9 @@
22#define XB_XTRABACKUP_H22#define XB_XTRABACKUP_H
2323
24typedef struct {24typedef struct {
25 ulint page_size;25 ulint page_size;
26 ulint space_id;26 ulint zip_size;
27 ulint space_id;
27} xb_delta_info_t;28} xb_delta_info_t;
2829
29typedef enum {30typedef enum {

Subscribers

People subscribed via source and target branches