376
376
+ /* Ignore .isl files on XtraBackup recovery. All tablespaces must be
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 @@
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) {
411
+ fil_space_t* space;
413
+ mutex_enter(&fil_system->mutex);
415
+ space = fil_space_get_by_id(fsp->id);
418
+ node = UT_LIST_GET_LAST(space->chain);
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. */
427
+ node->handle = fsp->file;
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. */
434
+ fil_system->n_open++;
435
+ fil_n_file_opened++;
437
+ if (fil_space_belongs_in_lru(space)) {
439
+ /* Put the node to the LRU list */
440
+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
444
+ mutex_exit(&fil_system->mutex);
447
+ os_file_close(fsp->file);
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 */
433
486
+ /* Ignore .isl files on XtraBackup
434
487
+ recovery, all tablespaces must be
436
+ || (!recv_recovery_on &&
489
+ || (srv_backup_mode &&
437
490
+ 0 == strcmp(fileinfo.name
438
491
+ strlen(fileinfo.name) - 4,
570
623
/****************************************************************//**
571
624
Generate redo logs for swapping two .ibd files */
573
@@ -6187,4 +6356,4 @@
626
@@ -6187,4 +6400,4 @@
574
627
0, 0, new_name, old_name, &mtr);
575
628
mtr_commit(&mtr);
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
717
770
extern ulong srv_max_purge_lag_delay;
719
772
extern ulong srv_replication_delay;
721
774
+extern ibool srv_apply_log_only;
776
+extern ibool srv_backup_mode;
723
778
/*-------------------------------------------*/
725
780
extern ibool srv_print_innodb_monitor;
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;
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)) {
881
+ ut_a(recv_sys->n_addrs);
883
+ recv_addr->state = RECV_PROCESSED;
884
+ recv_sys->n_addrs--;
888
if (recv_addr->state == RECV_NOT_PROCESSED) {
890
ib_logf(IB_LOG_LEVEL_INFO,
891
@@ -2413,7 +2436,7 @@
818
892
|| type == MLOG_FILE_RENAME
819
893
|| type == MLOG_FILE_DELETE) {
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
900
974
UNIV_INTERN ulong srv_replication_delay = 0;
902
976
+UNIV_INTERN ibool srv_apply_log_only = FALSE;
978
+UNIV_INTERN ibool srv_backup_mode = FALSE;
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