356
356
if (size < FIL_IBD_FILE_INITIAL_SIZE * (lint)UNIV_PAGE_SIZE) {
358
358
"InnoDB: Error: the size of single-table tablespace"
359
@@ -4299,7 +4402,7 @@
359
@@ -4288,7 +4391,51 @@
361
fil_node_create(filepath, 0, space_id, FALSE);
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) {
371
+ fil_space_t* space;
373
+ mutex_enter(&fil_system->mutex);
375
+ space = fil_space_get_by_id(space_id);
378
+ node = UT_LIST_GET_LAST(space->chain);
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. */
387
+ node->handle = file;
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. */
394
+ fil_system->n_open++;
396
+ if (space->purpose == FIL_TABLESPACE &&
399
+ /* Put the node to the LRU list */
400
+ UT_LIST_ADD_FIRST(LRU, fil_system->LRU, node);
404
+ mutex_exit(&fil_system->mutex);
407
+ os_file_close(file);
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 */
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"
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
/*-------------------------------------------*/
704
758
extern ulint srv_n_rows_inserted;
841
895
ib_uint64_t end_lsn;
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;
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)) {
906
+ ut_a(recv_sys->n_addrs);
908
+ recv_addr->state = RECV_PROCESSED;
909
+ recv_sys->n_addrs--;
913
if (recv_addr->state == RECV_NOT_PROCESSED) {
915
ut_print_timestamp(stderr);
916
@@ -1875,7 +1895,7 @@
918
mutex_enter(&(recv_sys->mutex));
922
recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
925
@@ -2380,7 +2400,7 @@
844
926
|| type == MLOG_FILE_RENAME
845
927
|| type == MLOG_FILE_DELETE) {
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. */
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 @@
1046
1129
/* Initialize some INFORMATION SCHEMA internal structures */