Merge lp:~akopytov/percona-xtrabackup/bugs-1177206-and-1187071-2.0 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 564
Proposed branch: lp:~akopytov/percona-xtrabackup/bugs-1177206-and-1187071-2.0
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 366 lines (+137/-44)
2 files modified
patches/innodb56.patch (+91/-22)
src/xtrabackup.cc (+46/-22)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bugs-1177206-and-1187071-2.0
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+170240@code.launchpad.net

Description of the change

    Bug #1177206: InnoDB: Assertion failure in thread <nr> in file
                  log0recv.c line 1105 InnoDB: Failing assertion: !page
                  || (ibool)!!page_is_comp(page) ==
                  dict_table_is_comp(index->table)

    Bug #1187071: xb 2.1 against ps 5.6 gives Error: Tablespace is not
                  sensible during backup"

    The problems are related, so fixing in a single revision.

    The problem in bug #1187071 was a difference in behavior between InnoDB
    5.5- and 5.6 codebases in cases when a newly created tablespace has
    uninitialized first page at the time when XtraBackup opens it while
    creating a list of tablespaces to backup. 5.1/5.5 InnoDB code would just
    complain about tablespace ID being non-sensible and omit it from the
    backup. But in 5.6 it fails with an error in such a case.

    A related problem in bug #1177206 was that
    xb_data_files_init() (i.e. loading tablespaces into fil_system) was
    called before log copying was started. This could lead to a race between
    the datafiles state in the resulting backup and xtrabackup_logfile: a
    tablespace created at a sensitive time would be missing in both the
    backup itself and as the corresponding MLOG_FILE_CREATE* log record in
    xtrabackup_logfile, so it would not be created on --apply-log
    either. This problem has existed since the very first XtraBackup
    version.

    Fixed by:

    1. Ignoring tablespaces with uninitialized pages on xtrabackup startup
    for InnoDB 5.6 codebase to match the behavior of InnoDB 5.5-.
    2. Moving the call to xb_data_files_init() in xtrabackup_backup_func()
    to a later stage so that it is only called after the log copying is
    started. This involved a minor code refactoring, since
    xb_data_files_init() previously did 2 things: initializing the 'fil'
    subsystem (which is also required by the log copying code) and actually
    populating fil_system. We now have 2 separate functions:
    xb_fil_io_init() (called before log copying is started) and
    xb_load_tablespaces() (called after log copying is started).

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.0-param/461/

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Was

13 ++ fsp_open_info* fsp;
14 ++ ulong minimum_size;
15 ++ ibool file_space_create_success;

intentional?

It looks like it's unrelated to the fix, just increases the patch size.

review: Needs Information
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Nevermind, I guess it's to fix "goto jumps past var initialization" warnings, isn't it?

