~raghavendra-prabhu/percona-xtrabackup/Bug-1182995

« back to all changes in this revision

Viewing changes to patches/xtradb55.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:
356
356
        if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
357
357
                fprintf(stderr,
358
358
                        "InnoDB: Error: the size of single-table tablespace"
359
 
@@ -4299,7 +4402,7 @@
 
359
@@ -4288,7 +4391,51 @@
 
360
 
 
361
        fil_node_create(filepath, 0, space_id, FALSE);
 
362
 func_exit:
 
363
-       os_file_close(file);
 
364
+       /* We reuse file handles on the backup stage in XtraBackup to avoid
 
365
+       inconsistencies between the file name and the actual tablespace contents
 
366
+       if a DDL occurs between a fil_load_single_table_tablespaces() call and
 
367
+       the actual copy operation. */
 
368
+       if (srv_backup_mode) {
 
369
+
 
370
+               fil_node_t*     node;
 
371
+               fil_space_t*    space;
 
372
+
 
373
+               mutex_enter(&fil_system->mutex);
 
374
+
 
375
+               space = fil_space_get_by_id(space_id);
 
376
+
 
377
+               if (space) {
 
378
+                       node = UT_LIST_GET_LAST(space->chain);
 
379
+
 
380
+                       /* The handle will be closed by xtrabackup in
 
381
+                       xtrabackup_copy_datafile(). We set node->open to TRUE to
 
382
+                       make sure no one calls fil_node_open_file()
 
383
+                       (i.e. attempts to reopen the tablespace by name) during
 
384
+                       the backup stage. */
 
385
+
 
386
+                       node->open = TRUE;
 
387
+                       node->handle = file;
 
388
+
 
389
+                       /* The following is copied from fil_node_open_file() to
 
390
+                       pass fil_system validity checks. We cannot use
 
391
+                       fil_node_open_file() directly, as that would re-open the
 
392
+                       file by name and create another file handle. */
 
393
+
 
394
+                       fil_system->n_open++;
 
395
+
 
396
+                       if (space->purpose == FIL_TABLESPACE &&
 
397
+                           space->id != 0) {
 
398
+
 
399
+                               /* Put the node to the LRU list */
 
400
+                               UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
 
401
+                       }
 
402
+               }
 
403
+
 
404
+               mutex_exit(&fil_system->mutex);
 
405
+       } else {
 
406
+
 
407
+               os_file_close(file);
 
408
+       }
 
409
        ut_free(buf2);
 
410
        mem_free(filepath);
 
411
 }
 
412
@@ -4299,7 +4446,7 @@
360
413
 idea is to read as much good data as we can and jump over bad data.
361
414
 @return 0 if ok, -1 if error even after the retries, 1 if at the end
362
415
 of the directory */
365
418
 int
366
419
 fil_file_readdir_next_file(
367
420
 /*=======================*/
368
 
@@ -4343,7 +4446,7 @@
 
421
@@ -4343,7 +4490,7 @@
369
422
 @return        DB_SUCCESS or error number */
370
423
 UNIV_INTERN
371
424
 ulint
374
427
 /*===================================*/
375
428
 {
376
429
        int             ret;
377
 
@@ -4399,7 +4502,9 @@
 
430
@@ -4399,7 +4546,9 @@
378
431
                        dbinfo.name);
379
432
                srv_normalize_path_for_win(dbpath);
380
433
 
385
438
 
386
439
                if (dbdir != NULL) {
387
440
                        /* printf("Opened dir %s\n", dbinfo.name); */
388
 
@@ -4425,8 +4530,11 @@
 
441
@@ -4425,8 +4574,11 @@
389
442
                                                   ".ibd")) {
390
443
                                        /* The name ends in .ibd; try opening
391
444
                                        the file */
398
451
                                }
399
452
 next_file_item:
