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

« back to all changes in this revision

Viewing changes to patches/innodb55.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:
464
464
        if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
465
465
                fprintf(stderr,
466
466
                        "InnoDB: Error: the size of single-table tablespace"
467
 
@@ -3476,7 +3581,7 @@
 
467
@@ -3465,7 +3570,51 @@
 
468
 
 
469
        fil_node_create(filepath, 0, space_id, FALSE);
 
470
 func_exit:
 
471
-       os_file_close(file);
 
472
+       /* We reuse file handles on the backup stage in XtraBackup to avoid
 
473
+       inconsistencies between the file name and the actual tablespace contents
 
474
+       if a DDL occurs between a fil_load_single_table_tablespaces() call and
 
475
+       the actual copy operation. */
 
476
+       if (srv_backup_mode) {
 
477
+
 
478
+               fil_node_t*     node;
 
479
+               fil_space_t*    space;
 
480
+
 
481
+               mutex_enter(&fil_system->mutex);
 
482
+
 
483
+               space = fil_space_get_by_id(space_id);
 
484
+
 
485
+               if (space) {
 
486
+                       node = UT_LIST_GET_LAST(space->chain);
 
487
+
 
488
+                       /* The handle will be closed by xtrabackup in
 
489
+                       xtrabackup_copy_datafile(). We set node->open to TRUE to
 
490
+                       make sure no one calls fil_node_open_file()
 
491
+                       (i.e. attempts to reopen the tablespace by name) during
 
492
+                       the backup stage. */
 
493
+
 
494
+                       node->open = TRUE;
 
495
+                       node->handle = file;
 
496
+
 
497
+                       /* The following is copied from fil_node_open_file() to
 
498
+                       pass fil_system validity checks. We cannot use
 
499
+                       fil_node_open_file() directly, as that would re-open the
 
500
+                       file by name and create another file handle. */
 
501
+
 
502
+                       fil_system->n_open++;
 
503
+
 
504
+                       if (space->purpose == FIL_TABLESPACE &&
 
505
+                           space->id != 0) {
 
506
+
 
507
+                               /* Put the node to the LRU list */
 
508
+                               UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
 
509
+                       }
 
510
+               }
 
511
+
 
512
+               mutex_exit(&fil_system->mutex);
 
513
+       } else {
 
514
+
 
515
+               os_file_close(file);
 
516
+       }
 
517
        ut_free(buf2);
 
518
        mem_free(filepath);
 
519
 }
 
520
@@ -3476,7 +3625,7 @@
468
521
 idea is to read as much good data as we can and jump over bad data.
469
522
 @return 0 if ok, -1 if error even after the retries, 1 if at the end
470
523
 of the directory */
473
526
 int
474
527
 fil_file_readdir_next_file(
475
528
 /*=======================*/
476
 
@@ -3520,7 +3625,7 @@
 
529
@@ -3520,7 +3669,7 @@
477
530
 @return        DB_SUCCESS or error number */
478
531
 UNIV_INTERN
479
532
 ulint
482
535
 /*===================================*/
483
536
 {
484
537
        int             ret;
485
 
@@ -3576,7 +3681,9 @@
 
538
@@ -3576,7 +3725,9 @@
486
539
                        dbinfo.name);
487
540
                srv_normalize_path_for_win(dbpath);
488
541
 
493
546
 
494
547
                if (dbdir != NULL) {
495
548
                        /* printf("Opened dir %s\n", dbinfo.name); */
496
 
@@ -3602,8 +3709,11 @@
 
549
@@ -3602,8 +3753,11 @@
497
550
                                                   ".ibd")) {
498
551
                                        /* The name ends in .ibd; try opening
499
552
                                        the file */
506
559
                                }
507
560
 next_file_item:
