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

« back to all changes in this revision

Viewing changes to patches/innodb51.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:
474
474
        if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
475
475
                fprintf(stderr,
476
476
                        "InnoDB: Error: the size of single-table tablespace"
477
 
@@ -3425,7 +3530,7 @@
 
477
@@ -3414,7 +3519,51 @@
 
478
 
 
479
        fil_node_create(filepath, 0, space_id, FALSE);
 
480
 func_exit:
 
481
-       os_file_close(file);
 
482
+       /* We reuse file handles on the backup stage in XtraBackup to avoid
 
483
+       inconsistencies between the file name and the actual tablespace contents
 
484
+       if a DDL occurs between a fil_load_single_table_tablespaces() call and
 
485
+       the actual copy operation. */
 
486
+       if (srv_backup_mode) {
 
487
+
 
488
+               fil_node_t*     node;
 
489
+               fil_space_t*    space;
 
490
+
 
491
+               mutex_enter(&fil_system->mutex);
 
492
+
 
493
+               space = fil_space_get_by_id(space_id);
 
494
+
 
495
+               if (space) {
 
496
+                       node = UT_LIST_GET_LAST(space->chain);
 
497
+
 
498
+                       /* The handle will be closed by xtrabackup in
 
499
+                       xtrabackup_copy_datafile(). We set node->open to TRUE to
 
500
+                       make sure no one calls fil_node_open_file()
 
501
+                       (i.e. attempts to reopen the tablespace by name) during
 
502
+                       the backup stage. */
 
503
+
 
504
+                       node->open = TRUE;
 
505
+                       node->handle = file;
 
506
+
 
507
+                       /* The following is copied from fil_node_open_file() to
 
508
+                       pass fil_system validity checks. We cannot use
 
509
+                       fil_node_open_file() directly, as that would re-open the
 
510
+                       file by name and create another file handle. */
 
511
+
 
512
+                       fil_system->n_open++;
 
513
+
 
514
+                       if (space->purpose == FIL_TABLESPACE &&
 
515
+                           space->id != 0) {
 
516
+
 
517
+                               /* Put the node to the LRU list */
 
518
+                               UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
 
519
+                       }
 
520
+               }
 
521
+
 
522
+               mutex_exit(&fil_system->mutex);
 
523
+       } else {
 
524
+
 
525
+               os_file_close(file);
 
526
+       }
 
527
        ut_free(buf2);
 
528
        mem_free(filepath);
 
529
 }
 
530
@@ -3425,7 +3574,7 @@
478
531
 idea is to read as much good data as we can and jump over bad data.
479
532
 @return 0 if ok, -1 if error even after the retries, 1 if at the end
480
533
 of the directory */
483
536
 int
484
537
 fil_file_readdir_next_file(
485
538
 /*=======================*/
486
 
@@ -3469,7 +3574,7 @@
 
539
@@ -3469,7 +3618,7 @@
487
540
 @return        DB_SUCCESS or error number */
488
541
 UNIV_INTERN
489
542
 ulint
492
545
 /*===================================*/
493
546
 {
494
547
        int             ret;
495
 
@@ -3525,7 +3630,9 @@
 
548
@@ -3525,7 +3674,9 @@
496
549
                        dbinfo.name);
497
550
                srv_normalize_path_for_win(dbpath);
498
551
 
503
556
 
504
557
                if (dbdir != NULL) {
505
558
                        /* printf("Opened dir %s\n", dbinfo.name); */
506
 
@@ -3551,8 +3658,11 @@
 
559
@@ -3551,8 +3702,11 @@
507
560
                                                   ".ibd")) {
508
561
                                        /* The name ends in .ibd; try opening
509
562
                                        the file */
516
569
                                }
517
570
 next_file_item:
