464
464
if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
466
466
"InnoDB: Error: the size of single-table tablespace"
467
@@ -3476,7 +3581,7 @@
467
@@ -3465,7 +3570,51 @@
469
fil_node_create(filepath, 0, space_id, FALSE);
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) {
479
+ fil_space_t* space;
481
+ mutex_enter(&fil_system->mutex);
483
+ space = fil_space_get_by_id(space_id);
486
+ node = UT_LIST_GET_LAST(space->chain);
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. */
495
+ node->handle = file;
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. */
502
+ fil_system->n_open++;
504
+ if (space->purpose == FIL_TABLESPACE &&
507
+ /* Put the node to the LRU list */
508
+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
512
+ mutex_exit(&fil_system->mutex);
515
+ os_file_close(file);
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 */
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"
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
701
754
extern ulong srv_max_purge_lag;
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
/*-------------------------------------------*/
710
764
extern ulint srv_n_rows_inserted;
875
929
ib_uint64_t end_lsn;
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;
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)) {
940
+ ut_a(recv_sys->n_addrs);
942
+ recv_addr->state = RECV_PROCESSED;
943
+ recv_sys->n_addrs--;
947
if (recv_addr->state == RECV_NOT_PROCESSED) {
949
ut_print_timestamp(stderr);
950
@@ -1807,7 +1828,7 @@
952
mutex_enter(&(recv_sys->mutex));
956
recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
959
@@ -2308,7 +2329,7 @@
878
960
|| type == MLOG_FILE_RENAME
879
961
|| type == MLOG_FILE_DELETE) {
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. */
1024
1106
--- a/storage/innobase/srv/srv0srv.c
1025
1107
+++ b/storage/innobase/srv/srv0srv.c
1108
@@ -399,6 +399,10 @@
1028
1110
UNIV_INTERN ulong srv_replication_delay = 0;
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 @@
1039
1122
/* Initialize some INFORMATION SCHEMA internal structures */