508
561
                                ret = fil_file_readdir_next_file(&err,
509
 
@@ -3775,15 +3885,97 @@
 
562
@@ -3775,15 +3929,97 @@
510
563
                                "InnoDB: in InnoDB data dictionary"
511
564
                                " has tablespace id %lu,\n"
512
565
                                "InnoDB: but tablespace with that id"
612
665
                } else {
613
666
                        ut_print_timestamp(stderr);
614
667
                        fputs("  InnoDB: Error: table ", stderr);
615
 
@@ -4172,7 +4364,7 @@
 
668
@@ -4172,7 +4408,7 @@
616
669
 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
617
670
 mutex. */
618
671
 static
621
674
 fil_node_prepare_for_io(
622
675
 /*====================*/
623
676
        fil_node_t*     node,   /*!< in: file node */
624
 
@@ -4192,10 +4384,13 @@
 
677
@@ -4192,10 +4428,13 @@
625
678
        }
626
679
 
627
680
        if (node->open == FALSE) {
636
689
        }
637
690
 
638
691
        if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
639
 
@@ -4208,6 +4403,8 @@
 
692
@@ -4208,6 +4447,8 @@
640
693
        }
641
694
 
642
695
        node->n_pending++;
645
698
 }
646
699
 
647
700
 /********************************************************************//**
648
 
@@ -4390,6 +4587,16 @@
 
701
@@ -4390,6 +4631,16 @@
649
702
 
650
703
        ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
651
704
 
697
750
 Returns TRUE if a single-table tablespace does not exist in the memory cache,
698
751
--- a/storage/innobase/include/srv0srv.h
699
752
+++ b/storage/innobase/include/srv0srv.h
700
 
@@ -218,6 +218,10 @@
 
753
@@ -218,6 +218,11 @@
701
754
 extern ulong   srv_max_purge_lag;
702
755
 
703
756
 extern ulong   srv_replication_delay;
705
758
+extern ibool   srv_read_only;
706
759
+extern ibool   srv_fake_write;
707
760
+extern ibool   srv_apply_log_only;
 
761
+extern ibool   srv_backup_mode;
708
762
 /*-------------------------------------------*/
709
763
 
710
764
 extern ulint   srv_n_rows_inserted;
874
928
 
875
929
                        ib_uint64_t     end_lsn;
876
930
 
877
 
@@ -2308,7 +2317,7 @@
 
931
@@ -1774,6 +1783,18 @@
 
932
                        ulint   zip_size = fil_space_get_zip_size(space);
 
933
                        ulint   page_no = recv_addr->page_no;
 
934
 
 
935
+                       /* By now we have replayed all DDL log records from the
 
936
+                       current batch. Check if the space ID is still valid in
 
937
+                       the entry being processed, and ignore it if it is not.*/
 
938
+                       if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
 
939
+
 
940
+                               ut_a(recv_sys->n_addrs);
 
941
+
 
942
+                               recv_addr->state = RECV_PROCESSED;
 
943
+                               recv_sys->n_addrs--;
 
944
+
 
945
+                               goto next;
 
946
+                       }
 
947
                        if (recv_addr->state == RECV_NOT_PROCESSED) {
 
948
                                if (!has_printed) {
 
949
                                        ut_print_timestamp(stderr);
 
950
@@ -1807,7 +1828,7 @@
 
951
 
 
952
                                mutex_enter(&(recv_sys->mutex));
 
953
                        }
 
954
-
 
955
+next:
 
956
                        recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
 
957
                }
 
958
 
 
959
@@ -2308,7 +2329,7 @@
878
960
                           || type == MLOG_FILE_RENAME