518
571
                                ret = fil_file_readdir_next_file(&err,
519
 
@@ -3724,15 +3834,97 @@
 
572
@@ -3724,15 +3878,97 @@
520
573
                                "InnoDB: in InnoDB data dictionary"
521
574
                                " has tablespace id %lu,\n"
522
575
                                "InnoDB: but tablespace with that id"
622
675
                } else {
623
676
                        ut_print_timestamp(stderr);
624
677
                        fputs("  InnoDB: Error: table ", stderr);
625
 
@@ -4121,7 +4313,7 @@
 
678
@@ -4121,7 +4357,7 @@
626
679
 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
627
680
 mutex. */
628
681
 static
631
684
 fil_node_prepare_for_io(
632
685
 /*====================*/
633
686
        fil_node_t*     node,   /*!< in: file node */
634
 
@@ -4141,10 +4333,13 @@
 
687
@@ -4141,10 +4377,13 @@
635
688
        }
636
689
 
637
690
        if (node->open == FALSE) {
646
699
        }
647
700
 
648
701
        if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
649
 
@@ -4157,6 +4352,8 @@
 
702
@@ -4157,6 +4396,8 @@
650
703
        }
651
704
 
652
705
        node->n_pending++;
655
708
 }
656
709
 
657
710
 /********************************************************************//**
658
 
@@ -4292,7 +4489,9 @@
 
711
@@ -4292,7 +4533,9 @@
659
712
        ut_ad(recv_no_ibuf_operations || (type == OS_FILE_WRITE)
660
713
              || !ibuf_bitmap_page(zip_size, block_offset)
661
714
              || sync || is_log);
666
719
              || ibuf_page(space_id, zip_size, block_offset, NULL));
667
720
 # endif /* UNIV_LOG_DEBUG */
668
721
        if (sync) {
669
 
@@ -4341,6 +4540,16 @@
 
722
@@ -4341,6 +4584,16 @@
670
723
 
671
724
        ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
672
725
 
740
793
 
741
794
--- a/storage/innodb_plugin/include/srv0srv.h
742
795
+++ b/storage/innodb_plugin/include/srv0srv.h
743
 
@@ -202,6 +202,10 @@
 
796
@@ -202,6 +202,11 @@
744
797
 extern ulong   srv_max_purge_lag;
745
798
 
746
799
 extern ulong   srv_replication_delay;
748
801
+extern ibool   srv_read_only;
749
802
+extern ibool   srv_fake_write;
750
803
+extern ibool   srv_apply_log_only;
 
804
+extern ibool   srv_backup_mode;
751
805
 /*-------------------------------------------*/
752
806
 
753
807
 extern ulint   srv_n_rows_inserted;
961
1015
 
962
1016
                        ib_uint64_t     end_lsn;
963
1017
 
964
 
@@ -2297,7 +2306,7 @@
 
1018
@@ -1762,6 +1771,18 @@
 
1019
                        ulint   zip_size = fil_space_get_zip_size(space);
 
1020
                        ulint   page_no = recv_addr->page_no;
 
1021
 
 
1022
+                       /* By now we have replayed all DDL log records from the
 
1023
+                       current batch. Check if the space ID is still valid in
 
1024
+                       the entry being processed, and ignore it if it is not.*/
 
1025
+                       if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
 
1026
+
 
1027
+                               ut_a(recv_sys->n_addrs);
 
1028
+
 
1029
+                               recv_addr->state = RECV_PROCESSED;
 
1030
+                               recv_sys->n_addrs--;
 
1031
+
 
1032
+                               goto next;
 
1033
+                       }
 
1034
                        if (recv_addr->state == RECV_NOT_PROCESSED) {
 
1035
                                if (!has_printed) {
 
1036
                                        ut_print_timestamp(stderr);
 
1037
@@ -1795,7 +1816,7 @@
 
1038
 
 
1039
                                mutex_enter(&(recv_sys->mutex));
 
1040
                        }
 
1041
-
 
1042
+next:
 
1043
                        recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
 
1044
                }
 
1045
 
 
1046
@@ -2297,7 +2318,7 @@
965
1047
                           || type == MLOG_FILE_RENAME
966
1048
                           || type == MLOG_FILE_DELETE) {
967
1049
                        ut_a(space);
970
1052
                        if (recv_replay_file_ops) {
971
1053
 
972
1054
                                /* In ibbackup --apply-log, replay an .ibd file
973
 
@@ -2320,7 +2329,7 @@
 
1055
@@ -2320,7 +2341,7 @@
974
1056
                                        ut_error;
975
1057
                                }
976
1058
                        }
979
1061
                        /* In normal mysqld crash recovery we do not try to
980
1062
                        replay file operations */
981
1063
 #ifdef UNIV_LOG_LSN_DEBUG
982
 
@@ -2737,8 +2746,11 @@
 
1064
@@ -2737,8 +2758,11 @@
983
1065
 
984
1066
                        fprintf(stderr,
985
1067
                                "InnoDB: Doing recovery: scanned up to"
993
1075
                }
994
1076
        }
995
1077
 
996
 
@@ -2841,7 +2845,7 @@
 
1078
@@ -2841,7 +2865,7 @@
997
1079
                "InnoDB: Reading tablespace information"
998
1080
                " from the .ibd files...\n");