review: Approve
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Exactly. Was something like "jump to protected scope" with clang.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'patches/innodb56.patch'
--- patches/innodb56.patch 2013-05-16 18:01:50 +0000
+++ patches/innodb56.patch 2013-06-19 05:51:29 +0000
@@ -330,7 +330,17 @@
330 330
331 err = DB_CORRUPTION;331 err = DB_CORRUPTION;
332 332
333@@ -4018,6 +4141,9 @@333@@ -3974,6 +4097,9 @@
334 #ifdef UNIV_HOTBACKUP
335 fil_space_t* space;
336 #endif
337+ fsp_open_info* fsp;
338+ ulong minimum_size;
339+ ibool file_space_create_success;
340
341 memset(&def, 0, sizeof(def));
342 memset(&remote, 0, sizeof(remote));
343@@ -4018,6 +4144,9 @@
334 # endif /* !UNIV_HOTBACKUP */344 # endif /* !UNIV_HOTBACKUP */
335 #endif345 #endif
336 346
@@ -340,24 +350,76 @@
340 /* Check for a link file which locates a remote tablespace. */350 /* Check for a link file which locates a remote tablespace. */
341 remote.success = fil_open_linked_file(351 remote.success = fil_open_linked_file(
342 tablename, &remote.filepath, &remote.file);352 tablename, &remote.filepath, &remote.file);
343@@ -4030,6 +4156,7 @@353@@ -4028,8 +4157,20 @@
354 if (!remote.success) {
355 os_file_close(remote.file);
344 mem_free(remote.filepath);356 mem_free(remote.filepath);
357+
358+ if (srv_backup_mode) {
359+
360+ /* Ignore files that have uninitialized space
361+ IDs on the backup stage. This means that a
362+ tablespace has just been created and we will
363+ replay the corresponding log records on
364+ prepare. */
365+
366+ goto func_exit_after_close;
367+ }
345 }368 }
346 }369 }
347+ }370+ }
348 371
349 372
350 /* Try to open the tablespace in the datadir. */373 /* Try to open the tablespace in the datadir. */
351@@ -4135,7 +4262,7 @@374@@ -4042,6 +4183,17 @@
375 fil_validate_single_table_tablespace(tablename, &def);
376 if (!def.success) {
377 os_file_close(def.file);
378+
379+ if (srv_backup_mode) {
380+
381+ /* Ignore files that have uninitialized space
382+ IDs on the backup stage. This means that a
383+ tablespace has just been created and we will
384+ replay the corresponding log records on
385+ prepare. */
386+
387+ goto func_exit_after_close;
388+ }
389 }
390 }
391
392@@ -4114,7 +4266,7 @@
393 /* At this point, only one tablespace is open */
394 ut_a(def.success == !remote.success);
395
396- fsp_open_info* fsp = def.success ? &def : &remote;
397+ fsp = def.success ? &def : &remote;
398
399 /* Get and test the file size. */
400 size = os_file_get_size(fsp->file);
401@@ -4133,9 +4285,9 @@
402
403 /* Every .ibd file is created >= 4 pages in size. Smaller files
352 cannot be ok. */404 cannot be ok. */
353 ulong minimum_size = FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE;405- ulong minimum_size = FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE;
406+ minimum_size = FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE;
354 if (size < minimum_size) {407 if (size < minimum_size) {
355-#ifndef UNIV_HOTBACKUP408-#ifndef UNIV_HOTBACKUP
356+#if 0409+#if 0
357 ib_logf(IB_LOG_LEVEL_ERROR,410 ib_logf(IB_LOG_LEVEL_ERROR,
358 "The size of single-table tablespace file %s "411 "The size of single-table tablespace file %s "
359 "is only " UINT64PF ", should be at least %lu!",412 "is only " UINT64PF ", should be at least %lu!",
360@@ -4243,7 +4370,51 @@413@@ -4216,7 +4368,7 @@
414 }
415 mutex_exit(&fil_system->mutex);
416 #endif /* UNIV_HOTBACKUP */
417- ibool file_space_create_success = fil_space_create(
418+ file_space_create_success = fil_space_create(
419 tablename, fsp->id, fsp->flags, FIL_TABLESPACE);
420
421 if (!file_space_create_success) {
422@@ -4243,13 +4395,55 @@
361 }423 }
362 424
363 func_exit:425 func_exit:
@@ -408,9 +470,16 @@
408+ os_file_close(fsp->file);470+ os_file_close(fsp->file);
409+ }471+ }
410 472
411 #ifdef UNIV_HOTBACKUP473-#ifdef UNIV_HOTBACKUP
412 func_exit_after_close:474 func_exit_after_close:
413@@ -4263,7 +4434,7 @@475-#else
476 ut_ad(!mutex_own(&fil_system->mutex));
477-#endif
478+
479 mem_free(tablename);
480 if (remote.success) {
481 mem_free(remote.filepath);
482@@ -4263,7 +4457,7 @@
414 idea is to read as much good data as we can and jump over bad data.483 idea is to read as much good data as we can and jump over bad data.
415 @return 0 if ok, -1 if error even after the retries, 1 if at the end484 @return 0 if ok, -1 if error even after the retries, 1 if at the end
416 of the directory */485 of the directory */
@@ -419,7 +488,7 @@
419 int488 int
420 fil_file_readdir_next_file(489 fil_file_readdir_next_file(
421 /*=======================*/490 /*=======================*/
422@@ -4303,7 +4474,7 @@491@@ -4303,7 +4497,7 @@
423 @return DB_SUCCESS or error number */492 @return DB_SUCCESS or error number */
424 UNIV_INTERN493 UNIV_INTERN
425 dberr_t494 dberr_t
@@ -428,7 +497,7 @@
428 /*===================================*/497 /*===================================*/
429 {498 {
430 int ret;499 int ret;
431@@ -4359,7 +4530,9 @@500@@ -4359,7 +4553,9 @@
432 "%s/%s", fil_path_to_mysql_datadir, dbinfo.name);501 "%s/%s", fil_path_to_mysql_datadir, dbinfo.name);
433 srv_normalize_path_for_win(dbpath);502 srv_normalize_path_for_win(dbpath);
434 503
@@ -439,7 +508,7 @@
439 508
440 if (dbdir != NULL) {509 if (dbdir != NULL) {
441 510
442@@ -4380,9 +4553,15 @@511@@ -4380,9 +4576,15 @@
443 && (0 == strcmp(fileinfo.name512 && (0 == strcmp(fileinfo.name
444 + strlen(fileinfo.name) - 4,513 + strlen(fileinfo.name) - 4,
445 ".ibd")514 ".ibd")
@@ -457,7 +526,7 @@
457 /* The name ends in .ibd or .isl;526 /* The name ends in .ibd or .isl;
458 try opening the file */527 try opening the file */
459 fil_load_single_table_tablespace(528 fil_load_single_table_tablespace(
460@@ -4538,6 +4717,7 @@529@@ -4538,6 +4740,7 @@
461 {530 {
462 fil_space_t* fnamespace;531 fil_space_t* fnamespace;
463 fil_space_t* space;532 fil_space_t* space;
@@ -465,7 +534,7 @@
465 534
466 ut_ad(fil_system);535 ut_ad(fil_system);
467 536
468@@ -4615,6 +4795,10 @@537@@ -4615,6 +4818,10 @@
469 if (fnamespace == NULL) {538 if (fnamespace == NULL) {
470 if (print_error_if_does_not_exist) {539 if (print_error_if_does_not_exist) {
471 fil_report_missing_tablespace(name, id);540 fil_report_missing_tablespace(name, id);
@@ -476,7 +545,7 @@
476 }545 }
477 } else {546 } else {
478 ut_print_timestamp(stderr);547 ut_print_timestamp(stderr);
479@@ -4638,6 +4822,10 @@548@@ -4638,6 +4845,10 @@
480 549
481 mutex_exit(&fil_system->mutex);550 mutex_exit(&fil_system->mutex);
482 551
@@ -487,7 +556,7 @@
487 return(FALSE);556 return(FALSE);
488 }557 }
489 558
490@@ -4728,6 +4916,7 @@559@@ -4728,6 +4939,7 @@
491 ulint page_size;560 ulint page_size;
492 ulint pages_added;561 ulint pages_added;
493 ibool success;562 ibool success;
@@ -495,7 +564,7 @@
495 564
496 ut_ad(!srv_read_only_mode);565 ut_ad(!srv_read_only_mode);
497 566
498@@ -4772,13 +4961,17 @@567@@ -4772,13 +4984,17 @@
499 goto retry;568 goto retry;
500 }569 }
501 570
@@ -514,7 +583,7 @@
514 start_page_no = space->size;583 start_page_no = space->size;
515 file_start_page_no = space->size - node->size;584 file_start_page_no = space->size - node->size;
516 585
517@@ -5024,7 +5217,7 @@586@@ -5024,7 +5240,7 @@
518 off the LRU list if it is in the LRU list. The caller must hold the fil_sys587 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
519 mutex. */588 mutex. */
520 static589 static
@@ -523,7 +592,7 @@
523 fil_node_prepare_for_io(592 fil_node_prepare_for_io(
524 /*====================*/593 /*====================*/
525 fil_node_t* node, /*!< in: file node */594 fil_node_t* node, /*!< in: file node */
526@@ -5044,9 +5237,12 @@595@@ -5044,9 +5260,12 @@
527 }596 }
528 597
529 if (node->open == FALSE) {598 if (node->open == FALSE) {
@@ -537,7 +606,7 @@
537 }606 }
538 607
539 if (node->n_pending == 0 && fil_space_belongs_in_lru(space)) {608 if (node->n_pending == 0 && fil_space_belongs_in_lru(space)) {
540@@ -5058,6 +5254,8 @@609@@ -5058,6 +5277,8 @@
541 }610 }
542 611
543 node->n_pending++;612 node->n_pending++;
@@ -546,7 +615,7 @@
546 }615 }
547 616
548 /********************************************************************//**617 /********************************************************************//**
549@@ -5259,6 +5457,16 @@618@@ -5259,6 +5480,16 @@
550 619
551 ut_ad(mode != OS_AIO_IBUF || space->purpose == FIL_TABLESPACE);620 ut_ad(mode != OS_AIO_IBUF || space->purpose == FIL_TABLESPACE);
552 621
@@ -563,7 +632,7 @@
563 node = UT_LIST_GET_FIRST(space->chain);632 node = UT_LIST_GET_FIRST(space->chain);
564 633
565 for (;;) {634 for (;;) {
566@@ -5290,7 +5498,11 @@635@@ -5290,7 +5521,11 @@
567 }636 }
568 637
569 /* Open file if closed */638 /* Open file if closed */
@@ -576,7 +645,7 @@
576 645
577 /* Check that at least the start offset is within the bounds of a646 /* Check that at least the start offset is within the bounds of a
578 single-table tablespace, including rollback tablespaces. */647 single-table tablespace, including rollback tablespaces. */
579@@ -6164,6 +6376,7 @@648@@ -6164,6 +6399,7 @@
580 return(err);649 return(err);
581 }650 }
582 651
@@ -584,7 +653,7 @@
584 /****************************************************************//**653 /****************************************************************//**
585 Generate redo logs for swapping two .ibd files */654 Generate redo logs for swapping two .ibd files */
586 UNIV_INTERN655 UNIV_INTERN
587@@ -6187,4 +6400,4 @@656@@ -6187,4 +6423,4 @@
588 0, 0, new_name, old_name, &mtr);657 0, 0, new_name, old_name, &mtr);
589 mtr_commit(&mtr);658 mtr_commit(&mtr);
590 }659 }
591660
=== modified file 'src/xtrabackup.cc'
--- src/xtrabackup.cc 2013-05-16 18:01:50 +0000
+++ src/xtrabackup.cc 2013-06-19 05:51:29 +0000
@@ -4826,24 +4826,12 @@
4826}4826}
48274827
4828/************************************************************************4828/************************************************************************
4829Initialize the tablespace memory cache and populate it by scanning for and4829Initializes the I/O and tablespace cache subsystems. */
4830opening data files.
4831@returns DB_SUCCESS or error code.*/
4832static4830static
4833ulint4831void
4834xb_data_files_init(void)4832xb_fil_io_init(void)
4835/*====================*/4833/*================*/
4836{4834{
4837 ulint i;
4838 ibool create_new_db;
4839#ifdef XTRADB_BASED
4840 ibool create_new_doublewrite_file;
4841#endif
4842 ulint err;
4843 lsn_t min_flushed_lsn;
4844 lsn_t max_flushed_lsn;
4845 ulint sum_of_new_sizes;
4846
4847#ifndef INNODB_VERSION_SHORT4835#ifndef INNODB_VERSION_SHORT
4848 os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD4836 os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
4849 * srv_n_file_io_threads,4837 * srv_n_file_io_threads,
@@ -4868,6 +4856,25 @@
4868#endif4856#endif
48694857
4870 fsp_init();4858 fsp_init();
4859}
4860
4861/****************************************************************************
4862Populates the tablespace memory cache by scanning for and opening data files.
4863@returns DB_SUCCESS or error code.*/
4864static
4865ulint
4866xb_load_tablespaces(void)
4867/*=====================*/
4868{
4869 ulint i;
4870 ibool create_new_db;
4871#ifdef XTRADB_BASED
4872 ibool create_new_doublewrite_file;
4873#endif
4874 ulint err;
4875 lsn_t min_flushed_lsn;
4876 lsn_t max_flushed_lsn;
4877 ulint sum_of_new_sizes;
48714878
4872 for (i = 0; i < srv_n_file_io_threads; i++) {4879 for (i = 0; i < srv_n_file_io_threads; i++) {
4873 thread_nr[i] = i;4880 thread_nr[i] = i;
@@ -4932,6 +4939,20 @@
4932 return(DB_SUCCESS);4939 return(DB_SUCCESS);
4933}4940}
49344941
4942/************************************************************************
4943Initialize the tablespace memory cache and populate it by scanning for and
4944opening data files.
4945@returns DB_SUCCESS or error code.*/
4946static
4947ulint
4948xb_data_files_init(void)
4949/*====================*/
4950{
4951 xb_fil_io_init();
4952
4953 return(xb_load_tablespaces());
4954}
4955
4935/*********************************************************************//**4956/*********************************************************************//**
4936Normalizes init parameter values to use units we use inside InnoDB.4957Normalizes init parameter values to use units we use inside InnoDB.
4937@return DB_SUCCESS or error code */4958@return DB_SUCCESS or error code */
@@ -5438,12 +5459,7 @@
5438 ulint err;5459 ulint err;
5439 ulint i;5460 ulint i;
54405461
5441 err = xb_data_files_init();5462 xb_fil_io_init();
5442 if (err != DB_SUCCESS) {
5443 msg("xtrabackup: error: xb_data_files_init() failed with"
5444 "error code %lu\n", err);
5445 exit(EXIT_FAILURE);
5446 }
54475463
5448 log_init();5464 log_init();
54495465
@@ -5655,6 +5671,14 @@
5655 log_copying_stop = xb_os_event_create(NULL);5671 log_copying_stop = xb_os_event_create(NULL);
5656 os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);5672 os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);
56575673
5674 /* Populate fil_system with tablespaces to copy */
5675 err = xb_load_tablespaces();
5676 if (err != DB_SUCCESS) {
5677 msg("xtrabackup: error: xb_load_tablespaces() failed with"
5678 "error code %lu\n", err);
5679 exit(EXIT_FAILURE);
5680 }
5681
5658 if (xtrabackup_parallel > 1 && xtrabackup_stream &&5682 if (xtrabackup_parallel > 1 && xtrabackup_stream &&
5659 xtrabackup_stream_fmt == XB_STREAM_FMT_TAR) {5683 xtrabackup_stream_fmt == XB_STREAM_FMT_TAR) {
5660 msg("xtrabackup: warning: the --parallel option does not have "5684 msg("xtrabackup: warning: the --parallel option does not have "

Subscribers

People subscribed via source and target branches