879
961
                           || type == MLOG_FILE_DELETE) {
880
962
                        ut_a(space);
883
965
                        if (recv_replay_file_ops) {
884
966
 
885
967
                                /* In ibbackup --apply-log, replay an .ibd file
886
 
@@ -2331,7 +2340,7 @@
 
968
@@ -2331,7 +2352,7 @@
887
969
                                        ut_error;
888
970
                                }
889
971
                        }
892
974
                        /* In normal mysqld crash recovery we do not try to
893
975
                        replay file operations */
894
976
 #ifdef UNIV_LOG_LSN_DEBUG
895
 
@@ -2748,8 +2757,11 @@
 
977
@@ -2748,8 +2769,11 @@
896
978
 
897
979
                        fprintf(stderr,
898
980
                                "InnoDB: Doing recovery: scanned up to"
906
988
                }
907
989
        }
908
990
 
909
 
@@ -2854,7 +2858,7 @@
 
991
@@ -2854,7 +2878,7 @@
910
992
                "InnoDB: Reading tablespace information"
911
993
                " from the .ibd files...\n");
912
994
 
915
997
 
916
998
        /* If we are using the doublewrite method, we will
917
999
        check if there are half-written pages in data files,
918
 
@@ -2863,12 +2875,14 @@
 
1000
@@ -2863,12 +2887,14 @@
919
1001
 
920
1002
        if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
921
1003
 
931
1013
        }
932
1014
 }
933
1015
 
934
 
@@ -3018,6 +3032,7 @@
 
1016
@@ -3018,6 +3044,7 @@
935
1017
                recv_sys->recovered_lsn = checkpoint_lsn;
936
1018
 
937
1019
                srv_start_lsn = checkpoint_lsn;
939
1021
        }
940
1022
 
941
1023
        contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
942
 
@@ -3299,6 +3314,7 @@
 
1024
@@ -3299,6 +3326,7 @@
943
1025
        that the data dictionary tables will be free of any locks.
944
1026
        The data dictionary latch should guarantee that there is at
945
1027
        most one data dictionary transaction active at a time. */
1023
1105
 }
1024
1106
--- a/storage/innobase/srv/srv0srv.c
1025
1107
+++ b/storage/innobase/srv/srv0srv.c
1026
 
@@ -399,6 +399,9 @@
 
1108
@@ -399,6 +399,10 @@
1027
1109
 
1028
1110
 UNIV_INTERN ulong      srv_replication_delay           = 0;
1029
1111
 
1030
1112
+UNIV_INTERN ibool      srv_read_only   = FALSE;
1031
1113
+UNIV_INTERN ibool      srv_fake_write  = FALSE;
1032
1114
+UNIV_INTERN ibool      srv_apply_log_only = FALSE;
 
1115
+UNIV_INTERN ibool      srv_backup_mode = FALSE;
1033
1116
 /*-------------------------------------------*/
1034
1117
 UNIV_INTERN ulong      srv_n_spin_wait_rounds  = 30;
1035
1118
 UNIV_INTERN ulong      srv_n_free_tickets_to_enter = 500;
1036
 
@@ -1078,7 +1081,7 @@
 
1119
@@ -1078,7 +1082,7 @@
1037
1120
        }
1038
1121
 
1039
1122
        /* Initialize some INFORMATION SCHEMA internal structures */
1042
1125
 }
1043
1126
 
1044
1127
 /*********************************************************************//**
1045
 
@@ -1089,6 +1092,7 @@
 
1128
@@ -1089,6 +1093,7 @@
1046
1129
 /*==========*/
1047
1130
 {
1048
1131
        os_fast_mutex_free(&srv_conc_mutex);
1050
1133
        mem_free(srv_conc_slots);
1051
1134
        srv_conc_slots = NULL;
1052
1135
 
1053
 
@@ -1102,6 +1106,7 @@
 
1136
@@ -1102,6 +1107,7 @@
1054
1137
        srv_mysql_table = NULL;
1055
1138
 
1056
1139
        trx_i_s_cache_free(trx_i_s_cache);
1058
1141
 }
1059
1142
 
1060
1143
 /*********************************************************************//**
1061
 
@@ -1717,7 +1722,7 @@
 
1144
@@ -1717,7 +1723,7 @@
1062
1145
                }
1063
1146
 
1064
1147
                /* Record the lock wait time for this thread */