999
1081
 
1002
1084
 
1003
1085
        /* If we are using the doublewrite method, we will
1004
1086
        check if there are half-written pages in data files,
1005
 
@@ -2850,12 +2862,14 @@
 
1087
@@ -2850,12 +2874,14 @@
1006
1088
 
1007
1089
        if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
1008
1090
 
1018
1100
        }
1019
1101
 }
1020
1102
 
1021
 
@@ -3005,6 +3019,7 @@
 
1103
@@ -3005,6 +3031,7 @@
1022
1104
                recv_sys->recovered_lsn = checkpoint_lsn;
1023
1105
 
1024
1106
                srv_start_lsn = checkpoint_lsn;
1026
1108
        }
1027
1109
 
1028
1110
        contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
1029
 
@@ -3286,6 +3301,7 @@
 
1111
@@ -3286,6 +3313,7 @@
1030
1112
        that the data dictionary tables will be free of any locks.
1031
1113
        The data dictionary latch should guarantee that there is at
1032
1114
        most one data dictionary transaction active at a time. */
1111
1193
 
1112
1194
--- a/storage/innodb_plugin/srv/srv0srv.c
1113
1195
+++ b/storage/innodb_plugin/srv/srv0srv.c
1114
 
@@ -374,6 +374,9 @@
 
1196
@@ -374,6 +374,10 @@
1115
1197
 
1116
1198
 UNIV_INTERN ulong      srv_replication_delay           = 0;
1117
1199
 
1118
1200
+UNIV_INTERN ibool      srv_read_only   = FALSE;
1119
1201
+UNIV_INTERN ibool      srv_fake_write  = FALSE;
1120
1202
+UNIV_INTERN ibool      srv_apply_log_only = FALSE;
 
1203
+UNIV_INTERN ibool      srv_backup_mode = FALSE;
1121
1204
 /*-------------------------------------------*/
1122
1205
 UNIV_INTERN ulong      srv_n_spin_wait_rounds  = 30;
1123
1206
 UNIV_INTERN ulong      srv_n_free_tickets_to_enter = 500;
1124
 
@@ -1002,7 +1005,7 @@
 
1207
@@ -1002,7 +1006,7 @@
1125
1208
        }
1126
1209
 
1127
1210
        /* Initialize some INFORMATION SCHEMA internal structures */
1130
1213
 }
1131
1214
 
1132
1215
 /*********************************************************************//**
1133
 
@@ -1013,6 +1016,7 @@
 
1216
@@ -1013,6 +1017,7 @@
1134
1217
 /*==========*/
1135
1218
 {
1136
1219
        os_fast_mutex_free(&srv_conc_mutex);
1138
1221
        mem_free(srv_conc_slots);
1139
1222
        srv_conc_slots = NULL;
1140
1223
 
1141
 
@@ -1026,6 +1030,7 @@
 
1224
@@ -1026,6 +1031,7 @@
1142
1225
        srv_mysql_table = NULL;
1143
1226
 
1144
1227
        trx_i_s_cache_free(trx_i_s_cache);
1410
1493
 
1411
1494
        UNIV_MEM_FREE(buf, n);
1412
1495
 }
 
1496
--- a/configure.in
 
1497
+++ b/configure.in
 
1498
@@ -22,7 +22,7 @@
 
1499
 AM_INIT_AUTOMAKE([1.9 tar-ustar])
 
1500
 AC_PROG_LIBTOOL
 
1501
 
 
1502
-AM_CONFIG_HEADER([include/config.h])
 
1503
+AC_CONFIG_HEADERS([include/config.h])
 
1504
 
 
1505
 # Request support for automake silent-rules if available.
 
1506
 # Default to verbose output. One can use the configure-time