400
453
                                ret = fil_file_readdir_next_file(&err,
401
 
@@ -4598,15 +4706,97 @@
 
454
@@ -4598,15 +4750,97 @@
402
455
                                "InnoDB: in InnoDB data dictionary"
403
456
                                " has tablespace id %lu,\n"
404
457
                                "InnoDB: but tablespace with that id"
504
557
                } else {
505
558
                        ut_print_timestamp(stderr);
506
559
                        fputs("  InnoDB: Error: table ", stderr);
507
 
@@ -5005,7 +5195,7 @@
 
560
@@ -5005,7 +5239,7 @@
508
561
 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
509
562
 mutex. */
510
563
 static
513
566
 fil_node_prepare_for_io(
514
567
 /*====================*/
515
568
        fil_node_t*     node,   /*!< in: file node */
516
 
@@ -5025,10 +5215,13 @@
 
569
@@ -5025,10 +5259,13 @@
517
570
        }
518
571
 
519
572
        if (node->open == FALSE) {
528
581
        }
529
582
 
530
583
        if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
531
 
@@ -5041,6 +5234,8 @@
 
584
@@ -5041,6 +5278,8 @@
532
585
        }
533
586
 
534
587
        node->n_pending++;
537
590
 }
538
591
 
539
592
 /********************************************************************//**
540
 
@@ -5240,6 +5435,16 @@
 
593
@@ -5240,6 +5479,16 @@
541
594
 
542
595
        ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
543
596
 
691
744
 extern char    srv_adaptive_flushing;
692
745
 
693
746
 
694
 
@@ -247,6 +246,10 @@
 
747
@@ -247,6 +246,11 @@
695
748
 extern ulint   srv_dict_size_limit;
696
749
 
697
750
 extern ulint   srv_lazy_drop_table;
699
752
+extern ibool   srv_read_only;
700
753
+extern ibool   srv_fake_write;
701
754
+extern ibool   srv_apply_log_only;
 
755
+extern ibool   srv_backup_mode;
702
756
 /*-------------------------------------------*/
703
757
 
704
758
 extern ulint   srv_n_rows_inserted;
840
894
 
841
895
                        ib_uint64_t     end_lsn;
842
896
 
843
 
@@ -2380,7 +2388,7 @@
 
897
@@ -1842,6 +1850,18 @@
 
898
                        ulint   zip_size = fil_space_get_zip_size(space);
 
899
                        ulint   page_no = recv_addr->page_no;
 
900
 
 
901
+                       /* By now we have replayed all DDL log records from the
 
902
+                       current batch. Check if the space ID is still valid in
 
903
+                       the entry being processed, and ignore it if it is not.*/
 
904
+                       if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
 
905
+
 
906
+                               ut_a(recv_sys->n_addrs);
 
907
+
 
908
+                               recv_addr->state = RECV_PROCESSED;
 
909
+                               recv_sys->n_addrs--;
 
910
+
 
911
+                               goto next;
 
912
+                       }
 
913
                        if (recv_addr->state == RECV_NOT_PROCESSED) {
 
914
                                if (!has_printed) {
 
915
                                        ut_print_timestamp(stderr);
 
916
@@ -1875,7 +1895,7 @@
 
917
 
 
918
                                mutex_enter(&(recv_sys->mutex));
 
919
                        }
 
920
-
 
921
+next:
 
922
                        recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
 
923
                }
 
924
 
 
925
@@ -2380,7 +2400,7 @@
844
926
                           || type == MLOG_FILE_RENAME
845
927
                           || type == MLOG_FILE_DELETE) {
846
928
                        ut_a(space);
849
931
                        if (recv_replay_file_ops) {
850
932
 
851
933
                                /* In ibbackup --apply-log, replay an .ibd file
852
 
@@ -2403,7 +2411,7 @@
 
934
@@ -2403,7 +2423,7 @@
853
935
                                        ut_error;
854
936
                                }
855
937
                        }
858
940
                        /* In normal mysqld crash recovery we do not try to
859
941
                        replay file operations */
860
942
 #ifdef UNIV_LOG_LSN_DEBUG
861
 
@@ -2820,8 +2828,11 @@
 
943
@@ -2820,8 +2840,11 @@
862
944
 
863
945
                        fprintf(stderr,
864
946
                                "InnoDB: Doing recovery: scanned up to"
872
954
                }
873
955
        }
874
956
 
875
 
@@ -2926,7 +2929,7 @@
 
957
@@ -2926,7 +2949,7 @@
876
958
                "InnoDB: Reading tablespace information"
877
959
                " from the .ibd files...\n");
