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

Proposed by Laurynas Biveinis on 2012-09-07
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 2012-09-07 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 on 2012-09-05

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 on 2012-09-05

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
=== modified file 'src/xtrabackup.c'
--- src/xtrabackup.c 2012-09-07 10:46:35 +0000
+++ src/xtrabackup.c 2012-09-07 10:46:35 +0000
@@ -3423,18 +3423,11 @@
3423 if (xtrabackup_incremental) {3423 if (xtrabackup_incremental) {
3424 for (chunk_offset = 0; chunk_offset < chunk; chunk_offset += page_size) {3424 for (chunk_offset = 0; chunk_offset < chunk; chunk_offset += page_size) {
3425 /* newer page */3425 /* newer page */
3426 /* This condition may be OK for header, ibuf and fsp3426 /* This condition may be OK for header, ibuf
3427 We always copy the 1st3427 and fsp. */
3428 FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
3429 bytes of any tablespace, regardless of the LSNs
3430 of the pages there. These pages are guaranteed
3431 to be flushed upon tablespace create and they
3432 are required for InnoDB to recognize the
3433 tablespace. */
3434 if (ut_dulint_cmp(incremental_lsn,3428 if (ut_dulint_cmp(incremental_lsn,
3435 MACH_READ_64(page + chunk_offset + FIL_PAGE_LSN)) < 03429 MACH_READ_64(page + chunk_offset
3436 || (offset + chunk_offset3430 + FIL_PAGE_LSN)) < 0) {
3437 < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE)) {
3438 /* ========================================= */3431 /* ========================================= */
3439 IB_INT64 offset_on_page;3432 IB_INT64 offset_on_page;
34403433
@@ -5657,12 +5650,107 @@
5657 return TRUE;5650 return TRUE;
5658}5651}
56595652
5653/****************************************************************//**
5654Create a new tablespace on disk and return the handle to its opened
5655file. Code adopted from fil_create_new_single_table_tablespace with
5656the main difference that only disk file is created without updating
5657the InnoDB in-memory dictionary data structures.
5658
5659@return TRUE on success, FALSE on error. */
5660static
5661ibool
5662xb_delta_create_space_file(
5663/*=======================*/
5664 const char* path, /*!<in: path to tablespace */
5665 ulint space_id, /*!<in: space id */
5666 ulint flags __attribute__((unused)),/*!<in: tablespace
5667 flags */
5668 os_file_t* file) /*!<out: file handle */
5669{
5670 ibool ret;
5671 byte* buf;
5672 byte* page;
5673
5674 *file = xb_file_create_no_error_handling(path, OS_FILE_CREATE,
5675 OS_FILE_READ_WRITE, &ret);
5676 if (!ret) {
5677 msg("xtrabackup: cannot create file %s\n", path);
5678 return ret;
5679 }
5680
5681 ret = os_file_set_size(path, *file,
5682 FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE, 0);
5683 if (!ret) {
5684 msg("xtrabackup: cannot set size for file %s\n", path);
5685 os_file_close(*file);
5686 os_file_delete(path);
5687 return ret;
5688 }
5689
5690 buf = ut_malloc(3 * UNIV_PAGE_SIZE);
5691 /* Align the memory for file i/o if we might have O_DIRECT set */
5692 page = ut_align(buf, UNIV_PAGE_SIZE);
5693
5694 memset(page, '\0', UNIV_PAGE_SIZE);
5695
5696#ifdef INNODB_VERSION_SHORT
5697 fsp_header_init_fields(page, space_id, flags);
5698 mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
5699
5700 if (!(flags & DICT_TF_ZSSIZE_MASK)) {
5701 buf_flush_init_for_writing(page, NULL, 0);
5702
5703 ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
5704 }
5705 else {
5706 page_zip_des_t page_zip;
5707 ulint zip_size;
5708
5709 zip_size = (PAGE_ZIP_MIN_SIZE >> 1)
5710 << ((flags & DICT_TF_ZSSIZE_MASK)
5711 >> DICT_TF_ZSSIZE_SHIFT);
5712 page_zip_set_size(&page_zip, zip_size);
5713 page_zip.data = page + UNIV_PAGE_SIZE;
5714 fprintf(stderr, "zip_size = %lu\n", zip_size);
5715
5716#ifdef UNIV_DEBUG
5717 page_zip.m_start =
5718#endif /* UNIV_DEBUG */
5719 page_zip.m_end = page_zip.m_nonempty =
5720 page_zip.n_blobs = 0;
5721
5722 buf_flush_init_for_writing(page, &page_zip, 0);
5723
5724 ret = os_file_write(path, *file, page_zip.data, 0, 0,
5725 zip_size);
5726 }
5727#else
5728 fsp_header_write_space_id(page, space_id);
5729
5730 buf_flush_init_for_writing(page, ut_dulint_zero, space_id, 0);
5731
5732 ret = os_file_write(path, *file, page, 0, 0, UNIV_PAGE_SIZE);
5733#endif
5734
5735 ut_free(buf);
5736
5737 if (!ret) {
5738 msg("xtrabackup: could not write the first page to %s\n",
5739 path);
5740 os_file_close(*file);
5741 os_file_delete(path);
5742 return ret;
5743 }
5744
5745 return TRUE;
5746}
5747
5660/***********************************************************************5748/***********************************************************************
5661Searches for matching tablespace file for given .delta file and space_id5749Searches for matching tablespace file for given .delta file and space_id
5662in given directory. When matching tablespace found, renames it to match the5750in given directory. When matching tablespace found, renames it to match the
5663name of .delta file. If there was a tablespace with matching name and5751name of .delta file. If there was a tablespace with matching name and
5664mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no5752mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no
5665matching file, creates a placeholder for the new tablespace.5753matching file, creates a new tablespace.
5666@return file handle of matched or created file */5754@return file handle of matched or created file */
5667static5755static
5668os_file_t5756os_file_t
@@ -5763,12 +5851,7 @@
5763 goto found;5851 goto found;
5764 }5852 }
57655853
5766 /* No matching space found. create the new one. Note that this is not5854 /* No matching space found. create the new one. */
5767 a full-fledged tablespace create, as done by
5768 fil_create_new_single_table_tablespace(): the minumum tablespace size
5769 is not ensured and the 1st page fields are not set. We rely on backup
5770 delta to contain the 1st FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE
5771 to ensure the correct tablespace image. */
57725855
5773#ifdef INNODB_VERSION_SHORT5856#ifdef INNODB_VERSION_SHORT
5774 /* Calculate correct tablespace flags for compressed tablespaces. Do5857 /* Calculate correct tablespace flags for compressed tablespaces. Do
@@ -5798,15 +5881,8 @@
5798 goto exit;5881 goto exit;
5799 }5882 }
58005883
5801 file = xb_file_create_no_error_handling(real_name, OS_FILE_CREATE,5884 *success = xb_delta_create_space_file(real_name, space_id,
5802 OS_FILE_READ_WRITE,5885 tablespace_flags, &file);
5803 &ok);
5804
5805 if (ok) {
5806 *success = TRUE;
5807 } else {
5808 msg("xtrabackup: Cannot open file %s\n", real_name);
5809 }
58105886
5811 goto exit;5887 goto exit;
58125888

Subscribers

People subscribed via source and target branches