~akopytov/percona-xtrabackup/bugs-1177206-and-1187071-2.1

« back to all changes in this revision

Viewing changes to patches/innodb56.patch

  • Committer: Alexey Kopytov
  • Date: 2013-05-16 18:03:01 UTC
  • mfrom: (595.1.1 2.1)
  • Revision ID: akopytov@gmail.com-20130516180301-c23mooyxyglif3wh
MergedĀ lp:~akopytov/percona-xtrabackup/bug1079700-2.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
375
375
 
376
376
+       /* Ignore .isl files on XtraBackup recovery. All tablespaces must be
377
377
+       local. */
378
 
+       if (!recv_recovery_on) {
 
378
+       if (srv_backup_mode) {
379
379
        /* Check for a link file which locates a remote tablespace. */
380
380
        remote.success = fil_open_linked_file(
381
381
                tablename, &remote.filepath, &remote.file);
396
396
                ib_logf(IB_LOG_LEVEL_ERROR,
397
397
                        "The size of single-table tablespace file %s "
398
398
                        "is only " UINT64PF ", should be at least %lu!",
399
 
@@ -4263,7 +4390,7 @@
 
399
@@ -4243,7 +4370,51 @@
 
400
        }
 
401
 
 
402
 func_exit:
 
403
-       os_file_close(fsp->file);
 
404
+       /* We reuse file handles on the backup stage in XtraBackup to avoid
 
405
+       inconsistencies between the file name and the actual tablespace contents
 
406
+       if a DDL occurs between a fil_load_single_table_tablespaces() call and
 
407
+       the actual copy operation. */
 
408
+       if (srv_backup_mode) {
 
409
+
 
410
+               fil_node_t*     node;
 
411
+               fil_space_t*    space;
 
412
+
 
413
+               mutex_enter(&fil_system->mutex);
 
414
+
 
415
+               space = fil_space_get_by_id(fsp->id);
 
416
+
 
417
+               if (space) {
 
418
+                       node = UT_LIST_GET_LAST(space->chain);
 
419
+
 
420
+                       /* The handle will be closed by xtrabackup in
 
421
+                       xtrabackup_copy_datafile(). We set node->open to TRUE to
 
422
+                       make sure no one calls fil_node_open_file()
 
423
+                       (i.e. attempts to reopen the tablespace by name) during
 
424
+                       the backup stage. */
 
425
+
 
426
+                       node->open = TRUE;
 
427
+                       node->handle = fsp->file;
 
428
+
 
429
+                       /* The following is copied from fil_node_open_file() to
 
430
+                       pass fil_system validaty checks. We cannot use
 
431
+                       fil_node_open_file() directly, as that would re-open the
 
432
+                       file by name and create another file handle. */
 
433
+
 
434
+                       fil_system->n_open++;
 
435
+                       fil_n_file_opened++;
 
436
+
 
437
+                       if (fil_space_belongs_in_lru(space)) {
 
438
+
 
439
+                               /* Put the node to the LRU list */
 
440
+                               UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
 
441
+                       }
 
442
+               }
 
443
+
 
444
+               mutex_exit(&fil_system->mutex);
 
445
+       } else {
 
446
+
 
447
+               os_file_close(fsp->file);
 
448
+       }
 
449
 
 
450
 #ifdef UNIV_HOTBACKUP
 
451
 func_exit_after_close:
 
452
@@ -4263,7 +4434,7 @@
400
453
 idea is to read as much good data as we can and jump over bad data.
401
454
 @return 0 if ok, -1 if error even after the retries, 1 if at the end
402
455
 of the directory */
405
458
 int
406
459
 fil_file_readdir_next_file(
407
460
 /*=======================*/
408
 
@@ -4303,7 +4430,7 @@
 
461
@@ -4303,7 +4474,7 @@
409
462
 @return        DB_SUCCESS or error number */
410
463
 UNIV_INTERN
411
464
 dberr_t
414
467
 /*===================================*/
415
468
 {
416
469
        int             ret;
417
 
@@ -4359,7 +4486,9 @@
 
470
@@ -4359,7 +4530,9 @@
418
471
                            "%s/%s", fil_path_to_mysql_datadir, dbinfo.name);
419
472
                srv_normalize_path_for_win(dbpath);
420
473
 
425
478
 
426
479
                if (dbdir != NULL) {
427
480
 
428
 
@@ -4380,9 +4509,15 @@
 
481
@@ -4380,9 +4553,15 @@
429
482
                                    && (0 == strcmp(fileinfo.name
430
483
                                                   + strlen(fileinfo.name) - 4,
431
484
                                                   ".ibd")
433
486
+                                       /* Ignore .isl files on XtraBackup
434
487
+                                       recovery, all tablespaces must be
435
488
+                                       local. */
436
 
+                                       || (!recv_recovery_on &&
 
489
+                                       || (srv_backup_mode &&
437
490
+                                           0 == strcmp(fileinfo.name
438
491
                                                   + strlen(fileinfo.name) - 4,
439
492
-                                                  ".isl"))) {
443
496
                                        /* The name ends in .ibd or .isl;
444
497
                                        try opening the file */
445
498
                                        fil_load_single_table_tablespace(
446
 
@@ -4538,6 +4673,7 @@
 
499
@@ -4538,6 +4717,7 @@
447
500
 {
448
501
        fil_space_t*    fnamespace;
449
502
        fil_space_t*    space;
451
504
 
452
505
        ut_ad(fil_system);
453
506
 
454
 
@@ -4615,6 +4751,10 @@
 
507
@@ -4615,6 +4795,10 @@
455
508
                if (fnamespace == NULL) {
456
509
                        if (print_error_if_does_not_exist) {
457
510
                                fil_report_missing_tablespace(name, id);
462
515
                        }
463
516
                } else {
464
517
                        ut_print_timestamp(stderr);
465
 
@@ -4638,6 +4778,10 @@
 
518
@@ -4638,6 +4822,10 @@
466
519
 
467
520
                mutex_exit(&fil_system->mutex);
468
521
 
473
526
                return(FALSE);
474
527
        }
475
528
 
476
 
@@ -4728,6 +4872,7 @@
 
529
@@ -4728,6 +4916,7 @@
477
530
        ulint           page_size;
478
531
        ulint           pages_added;
479
532
        ibool           success;
481
534
 
482
535
        ut_ad(!srv_read_only_mode);
483
536
 
484
 
@@ -4772,13 +4917,17 @@
 
537
@@ -4772,13 +4961,17 @@
485
538
                goto retry;
486
539
        }
487
540
 
500
553
        start_page_no = space->size;
501
554
        file_start_page_no = space->size - node->size;
502
555
 
503
 
@@ -5024,7 +5173,7 @@
 
556
@@ -5024,7 +5217,7 @@
504
557
 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
505
558
 mutex. */
506
559
 static
509
562
 fil_node_prepare_for_io(
510
563
 /*====================*/
511
564
        fil_node_t*     node,   /*!< in: file node */
512
 
@@ -5044,9 +5193,12 @@
 
565
@@ -5044,9 +5237,12 @@
513
566
        }
514
567
 
515
568
        if (node->open == FALSE) {
523
576
        }
524
577
 
525
578
        if (node->n_pending == 0 && fil_space_belongs_in_lru(space)) {
526
 
@@ -5058,6 +5210,8 @@
 
579
@@ -5058,6 +5254,8 @@
527
580
        }
528
581
 
529
582
        node->n_pending++;
532
585
 }
533
586
 
534
587
 /********************************************************************//**
535
 
@@ -5259,6 +5413,16 @@
 
588
@@ -5259,6 +5457,16 @@
536
589
 
537
590
        ut_ad(mode != OS_AIO_IBUF || space->purpose == FIL_TABLESPACE);
538
591
 
549
602
        node = UT_LIST_GET_FIRST(space->chain);
550
603
 
551
604
        for (;;) {
552
 
@@ -5290,7 +5454,11 @@
 
605
@@ -5290,7 +5498,11 @@
553
606
        }
554
607
 
555
608
        /* Open file if closed */
562
615
 
563
616
        /* Check that at least the start offset is within the bounds of a
564
617
        single-table tablespace, including rollback tablespaces. */
565
 
@@ -6164,6 +6332,7 @@
 
618
@@ -6164,6 +6376,7 @@
566
619
        return(err);
567
620
 }
568
621
 
570
623
 /****************************************************************//**
571
624
 Generate redo logs for swapping two .ibd files */
572
625
 UNIV_INTERN
573
 
@@ -6187,4 +6356,4 @@
 
626
@@ -6187,4 +6400,4 @@
574
627
                         0, 0, new_name, old_name, &mtr);
575
628
        mtr_commit(&mtr);
576
629
 }
713
766
 Returns TRUE if a single-table tablespace does not exist in the memory cache,
714
767
--- a/storage/innobase/include/srv0srv.h
715
768
+++ b/storage/innobase/include/srv0srv.h
716
 
@@ -353,6 +353,9 @@
 
769
@@ -353,6 +353,11 @@
717
770
 extern ulong   srv_max_purge_lag_delay;
718
771
 
719
772
 extern ulong   srv_replication_delay;
720
773
+
721
774
+extern ibool   srv_apply_log_only;
722
775
+
 
776
+extern ibool   srv_backup_mode;
 
777
+
723
778
 /*-------------------------------------------*/
724
779
 
725
780
 extern ibool   srv_print_innodb_monitor;
814
869
 
815
870
                        lsn_t   end_lsn;
816
871
 
817
 
@@ -2413,7 +2424,7 @@
 
872
@@ -1868,6 +1879,18 @@
 
873
                        ulint   zip_size = fil_space_get_zip_size(space);
 
874
                        ulint   page_no = recv_addr->page_no;
 
875
 
 
876
+                       /* By now we have replayed all DDL log records from the
 
877
+                       current batch. Check if the space ID is still valid in
 
878
+                       the entry being processed, and ignore it if it is not.*/
 
879
+                       if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
 
880
+
 
881
+                               ut_a(recv_sys->n_addrs);
 
882
+
 
883
+                               recv_addr->state = RECV_PROCESSED;
 
884
+                               recv_sys->n_addrs--;
 
885
+
 
886
+                               continue;
 
887
+                       }
 
888
                        if (recv_addr->state == RECV_NOT_PROCESSED) {
 
889
                                if (!has_printed) {
 
890
                                        ib_logf(IB_LOG_LEVEL_INFO,
 
891
@@ -2413,7 +2436,7 @@
818
892
                           || type == MLOG_FILE_RENAME
819
893
                           || type == MLOG_FILE_DELETE) {
820
894
                        ut_a(space);
823
897
                        if (recv_replay_file_ops) {
824
898
 
825
899
                                /* In ibbackup --apply-log, replay an .ibd file
826
 
@@ -2436,7 +2447,7 @@
 
900
@@ -2436,7 +2459,7 @@
827
901
                                        ut_error;
828
902
                                }
829
903
                        }
832
906
                        /* In normal mysqld crash recovery we do not try to
833
907
                        replay file operations */
834
908
 #ifdef UNIV_LOG_LSN_DEBUG
835
 
@@ -2863,8 +2874,14 @@
 
909
@@ -2863,8 +2886,14 @@
836
910
 
837
911
                        fprintf(stderr,
838
912
                                "InnoDB: Doing recovery: scanned up to"
849
923
                }
850
924
        }
851
925
 
852
 
@@ -2964,7 +2981,7 @@
 
926
@@ -2964,7 +2993,7 @@
853
927
        ib_logf(IB_LOG_LEVEL_INFO,
854
928
                "Reading tablespace information from the .ibd files...");
855
929
 
858
932
 
859
933
        /* If we are using the doublewrite method, we will
860
934
        check if there are half-written pages in data files,
861
 
@@ -3456,7 +3473,8 @@
 
935
@@ -3456,7 +3485,8 @@
862
936
        that the data dictionary tables will be free of any locks.
863
937
        The data dictionary latch should guarantee that there is at
864
938
        most one data dictionary transaction active at a time. */
895
969
        tested with following crash point */
896
970
--- a/storage/innobase/srv/srv0srv.cc
897
971
+++ b/storage/innobase/srv/srv0srv.cc
898
 
@@ -349,6 +349,8 @@
 
972
@@ -349,6 +349,10 @@
899
973
 
900
974
 UNIV_INTERN ulong      srv_replication_delay           = 0;
901
975
 
902
976
+UNIV_INTERN ibool      srv_apply_log_only      = FALSE;
903
977
+
 
978
+UNIV_INTERN ibool      srv_backup_mode = FALSE;
 
979
+
904
980
 /*-------------------------------------------*/
905
981
 UNIV_INTERN ulong      srv_n_spin_wait_rounds  = 30;
906
982
 UNIV_INTERN ulong      srv_spin_wait_delay     = 6;
907
 
@@ -1808,7 +1810,8 @@
 
983
@@ -1808,7 +1812,8 @@
908
984
        if (ret == SRV_NONE
909
985
            && srv_shutdown_state != SRV_SHUTDOWN_NONE
910
986
            && trx_purge_state() != PURGE_STATE_DISABLED