878
960
 
881
963
 
882
964
        /* If we are using the doublewrite method, we will
883
965
        check if there are half-written pages in data files,
884
 
@@ -2935,12 +2946,14 @@
 
966
@@ -2935,12 +2958,14 @@
885
967
 
886
968
        if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
887
969
 
897
979
        }
898
980
 }
899
981
 
900
 
@@ -3109,6 +3122,7 @@
 
982
@@ -3109,6 +3134,7 @@
901
983
                recv_sys->recovered_lsn = checkpoint_lsn;
902
984
 
903
985
                srv_start_lsn = checkpoint_lsn;
905
987
        }
906
988
 
907
989
        contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
908
 
@@ -3474,6 +3488,7 @@
 
990
@@ -3474,6 +3500,7 @@
909
991
        that the data dictionary tables will be free of any locks.
910
992
        The data dictionary latch should guarantee that there is at
911
993
        most one data dictionary transaction active at a time. */
1029
1111
 
1030
1112
 /* Try to flush dirty pages so as to avoid IO bursts at
1031
1113
 the checkpoints. */
1032
 
@@ -457,6 +451,10 @@
 
1114
@@ -457,6 +451,11 @@
1033
1115
 UNIV_INTERN ulint      srv_dict_size_limit = 0;
1034
1116
 
1035
1117
 UNIV_INTERN ulint      srv_lazy_drop_table = 0;
1037
1119
+UNIV_INTERN ibool      srv_read_only   = FALSE;
1038
1120
+UNIV_INTERN ibool      srv_fake_write  = FALSE;
1039
1121
+UNIV_INTERN ibool      srv_apply_log_only = FALSE;
 
1122
+UNIV_INTERN ibool      srv_backup_mode = FALSE;
1040
1123
 /*-------------------------------------------*/
1041
1124
 UNIV_INTERN ulong      srv_n_spin_wait_rounds  = 30;
1042
1125
 UNIV_INTERN ulong      srv_n_free_tickets_to_enter = 500;
1043
 
@@ -1137,7 +1135,7 @@
 
1126
@@ -1137,7 +1136,7 @@
1044
1127
        }
1045
1128
 
1046
1129
        /* Initialize some INFORMATION SCHEMA internal structures */
1049
1132
 }
1050
1133
 
1051
1134
 /*********************************************************************//**
1052
 
@@ -1148,6 +1146,7 @@
 
1135
@@ -1148,6 +1147,7 @@
1053
1136
 /*==========*/
1054
1137
 {
1055
1138
        os_fast_mutex_free(&srv_conc_mutex);
1057
1140
        mem_free(srv_conc_slots);
1058
1141
        srv_conc_slots = NULL;
1059
1142
 
1060
 
@@ -1161,6 +1160,7 @@
 
1143
@@ -1161,6 +1161,7 @@
1061
1144
        srv_mysql_table = NULL;
1062
1145
 
1063
1146
        trx_i_s_cache_free(trx_i_s_cache);
1065
1148
 }
1066
1149
 
1067
1150
 /*********************************************************************//**
1068
 
@@ -1886,7 +1886,7 @@
 
1151
@@ -1886,7 +1887,7 @@
1069
1152
                }
1070
1153
 
1071
1154
                /* Record the lock wait time for this thread */
1074
1157
        }
1075
1158
 
1076
1159
        if (trx->was_chosen_as_deadlock_victim) {
1077
 
@@ -2842,36 +2842,6 @@
 
1160
@@ -2842,36 +2843,6 @@
1078
1161
                old_sema = sema;
1079
1162
        }
1080
1163