43 #include "xtrabackup_api.h"
44 #ifndef UNIV_HOTBACKUP
50 static ulint srv_data_read, srv_data_written;
125 #ifdef UNIV_PFS_MUTEX
127 UNIV_INTERN mysql_pfs_key_t fil_system_mutex_key;
130 #ifdef UNIV_PFS_RWLOCK
132 UNIV_INTERN mysql_pfs_key_t fil_space_latch_key;
168 #define FIL_NODE_MAGIC_N 89389
208 ulint n_reserved_extents;
214 ulint n_pending_ibuf_merges;
221 hash_node_t name_hash;
222 #ifndef UNIV_HOTBACKUP
229 ibool is_in_unflushed_spaces;
237 #define FIL_SPACE_MAGIC_N 89472
247 #ifndef UNIV_HOTBACKUP
277 ulint max_assigned_id;
283 ib_int64_t tablespace_version;
293 ibool space_id_reuse_warned;
305 # define FIL_VALIDATE_SKIP 17
312 fil_validate_skip(
void)
317 static int fil_validate_count = FIL_VALIDATE_SKIP;
323 if (--fil_validate_count > 0) {
327 fil_validate_count = FIL_VALIDATE_SKIP;
341 fil_node_prepare_for_io(
351 fil_node_complete_io(
364 fil_get_space_id_for_table(
406 byte_offset, len, buf, message));
434 return(
fil_io(OS_FILE_WRITE, sync, space_id, zip_size, block_offset,
435 byte_offset, len, buf, message));
462 fil_space_get_by_name(
476 !strcmp(name, space->
name));
481 #ifndef UNIV_HOTBACKUP
493 ib_int64_t version = -1;
497 mutex_enter(&fil_system->
mutex);
499 space = fil_space_get_by_id(
id);
505 mutex_exit(&fil_system->
mutex);
524 mutex_enter(&fil_system->
mutex);
526 space = fil_space_get_by_id(
id);
531 *flags = space->
flags;
534 mutex_exit(&fil_system->
mutex);
536 return(&(space->
latch));
552 mutex_enter(&fil_system->
mutex);
554 space = fil_space_get_by_id(
id);
558 mutex_exit(&fil_system->
mutex);
570 fil_space_is_flushed(
611 mutex_enter(&fil_system->
mutex);
622 node->
magic_n = FIL_NODE_MAGIC_N;
629 space = fil_space_get_by_id(
id);
634 " InnoDB: Error: Could not find tablespace %lu for\n"
635 "InnoDB: file ", (ulong)
id);
637 fputs(
" in the tablespace memory cache.\n", stderr);
642 mutex_exit(&fil_system->
mutex);
653 if (id < SRV_LOG_SPACE_FIRST_ID && fil_system->max_assigned_id <
id) {
658 mutex_exit(&fil_system->
mutex);
686 if (node->
size == 0) {
695 node->
handle = os_file_create_simple_no_error_handling(
697 OS_FILE_READ_ONLY, &success);
705 " InnoDB: Fatal error: cannot open %s\n."
706 "InnoDB: Have you deleted .ibd files"
707 " under a running mysqld server?\n",
714 size_bytes = (((uint64_t)size_high) << 32) + size_low;
715 #ifdef UNIV_HOTBACKUP
716 if (space->
id == 0) {
717 node->
size = size_bytes / UNIV_PAGE_SIZE;
718 os_file_close(node->
handle);
727 "InnoDB: Error: the size of single-table"
728 " tablespace file %s\n"
729 "InnoDB: is only %lu %lu,"
730 " should be at least %lu!\n",
742 buf2 =
static_cast<unsigned char *
>(
ut_malloc(2 * UNIV_PAGE_SIZE));
745 page =
static_cast<unsigned char *
>(
ut_align(buf2, UNIV_PAGE_SIZE));
747 success = os_file_read(node->
handle, page, 0, 0,
756 os_file_close(node->
handle);
758 if (UNIV_UNLIKELY(space_id != space->
id)) {
760 "InnoDB: Error: tablespace id is %lu"
761 " in the data dictionary\n"
762 "InnoDB: but in file %s it is %lu!\n",
763 space->
id, node->
name, space_id);
768 if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED
771 "InnoDB: Error: tablespace id %lu"
772 " in file %s is not sensible\n",
773 (ulong) space_id, node->
name);
778 if (UNIV_UNLIKELY(space->
flags != flags)) {
780 "InnoDB: Error: table flags are %lx"
781 " in the data dictionary\n"
782 "InnoDB: but the flags in file %s are %lx!\n",
788 if (size_bytes >= 1024 * 1024) {
793 if (!(flags & DICT_TF_ZSSIZE_MASK)) {
794 node->
size = (ulint)size_bytes / UNIV_PAGE_SIZE;
801 #ifdef UNIV_HOTBACKUP
814 node->
handle = os_file_create(innodb_file_log_key,
816 OS_FILE_AIO, OS_LOG_FILE,
819 node->
handle = os_file_create(innodb_file_data_key,
825 node->
handle = os_file_create(innodb_file_data_key,
854 ut_ad(node && system);
861 ret = os_file_close(node->
handle);
888 fil_try_to_close_file_in_LRU(
901 "InnoDB: fil_sys open file LRU len %lu\n",
905 while (node != NULL) {
909 fil_node_close_file(node, fil_system);
915 fputs(
"InnoDB: cannot close file ", stderr);
917 fprintf(stderr,
", because n_pending_flushes %lu\n",
923 fputs(
"InnoDB: cannot close file ", stderr);
926 ", because mod_count %ld != fl_count %ld\n",
943 fil_mutex_enter_and_prepare_for_io(
949 ibool print_info = FALSE;
954 mutex_enter(&fil_system->
mutex);
971 space = fil_space_get_by_id(space_id);
973 if (space != NULL && space->
stop_ios) {
977 if (count2 > 20000) {
978 fputs(
"InnoDB: Warning: tablespace ", stderr);
981 " has i/o ops stopped for a long time %lu\n",
985 mutex_exit(&fil_system->
mutex);
1009 success = fil_try_to_close_file_in_LRU(print_info);
1025 " InnoDB: Warning: too many (%lu) files stay open"
1026 " while the maximum\n"
1027 "InnoDB: allowed value would be %lu.\n"
1028 "InnoDB: You may need to raise the value of"
1029 " innodb_open_files in\n"
1030 "InnoDB: my.cnf.\n",
1031 (ulong) fil_system->
n_open,
1037 mutex_exit(&fil_system->
mutex);
1039 #ifndef UNIV_HOTBACKUP
1066 ut_ad(node && system && space);
1078 && fil_space_is_flushed(space)) {
1083 system->unflushed_spaces,
1087 fil_node_close_file(node, system);
1098 #ifdef UNIV_LOG_ARCHIVE
1104 fil_space_truncate_start(
1114 mutex_enter(&fil_system->
mutex);
1116 space = fil_space_get_by_id(
id);
1120 while (trunc_len > 0) {
1123 ut_a(node->
size * UNIV_PAGE_SIZE <= trunc_len);
1125 trunc_len -= node->
size * UNIV_PAGE_SIZE;
1127 fil_node_free(node, fil_system, space);
1130 mutex_exit(&fil_system->
mutex);
1167 mutex_enter(&fil_system->
mutex);
1169 space = fil_space_get_by_name(name);
1171 if (UNIV_LIKELY_NULL(space)) {
1177 " InnoDB: Warning: trying to init to the"
1178 " tablespace memory cache\n"
1179 "InnoDB: a tablespace %lu of name ", (ulong)
id);
1181 fprintf(stderr,
",\n"
1182 "InnoDB: but a tablespace %lu of the same name\n"
1183 "InnoDB: already exists in the"
1184 " tablespace memory cache!\n",
1189 mutex_exit(&fil_system->
mutex);
1195 "InnoDB: We assume that InnoDB did a crash recovery,"
1197 "InnoDB: an .ibd file for which the table"
1198 " did not exist in the\n"
1199 "InnoDB: InnoDB internal data dictionary in the"
1201 "InnoDB: We assume that you later removed the"
1202 " .ibd and .frm files,\n"
1203 "InnoDB: and are now trying to recreate the table."
1204 " We now remove the\n"
1205 "InnoDB: conflicting tablespace object"
1206 " from the memory cache and try\n"
1207 "InnoDB: the init again.\n");
1209 namesake_id = space->
id;
1211 success = fil_space_free(namesake_id, FALSE);
1214 mutex_exit(&fil_system->
mutex);
1219 space = fil_space_get_by_id(
id);
1221 if (UNIV_LIKELY_NULL(space)) {
1223 "InnoDB: Error: trying to add tablespace %lu"
1224 " of name ", (ulong)
id);
1226 fprintf(stderr,
"\n"
1227 "InnoDB: to the tablespace memory cache,"
1229 "InnoDB: %lu of name ", (ulong) space->
id);
1231 fputs(
" already exists in the tablespace\n"
1232 "InnoDB: memory cache!\n", stderr);
1234 mutex_exit(&fil_system->
mutex);
1246 space->
mark = FALSE;
1250 if (!fil_system->space_id_reuse_warned) {
1251 fil_system->space_id_reuse_warned = TRUE;
1255 " InnoDB: Warning: allocated tablespace %lu,"
1256 " old maximum was %lu\n",
1269 space->
flags = flags;
1277 space->
magic_n = FIL_SPACE_MAGIC_N;
1289 mutex_exit(&fil_system->
mutex);
1308 mutex_enter(&fil_system->
mutex);
1312 if (id < fil_system->max_assigned_id) {
1321 "InnoDB: Warning: you are running out of new"
1322 " single-table tablespace id's.\n"
1323 "InnoDB: Current counter is %lu and it"
1324 " must not exceed %lu!\n"
1325 "InnoDB: To reset the counter to zero"
1326 " you have to dump all your tables and\n"
1327 "InnoDB: recreate the whole InnoDB installation.\n",
1339 "InnoDB: You have run out of single-table"
1340 " tablespace id's!\n"
1341 "InnoDB: Current counter is %lu.\n"
1342 "InnoDB: To reset the counter to zero you"
1343 " have to dump all your tables and\n"
1344 "InnoDB: recreate the whole InnoDB installation.\n",
1346 *space_id = ULINT_UNDEFINED;
1349 mutex_exit(&fil_system->
mutex);
1374 space = fil_space_get_by_id(
id);
1379 " InnoDB: Error: trying to remove tablespace %lu"
1380 " from the cache but\n"
1381 "InnoDB: it is not there.\n", (ulong)
id);
1388 tablespace = fil_space_get_by_name(space->
name);
1390 ut_a(space == tablespace);
1409 while (fil_node != NULL) {
1410 fil_node_free(fil_node, fil_system, space);
1418 rw_lock_x_unlock(&space->
latch);
1421 rw_lock_free(&(space->
latch));
1445 fil_mutex_enter_and_prepare_for_io(
id);
1447 space = fil_space_get_by_id(
id);
1449 if (space == NULL) {
1450 mutex_exit(&fil_system->
mutex);
1466 fil_node_prepare_for_io(node, fil_system, space);
1472 mutex_exit(&fil_system->
mutex);
1493 if (UNIV_UNLIKELY(!
id)) {
1497 fil_mutex_enter_and_prepare_for_io(
id);
1499 space = fil_space_get_by_id(
id);
1501 if (space == NULL) {
1502 mutex_exit(&fil_system->
mutex);
1504 return(ULINT_UNDEFINED);
1518 fil_node_prepare_for_io(node, fil_system, space);
1522 flags = space->
flags;
1524 mutex_exit(&fil_system->
mutex);
1543 if (flags && flags != ULINT_UNDEFINED) {
1579 ut_a(fil_system == NULL);
1581 ut_a(hash_size > 0);
1582 ut_a(max_n_open > 0);
1585 fil_system =
static_cast<fil_system_t *
>(fil_system_ptr);
1587 mutex_create(fil_system_mutex_key,
1588 &fil_system->
mutex, SYNC_ANY_LATCH);
1612 mutex_enter(&fil_system->
mutex);
1616 while (space != NULL) {
1620 while (node != NULL) {
1622 fil_node_open_file(node, fil_system,
1626 < 10 + fil_system->
n_open) {
1628 "InnoDB: Warning: you must"
1629 " raise the value of"
1630 " innodb_open_files in\n"
1631 "InnoDB: my.cnf! Remember that"
1632 " InnoDB keeps all log files"
1634 "InnoDB: tablespace files open"
1635 " for the whole time mysqld is"
1637 "InnoDB: needs to open also"
1638 " some .ibd files if the"
1639 " file-per-table storage\n"
1640 "InnoDB: model is used."
1641 " Current open files %lu,"
1643 " open files %lu.\n",
1644 (ulong) fil_system->
n_open,
1653 mutex_exit(&fil_system->
mutex);
1666 mutex_enter(&fil_system->
mutex);
1670 while (space != NULL) {
1679 fil_node_close_file(node, fil_system);
1685 fil_space_free(prev_space->
id, FALSE);
1688 mutex_exit(&fil_system->
mutex);
1702 "InnoDB: Fatal error: max tablespace id"
1703 " is too high, %lu\n", (ulong) max_id);
1707 mutex_enter(&fil_system->
mutex);
1714 mutex_exit(&fil_system->
mutex);
1723 fil_write_lsn_and_arch_no_to_file(
1734 buf1 =
static_cast<byte *
>(mem_alloc(2 * UNIV_PAGE_SIZE));
1735 buf =
static_cast<byte *
>(
ut_align(buf1, UNIV_PAGE_SIZE));
1737 fil_read(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1741 fil_write(TRUE, 0, 0, sum_of_sizes, 0, UNIV_PAGE_SIZE, buf, NULL);
1765 mutex_enter(&fil_system->
mutex);
1777 && space->
id == 0) {
1782 mutex_exit(&fil_system->
mutex);
1784 err = fil_write_lsn_and_arch_no_to_file(
1785 sum_of_sizes, lsn, arch_log_no);
1786 if (err != DB_SUCCESS) {
1791 mutex_enter(&fil_system->
mutex);
1793 sum_of_sizes += node->
size;
1800 mutex_exit(&fil_system->
mutex);
1813 ibool one_read_already,
1816 #ifdef UNIV_LOG_ARCHIVE
1817 ulint* min_arch_log_no,
1818 ulint* max_arch_log_no,
1820 ib_uint64_t* min_flushed_lsn,
1821 ib_uint64_t* max_flushed_lsn)
1825 ib_uint64_t flushed_lsn;
1827 buf2 =
static_cast<byte *
>(
ut_malloc(2 * UNIV_PAGE_SIZE));
1829 buf =
static_cast<byte *
>(
ut_align(buf2, UNIV_PAGE_SIZE));
1831 os_file_read(data_file, buf, 0, 0, UNIV_PAGE_SIZE);
1837 if (!one_read_already) {
1838 *min_flushed_lsn = flushed_lsn;
1839 *max_flushed_lsn = flushed_lsn;
1840 #ifdef UNIV_LOG_ARCHIVE
1841 *min_arch_log_no = arch_log_no;
1842 *max_arch_log_no = arch_log_no;
1847 if (*min_flushed_lsn > flushed_lsn) {
1848 *min_flushed_lsn = flushed_lsn;
1850 if (*max_flushed_lsn < flushed_lsn) {
1851 *max_flushed_lsn = flushed_lsn;
1853 #ifdef UNIV_LOG_ARCHIVE
1854 if (*min_arch_log_no > arch_log_no) {
1855 *min_arch_log_no = arch_log_no;
1857 if (*max_arch_log_no < arch_log_no) {
1858 *max_arch_log_no = arch_log_no;
1865 #ifndef UNIV_HOTBACKUP
1878 mutex_enter(&fil_system->
mutex);
1880 space = fil_space_get_by_id(
id);
1882 if (space == NULL) {
1884 "InnoDB: Error: trying to do ibuf merge to a"
1885 " dropped tablespace %lu\n",
1890 mutex_exit(&fil_system->
mutex);
1897 mutex_exit(&fil_system->
mutex);
1912 mutex_enter(&fil_system->
mutex);
1914 space = fil_space_get_by_id(
id);
1916 if (space == NULL) {
1918 "InnoDB: Error: decrementing ibuf merge of a"
1919 " dropped tablespace %lu\n",
1923 if (space != NULL) {
1927 mutex_exit(&fil_system->
mutex);
1935 fil_create_directory_for_tablename(
1945 namend = strchr(name,
'/');
1947 path =
static_cast<char *
>(mem_alloc(len + (namend - name) + 2));
1951 memcpy(path + len + 1, name, namend - name);
1952 path[len + (namend -
name) + 1] = 0;
1960 #ifndef UNIV_HOTBACKUP
1981 const char* new_name,
1998 type, space_id, log_flags, log_ptr, mtr);
2006 len = strlen(name) + 1;
2015 len = strlen(new_name) + 1;
2059 const char* new_name = NULL;
2063 if (end_ptr < ptr + 4) {
2072 if (end_ptr < ptr + 2) {
2081 if (end_ptr < ptr + name_len) {
2086 name = (
const char*) ptr;
2091 if (end_ptr < ptr + 2) {
2100 if (end_ptr < ptr + new_name_len) {
2105 new_name = (
const char*) ptr;
2107 ptr += new_name_len;
2149 fil_create_directory_for_tablename(new_name);
2154 if (fil_get_space_id_for_table(new_name)
2155 == ULINT_UNDEFINED) {
2171 }
else if (fil_get_space_id_for_table(name)
2172 != ULINT_UNDEFINED) {
2179 fil_create_directory_for_tablename(name);
2182 space_id, name, FALSE, flags,
2215 mutex_enter(&fil_system->
mutex);
2217 space = fil_space_get_by_id(
id);
2219 if (space != NULL) {
2223 mutex_exit(&fil_system->
mutex);
2231 fputs(
" InnoDB: Warning: trying to"
2232 " delete tablespace ", stderr);
2234 fprintf(stderr,
",\n"
2235 "InnoDB: but there are %lu pending"
2236 " ibuf merges on it.\n"
2237 "InnoDB: Loop %lu.\n",
2242 mutex_exit(&fil_system->
mutex);
2247 goto stop_ibuf_merges;
2251 mutex_exit(&fil_system->
mutex);
2255 mutex_enter(&fil_system->
mutex);
2257 space = fil_space_get_by_id(
id);
2259 if (space == NULL) {
2262 " InnoDB: Error: cannot delete tablespace %lu\n"
2263 "InnoDB: because it is not found in the"
2264 " tablespace memory cache.\n",
2267 mutex_exit(&fil_system->
mutex);
2283 fputs(
" InnoDB: Warning: trying to"
2284 " delete tablespace ", stderr);
2286 fprintf(stderr,
",\n"
2287 "InnoDB: but there are %lu flushes"
2288 " and %lu pending i/o's on it\n"
2289 "InnoDB: Loop %lu.\n",
2294 mutex_exit(&fil_system->
mutex);
2304 mutex_exit(&fil_system->
mutex);
2316 rw_lock_x_lock(&space->
latch);
2318 #ifndef UNIV_HOTBACKUP
2330 mutex_enter(&fil_system->
mutex);
2332 success = fil_space_free(
id, TRUE);
2334 mutex_exit(&fil_system->
mutex);
2343 rw_lock_x_unlock(&space->
latch);
2347 #ifndef UNIV_HOTBACKUP
2381 ibool is_being_deleted;
2383 mutex_enter(&fil_system->
mutex);
2385 space = fil_space_get_by_id(
id);
2387 ut_a(space != NULL);
2391 mutex_exit(&fil_system->
mutex);
2393 return(is_being_deleted);
2396 #ifndef UNIV_HOTBACKUP
2418 "InnoDB: Warning: cannot delete tablespace %lu"
2419 " in DISCARD TABLESPACE.\n"
2420 "InnoDB: But let us remove the"
2421 " insert buffer entries for this tablespace.\n",
2438 fil_rename_tablespace_in_mem(
2445 const char* old_name = space->
name;
2449 space2 = fil_space_get_by_name(old_name);
2450 if (space != space2) {
2451 fputs(
"InnoDB: Error: cannot find ", stderr);
2453 fputs(
" in tablespace memory cache\n", stderr);
2458 space2 = fil_space_get_by_name(path);
2459 if (space2 != NULL) {
2460 fputs(
"InnoDB: Error: ", stderr);
2462 fputs(
" is already in tablespace memory cache\n", stderr);
2492 ulint namelen = strlen(name);
2494 char* filename =
static_cast<char *
>(mem_alloc(namelen + dirlen +
sizeof "/.ibd"));
2497 memcpy(filename, name, namelen);
2498 memcpy(filename + namelen,
".ibd",
sizeof ".ibd");
2501 filename[dirlen] =
'/';
2503 memcpy(filename + dirlen + 1, name, namelen);
2504 memcpy(filename + dirlen + namelen + 1,
".ibd",
sizeof ".ibd");
2520 const char* old_name,
2525 const char* new_name)
2534 ibool old_name_was_specified = TRUE;
2539 if (old_name == NULL) {
2540 old_name =
"(name not specified)";
2541 old_name_was_specified = FALSE;
2548 fputs(
" InnoDB: Warning: problems renaming ", stderr);
2550 fputs(
" to ", stderr);
2552 fprintf(stderr,
", %lu iterations\n", (ulong) count);
2555 mutex_enter(&fil_system->
mutex);
2557 space = fil_space_get_by_id(
id);
2559 if (space == NULL) {
2561 "InnoDB: Error: cannot find space id %lu"
2562 " in the tablespace memory cache\n"
2563 "InnoDB: though the table ", (ulong)
id);
2565 fputs(
" in a rename operation should have that id\n", stderr);
2566 mutex_exit(&fil_system->
mutex);
2571 if (count > 25000) {
2573 mutex_exit(&fil_system->
mutex);
2591 mutex_exit(&fil_system->
mutex);
2600 mutex_exit(&fil_system->
mutex);
2608 }
else if (node->
open) {
2611 fil_node_close_file(node, fil_system);
2616 if (old_name_was_specified) {
2617 old_path = fil_make_ibd_name(old_name, FALSE);
2619 ut_a(strcmp(space->
name, old_path) == 0);
2620 ut_a(strcmp(node->
name, old_path) == 0);
2626 path = fil_make_ibd_name(new_name, FALSE);
2627 success = fil_rename_tablespace_in_mem(space, node, path);
2630 success = os_file_rename(innodb_file_data_key, old_path, path);
2636 ut_a(fil_rename_tablespace_in_mem(space, node,
2646 mutex_exit(&fil_system->
mutex);
2648 #ifndef UNIV_HOTBACKUP
2674 const char* tablename,
2705 path = fil_make_ibd_name(tablename, is_temp);
2707 file = os_file_create(innodb_file_data_key, path,
2708 OS_FILE_CREATE, OS_FILE_NORMAL,
2712 fputs(
" InnoDB: Error creating file ", stderr);
2714 fputs(
".\n", stderr);
2720 if (err == OS_FILE_ALREADY_EXISTS) {
2721 fputs(
"InnoDB: The file already exists though"
2722 " the corresponding table did not\n"
2723 "InnoDB: exist in the InnoDB data dictionary."
2724 " Have you moved InnoDB\n"
2725 "InnoDB: .ibd files around without using the"
2727 "InnoDB: DISCARD TABLESPACE and"
2728 " IMPORT TABLESPACE, or did\n"
2729 "InnoDB: mysqld crash in the middle of"
2730 " CREATE TABLE? You can\n"
2731 "InnoDB: resolve the problem by"
2732 " removing the file ", stderr);
2735 "InnoDB: under the 'datadir' of MySQL.\n",
2739 return(DB_TABLESPACE_ALREADY_EXISTS);
2742 if (err == OS_FILE_DISK_FULL) {
2745 return(DB_OUT_OF_FILE_SPACE);
2755 err = DB_OUT_OF_FILE_SPACE;
2757 os_file_close(file);
2776 buf2 =
static_cast<byte *
>(
ut_malloc(3 * UNIV_PAGE_SIZE));
2778 page =
static_cast<byte *
>(
ut_align(buf2, UNIV_PAGE_SIZE));
2780 memset(page,
'\0', UNIV_PAGE_SIZE);
2785 if (!(flags & DICT_TF_ZSSIZE_MASK)) {
2787 ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
2793 << ((flags & DICT_TF_ZSSIZE_MASK)
2797 page_zip.
data = page + UNIV_PAGE_SIZE;
2804 ret = os_file_write(path, file, page_zip.
data, 0, 0, zip_size);
2810 fputs(
"InnoDB: Error: could not write the first page"
2811 " to tablespace ", stderr);
2818 ret = os_file_flush(file);
2821 fputs(
"InnoDB: Error: file flush of tablespace ", stderr);
2823 fputs(
" failed\n", stderr);
2828 os_file_close(file);
2839 #ifndef UNIV_HOTBACKUP
2845 fil_op_write_log(flags
2851 tablename, NULL, &mtr);
2860 #ifndef UNIV_HOTBACKUP
2877 ib_uint64_t current_lsn)
2885 ib_uint64_t flush_lsn;
2887 ib_int64_t file_size;
2893 filepath = fil_make_ibd_name(name, FALSE);
2895 file = os_file_create_simple_no_error_handling(
2897 OS_FILE_READ_WRITE, &success);
2904 fputs(
" InnoDB: Error: trying to open a table,"
2906 "InnoDB: open the tablespace file ", stderr);
2908 fputs(
"!\n", stderr);
2916 buf2 =
static_cast<byte *
>(
ut_malloc(3 * UNIV_PAGE_SIZE));
2918 page =
static_cast<byte *
>(
ut_align(buf2, UNIV_PAGE_SIZE));
2920 success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
2930 if (current_lsn >= flush_lsn) {
2943 page_zip.
data = page + UNIV_PAGE_SIZE;
2948 " InnoDB: Flush lsn in the tablespace file %lu"
2950 "InnoDB: is %"PRIu64
", which exceeds current"
2951 " system lsn %"PRIu64
".\n"
2952 "InnoDB: We reset the lsn's in the file ",
2954 flush_lsn, current_lsn);
2956 fputs(
".\n", stderr);
2959 ut_a(zip_size <= UNIV_PAGE_SIZE);
2966 for (offset = 0; offset < file_size;
2967 offset += zip_size ? zip_size : UNIV_PAGE_SIZE) {
2968 success = os_file_read(file, page,
2969 (ulint)(offset & 0xFFFFFFFFUL),
2970 (ulint)(offset >> 32),
2971 zip_size ? zip_size : UNIV_PAGE_SIZE);
2980 memcpy(page_zip.
data, page, zip_size);
2982 page, &page_zip, current_lsn);
2983 success = os_file_write(
2984 filepath, file, page_zip.
data,
2985 (ulint) offset & 0xFFFFFFFFUL,
2986 (ulint) (offset >> 32), zip_size);
2989 page, NULL, current_lsn);
2990 success = os_file_write(
2991 filepath, file, page,
2992 (ulint)(offset & 0xFFFFFFFFUL),
2993 (ulint)(offset >> 32),
3004 success = os_file_flush(file);
3011 success = os_file_read(file, page, 0, 0,
3012 zip_size ? zip_size : UNIV_PAGE_SIZE);
3020 success = os_file_write(filepath, file, page, 0, 0,
3021 zip_size ? zip_size : UNIV_PAGE_SIZE);
3026 success = os_file_flush(file);
3028 os_file_close(file);
3049 ibool check_space_id,
3069 filepath = fil_make_ibd_name(name, FALSE);
3080 file = os_file_create_simple_no_error_handling(
3082 OS_FILE_READ_ONLY, &success);
3089 fputs(
" InnoDB: Error: trying to open a table,"
3091 "InnoDB: open the tablespace file ", stderr);
3094 "InnoDB: Have you moved InnoDB .ibd files around"
3095 " without using the\n"
3096 "InnoDB: commands DISCARD TABLESPACE and"
3097 " IMPORT TABLESPACE?\n"
3098 "InnoDB: It is also possible that this is"
3099 " a temporary table #sql...,\n"
3100 "InnoDB: and MySQL removed the .ibd file for this.\n"
3101 "InnoDB: Please refer to\n"
3102 "InnoDB: " REFMAN
"innodb-troubleshooting-datadict.html\n"
3103 "InnoDB: for how to resolve the issue.\n", stderr);
3110 if (!check_space_id) {
3118 buf2 =
static_cast<byte *
>(
ut_malloc(2 * UNIV_PAGE_SIZE));
3120 page =
static_cast<byte *
>(
ut_align(buf2, UNIV_PAGE_SIZE));
3122 success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
3131 if (UNIV_UNLIKELY(space_id !=
id
3135 fputs(
" InnoDB: Error: tablespace id and flags in file ",
3138 fprintf(stderr,
" are %lu and %lu, but in the InnoDB\n"
3139 "InnoDB: data dictionary they are %lu and %lu.\n"
3140 "InnoDB: Have you moved InnoDB .ibd files"
3141 " around without using the\n"
3142 "InnoDB: commands DISCARD TABLESPACE and"
3143 " IMPORT TABLESPACE?\n"
3144 "InnoDB: Please refer to\n"
3145 "InnoDB: " REFMAN
"innodb-troubleshooting-datadict.html\n"
3146 "InnoDB: for how to resolve the issue.\n",
3147 (ulong) space_id, (ulong) space_flags,
3148 (ulong)
id, (ulong) flags);
3167 os_file_close(file);
3174 #ifdef UNIV_HOTBACKUP
3181 fil_make_ibbackup_old_name(
3185 static const char suffix[] =
"_ibbackup_old_vers_";
3186 ulint len = strlen(name);
3187 char* path = mem_alloc(len + (15 +
sizeof suffix));
3189 memcpy(path, name, len);
3190 memcpy(path + len, suffix, (
sizeof suffix) - 1);
3191 ut_sprintf_timestamp_without_extra_chars(path + len +
sizeof suffix);
3201 fil_load_single_table_tablespace(
3204 const char* filename)
3217 #ifdef UNIV_HOTBACKUP
3220 filepath =
static_cast<char *
>(mem_alloc(strlen(dbname) + strlen(filename)
3227 # ifndef UNIV_HOTBACKUP
3237 file = os_file_create_simple_no_error_handling(
3239 OS_FILE_READ_ONLY, &success);
3245 "InnoDB: Error: could not open single-table tablespace"
3248 "InnoDB: We do not continue the crash recovery,"
3249 " because the table may become\n"
3250 "InnoDB: corrupt if we cannot apply the log records"
3251 " in the InnoDB log to it.\n"
3252 "InnoDB: To fix the problem and start mysqld:\n"
3253 "InnoDB: 1) If there is a permission problem"
3254 " in the file and mysqld cannot\n"
3255 "InnoDB: open the file, you should"
3256 " modify the permissions.\n"
3257 "InnoDB: 2) If the table is not needed, or you can"
3258 " restore it from a backup,\n"
3259 "InnoDB: then you can remove the .ibd file,"
3260 " and InnoDB will do a normal\n"
3261 "InnoDB: crash recovery and ignore that table.\n"
3262 "InnoDB: 3) If the file system or the"
3263 " disk is broken, and you cannot remove\n"
3264 "InnoDB: the .ibd file, you can set"
3265 " innodb_force_recovery > 0 in my.cnf\n"
3266 "InnoDB: and force InnoDB to continue crash"
3267 " recovery here.\n", filepath);
3271 if (srv_force_recovery > 0) {
3273 "InnoDB: innodb_force_recovery"
3274 " was set to %lu. Continuing crash recovery\n"
3275 "InnoDB: even though we cannot access"
3276 " the .ibd file of this table.\n",
3277 srv_force_recovery);
3291 "InnoDB: Error: could not measure the size"
3292 " of single-table tablespace file\n"
3294 "InnoDB: We do not continue crash recovery,"
3295 " because the table will become\n"
3296 "InnoDB: corrupt if we cannot apply the log records"
3297 " in the InnoDB log to it.\n"
3298 "InnoDB: To fix the problem and start mysqld:\n"
3299 "InnoDB: 1) If there is a permission problem"
3300 " in the file and mysqld cannot\n"
3301 "InnoDB: access the file, you should"
3302 " modify the permissions.\n"
3303 "InnoDB: 2) If the table is not needed,"
3304 " or you can restore it from a backup,\n"
3305 "InnoDB: then you can remove the .ibd file,"
3306 " and InnoDB will do a normal\n"
3307 "InnoDB: crash recovery and ignore that table.\n"
3308 "InnoDB: 3) If the file system or the disk is broken,"
3309 " and you cannot remove\n"
3310 "InnoDB: the .ibd file, you can set"
3311 " innodb_force_recovery > 0 in my.cnf\n"
3312 "InnoDB: and force InnoDB to continue"
3313 " crash recovery here.\n", filepath);
3315 os_file_close(file);
3318 if (srv_force_recovery > 0) {
3320 "InnoDB: innodb_force_recovery"
3321 " was set to %lu. Continuing crash recovery\n"
3322 "InnoDB: even though we cannot access"
3323 " the .ibd file of this table.\n",
3324 srv_force_recovery);
3337 size = (((ib_int64_t)size_high) << 32) + (ib_int64_t)size_low;
3338 #ifndef UNIV_HOTBACKUP
3341 "InnoDB: Error: the size of single-table tablespace"
3343 "InnoDB: is only %lu %lu, should be at least %lu!",
3346 (ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE));
3347 os_file_close(file);
3355 buf2 =
static_cast<byte *
>(
ut_malloc(2 * UNIV_PAGE_SIZE));
3357 page =
static_cast<byte *
>(
ut_align(buf2, UNIV_PAGE_SIZE));
3360 success = os_file_read(file, page, 0, 0, UNIV_PAGE_SIZE);
3367 space_id = ULINT_UNDEFINED;
3371 #ifndef UNIV_HOTBACKUP
3372 if (space_id == ULINT_UNDEFINED || space_id == 0) {
3374 "InnoDB: Error: tablespace id %lu in file %s"
3375 " is not sensible\n",
3381 if (space_id == ULINT_UNDEFINED || space_id == 0) {
3385 "InnoDB: Renaming tablespace %s of id %lu,\n"
3386 "InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
3387 "InnoDB: because its size %" PRId64
" is too small"
3388 " (< 4 pages 16 kB each),\n"
3389 "InnoDB: or the space id in the file header"
3390 " is not sensible.\n"
3391 "InnoDB: This can happen in an ibbackup run,"
3392 " and is not dangerous.\n",
3393 filepath, space_id, filepath, size);
3394 os_file_close(file);
3396 new_path = fil_make_ibbackup_old_name(filepath);
3397 ut_a(os_file_rename(innodb_file_data_key, filepath, new_path));
3413 mutex_enter(&fil_system->
mutex);
3415 space = fil_space_get_by_id(space_id);
3421 "InnoDB: Renaming tablespace %s of id %lu,\n"
3422 "InnoDB: to %s_ibbackup_old_vers_<timestamp>\n"
3423 "InnoDB: because space %s with the same id\n"
3424 "InnoDB: was scanned earlier. This can happen"
3425 " if you have renamed tables\n"
3426 "InnoDB: during an ibbackup run.\n",
3427 filepath, space_id, filepath,
3429 os_file_close(file);
3431 new_path = fil_make_ibbackup_old_name(filepath);
3433 mutex_exit(&fil_system->
mutex);
3435 ut_a(os_file_rename(innodb_file_data_key, filepath, new_path));
3443 mutex_exit(&fil_system->
mutex);
3449 if (srv_force_recovery > 0) {
3451 "InnoDB: innodb_force_recovery"
3452 " was set to %lu. Continuing crash recovery\n"
3453 "InnoDB: even though the tablespace creation"
3454 " of this table failed.\n",
3455 srv_force_recovery);
3468 os_file_close(file);
3480 fil_file_readdir_next_file(
3484 const char* dirname,
3491 for (i = 0; i < 100; i++) {
3500 "InnoDB: Error: os_file_readdir_next_file()"
3502 "InnoDB: directory %s\n"
3503 "InnoDB: Crash recovery may have failed"
3504 " for some .ibd files!\n", dirname);
3526 char* dbpath = NULL;
3527 ulint dbpath_len = 100;
3532 ulint err = DB_SUCCESS;
3543 dbpath =
static_cast<char *
>(mem_alloc(dbpath_len));
3554 if (dbinfo.
type == OS_FILE_TYPE_FILE
3555 || dbinfo.
type == OS_FILE_TYPE_UNKNOWN) {
3557 goto next_datadir_item;
3564 + strlen (dbinfo.
name) + 2;
3565 if (len > dbpath_len) {
3572 dbpath =
static_cast<char *
>(mem_alloc(dbpath_len));
3580 if (dbdir != NULL) {
3586 ret = fil_file_readdir_next_file(&err, dbpath, dbdir,
3592 if (fileinfo.
type == OS_FILE_TYPE_DIR) {
3594 goto next_file_item;
3598 if (strlen(fileinfo.
name) > 4
3599 && 0 == strcmp(fileinfo.
name
3600 + strlen(fileinfo.
name) - 4,
3604 fil_load_single_table_tablespace(
3608 ret = fil_file_readdir_next_file(&err,
3614 fputs(
"InnoDB: Warning: could not"
3615 " close database directory ", stderr);
3624 ret = fil_file_readdir_next_file(&err,
3633 "InnoDB: Error: could not close MySQL datadir\n");
3658 mutex_enter(&fil_system->
mutex);
3660 space = fil_space_get_by_id(
id);
3663 mutex_exit(&fil_system->
mutex);
3668 if (version != ((ib_int64_t)-1)
3670 mutex_exit(&fil_system->
mutex);
3675 mutex_exit(&fil_system->
mutex);
3693 mutex_enter(&fil_system->
mutex);
3695 space = fil_space_get_by_id(
id);
3697 mutex_exit(&fil_system->
mutex);
3699 return(space != NULL);
3723 ibool print_error_if_does_not_exist)
3735 mutex_enter(&fil_system->
mutex);
3737 path = fil_make_ibd_name(name, is_temp);
3741 space = fil_space_get_by_id(
id);
3746 tablespace = fil_space_get_by_name(path);
3747 if (space && space == tablespace) {
3755 mutex_exit(&fil_system->
mutex);
3760 if (!print_error_if_does_not_exist) {
3763 mutex_exit(&fil_system->
mutex);
3768 if (space == NULL) {
3769 if (tablespace == NULL) {
3771 fputs(
" InnoDB: Error: table ", stderr);
3773 fprintf(stderr,
"\n"
3774 "InnoDB: in InnoDB data dictionary"
3775 " has tablespace id %lu,\n"
3776 "InnoDB: but tablespace with that id"
3777 " or name does not exist. Have\n"
3778 "InnoDB: you deleted or moved .ibd files?\n"
3779 "InnoDB: This may also be a table created with"
3780 " CREATE TEMPORARY TABLE\n"
3781 "InnoDB: whose .ibd and .frm files"
3782 " MySQL automatically removed, but the\n"
3783 "InnoDB: table still exists in the"
3784 " InnoDB internal data dictionary.\n",
3788 fputs(
" InnoDB: Error: table ", stderr);
3790 fprintf(stderr,
"\n"
3791 "InnoDB: in InnoDB data dictionary has"
3792 " tablespace id %lu,\n"
3793 "InnoDB: but a tablespace with that id"
3794 " does not exist. There is\n"
3795 "InnoDB: a tablespace of name %s and id %lu,"
3797 "InnoDB: you deleted or moved .ibd files?\n",
3798 (ulong)
id, tablespace->
name,
3799 (ulong) tablespace->
id);
3802 fputs(
"InnoDB: Please refer to\n"
3803 "InnoDB: " REFMAN
"innodb-troubleshooting-datadict.html\n"
3804 "InnoDB: for how to resolve the issue.\n", stderr);
3807 mutex_exit(&fil_system->
mutex);
3812 if (0 != strcmp(space->
name, path)) {
3814 fputs(
" InnoDB: Error: table ", stderr);
3816 fprintf(stderr,
"\n"
3817 "InnoDB: in InnoDB data dictionary has"
3818 " tablespace id %lu,\n"
3819 "InnoDB: but the tablespace with that id"
3821 "InnoDB: Have you deleted or moved .ibd files?\n",
3822 (ulong)
id, space->
name);
3824 if (tablespace != NULL) {
3825 fputs(
"InnoDB: There is a tablespace"
3826 " with the right name\n"
3827 "InnoDB: ", stderr);
3829 fprintf(stderr,
", but its id is %lu.\n",
3830 (ulong) tablespace->
id);
3837 mutex_exit(&fil_system->
mutex);
3848 fil_get_space_id_for_table(
3854 ulint
id = ULINT_UNDEFINED;
3859 mutex_enter(&fil_system->
mutex);
3861 path = fil_make_ibd_name(name, FALSE);
3866 tablespace = fil_space_get_by_name(path);
3869 id = tablespace->
id;
3874 mutex_exit(&fil_system->
mutex);
3892 ulint size_after_extend)
3901 ulint start_page_no;
3902 ulint file_start_page_no;
3906 ibool success = TRUE;
3908 fil_mutex_enter_and_prepare_for_io(space_id);
3910 space = fil_space_get_by_id(space_id);
3913 if (space->
size >= size_after_extend) {
3916 *actual_size = space->
size;
3918 mutex_exit(&fil_system->
mutex);
3925 page_size = UNIV_PAGE_SIZE;
3930 fil_node_prepare_for_io(node, fil_system, space);
3932 start_page_no = space->
size;
3933 file_start_page_no = space->
size - node->
size;
3936 buf_size =
ut_min(64, size_after_extend - start_page_no) * page_size;
3937 buf2 =
static_cast<byte *
>(mem_alloc(buf_size + page_size));
3938 buf =
static_cast<byte *
>(
ut_align(buf2, page_size));
3940 memset(buf, 0, buf_size);
3942 while (start_page_no < size_after_extend) {
3943 ulint n_pages =
ut_min(buf_size / page_size,
3944 size_after_extend - start_page_no);
3946 offset_high = (start_page_no - file_start_page_no)
3947 / (4096 * ((1024 * 1024) / page_size));
3948 offset_low = ((start_page_no - file_start_page_no)
3949 % (4096 * ((1024 * 1024) / page_size)))
3951 #ifdef UNIV_HOTBACKUP
3952 success = os_file_write(node->
name, node->
handle, buf,
3953 offset_low, offset_high,
3954 page_size * n_pages);
3958 offset_low, offset_high,
3959 page_size * n_pages,
3963 node->
size += n_pages;
3964 space->
size += n_pages;
3966 os_has_said_disk_full = FALSE;
3974 / page_size)) - node->
size;
3976 node->
size += n_pages;
3977 space->
size += n_pages;
3982 start_page_no += n_pages;
3987 fil_node_complete_io(node, fil_system, OS_FILE_WRITE);
3989 *actual_size = space->
size;
3991 #ifndef UNIV_HOTBACKUP
3992 if (space_id == 0) {
3993 ulint pages_per_mb = (1024 * 1024) / page_size;
3998 srv_data_file_sizes[srv_n_data_files - 1]
3999 = (node->
size / pages_per_mb) * pages_per_mb;
4006 mutex_exit(&fil_system->
mutex);
4013 #ifdef UNIV_HOTBACKUP
4021 fil_extend_tablespaces_to_stored_len(
void)
4027 ulint size_in_header;
4031 buf = mem_alloc(UNIV_PAGE_SIZE);
4033 mutex_enter(&fil_system->
mutex);
4040 mutex_exit(&fil_system->
mutex);
4043 error = fil_read(TRUE, space->
id,
4045 0, 0, UNIV_PAGE_SIZE, buf, NULL);
4046 ut_a(error == DB_SUCCESS);
4051 &actual_size, space->
id, size_in_header);
4054 "InnoDB: Error: could not extend the"
4055 " tablespace of %s\n"
4056 "InnoDB: to the size stored in header,"
4058 "InnoDB: size after extension %lu pages\n"
4059 "InnoDB: Check that you have free disk space"
4061 space->
name, size_in_header, actual_size);
4065 mutex_enter(&fil_system->
mutex);
4070 mutex_exit(&fil_system->
mutex);
4094 mutex_enter(&fil_system->
mutex);
4096 space = fil_space_get_by_id(
id);
4107 mutex_exit(&fil_system->
mutex);
4125 mutex_enter(&fil_system->
mutex);
4127 space = fil_space_get_by_id(
id);
4134 mutex_exit(&fil_system->
mutex);
4151 mutex_enter(&fil_system->
mutex);
4153 space = fil_space_get_by_id(
id);
4159 mutex_exit(&fil_system->
mutex);
4175 fil_node_prepare_for_io(
4181 ut_ad(node && system && space);
4187 " InnoDB: Warning: open files %lu"
4188 " exceeds the limit %lu\n",
4193 if (node->
open == FALSE) {
4197 fil_node_open_file(node, system, space);
4201 && space->
id != 0) {
4217 fil_node_complete_io(
4233 if (type == OS_FILE_WRITE) {
4241 system->unflushed_spaces,
4257 fil_report_invalid_page_access(
4261 const char* space_name,
4267 "InnoDB: Error: trying to access page number %lu"
4269 "InnoDB: space name %s,\n"
4270 "InnoDB: which is outside the tablespace bounds.\n"
4271 "InnoDB: Byte offset %lu, len %lu, i/o type %lu.\n"
4272 "InnoDB: If you get this error at mysqld startup,"
4273 " please check that\n"
4274 "InnoDB: your my.cnf matches the ibdata files"
4275 " that you have in the\n"
4276 "InnoDB: MySQL server.\n",
4277 (ulong) block_offset, (ulong) space_id, space_name,
4278 (ulong) byte_offset, (ulong) len, (ulong) type);
4324 is_log = type & OS_FILE_LOG;
4325 type = type & ~OS_FILE_LOG;
4328 type = type & ~OS_AIO_SIMULATED_WAKE_LATER;
4330 ut_ad(byte_offset < UNIV_PAGE_SIZE);
4331 ut_ad(!zip_size || !byte_offset);
4335 ut_ad(fil_validate_skip());
4336 #ifndef UNIV_HOTBACKUP
4337 # ifndef UNIV_LOG_DEBUG
4345 }
else if (is_log) {
4349 &&
ibuf_page(space_id, zip_size, block_offset, NULL)) {
4360 srv_data_read+= len;
4361 }
else if (type == OS_FILE_WRITE) {
4362 srv_data_written+= len;
4368 fil_mutex_enter_and_prepare_for_io(space_id);
4370 space = fil_space_get_by_id(space_id);
4373 mutex_exit(&fil_system->
mutex);
4377 " InnoDB: Error: trying to do i/o"
4378 " to a tablespace which does not exist.\n"
4379 "InnoDB: i/o type %lu, space id %lu,"
4380 " page no. %lu, i/o length %lu bytes\n",
4381 (ulong) type, (ulong) space_id, (ulong) block_offset,
4384 return(DB_TABLESPACE_DELETED);
4392 if (UNIV_UNLIKELY(node == NULL)) {
4393 fil_report_invalid_page_access(
4394 block_offset, space_id, space->
name,
4395 byte_offset, len, type);
4400 if (space->
id != 0 && node->
size == 0) {
4407 if (node->
size > block_offset) {
4411 block_offset -= node->
size;
4417 fil_node_prepare_for_io(node, fil_system, space);
4421 if (UNIV_UNLIKELY(node->
size <= block_offset)
4424 fil_report_invalid_page_access(
4425 block_offset, space_id, space->
name, byte_offset,
4432 mutex_exit(&fil_system->
mutex);
4437 offset_high = (block_offset >> (32 - UNIV_PAGE_SIZE_SHIFT));
4438 offset_low = ((block_offset << UNIV_PAGE_SIZE_SHIFT)
4439 & 0xFFFFFFFFUL) + byte_offset;
4442 >= ((byte_offset + len + (UNIV_PAGE_SIZE - 1))
4445 ulint zip_size_shift;
4447 case 1024: zip_size_shift = 10;
break;
4448 case 2048: zip_size_shift = 11;
break;
4449 case 4096: zip_size_shift = 12;
break;
4450 case 8192: zip_size_shift = 13;
break;
4451 case 16384: zip_size_shift = 14;
break;
4454 offset_high = block_offset >> (32 - zip_size_shift);
4455 offset_low = (block_offset << zip_size_shift & 0xFFFFFFFFUL)
4458 >= (len + (zip_size - 1)) / zip_size);
4466 #ifdef UNIV_HOTBACKUP
4469 ret = os_file_read(node->
handle, buf, offset_low, offset_high,
4472 ret = os_file_write(node->
name, node->
handle, buf,
4473 offset_low, offset_high, len);
4477 ret = os_aio(type, mode | wake_later, node->
name, node->
handle, buf,
4478 offset_low, offset_high, len, node, message);
4486 mutex_enter(&fil_system->
mutex);
4488 fil_node_complete_io(node, fil_system, type);
4490 mutex_exit(&fil_system->
mutex);
4492 ut_ad(fil_validate_skip());
4513 fil_mutex_enter_and_prepare_for_io(space_id);
4515 space = fil_space_get_by_id(space_id);
4518 mutex_exit(&fil_system->
mutex);
4525 if (UNIV_UNLIKELY(node == NULL)) {
4526 mutex_exit(&fil_system->
mutex);
4530 if (space->
id != 0 && node->
size == 0) {
4537 if (node->
size > block_offset) {
4541 block_offset -= node->
size;
4547 fil_node_prepare_for_io(node, fil_system, space);
4552 if (UNIV_UNLIKELY(node->
size <= block_offset)
4554 mutex_exit(&fil_system->
mutex);
4558 mutex_exit(&fil_system->
mutex);
4562 #ifndef UNIV_HOTBACKUP
4580 ut_ad(fil_validate_skip());
4582 if (srv_use_native_aio) {
4585 ret = os_aio_windows_handle(segment, 0, &fil_node,
4587 #elif defined(LINUX_NATIVE_AIO)
4588 ret = os_aio_linux_handle(segment, &fil_node,
4605 mutex_enter(&fil_system->
mutex);
4607 fil_node_complete_io(fil_node, fil_system, type);
4609 mutex_exit(&fil_system->
mutex);
4611 ut_ad(fil_validate_skip());
4642 ib_int64_t old_mod_counter;
4644 mutex_enter(&fil_system->
mutex);
4646 space = fil_space_get_by_id(space_id);
4649 mutex_exit(&fil_system->
mutex);
4685 mutex_exit(&fil_system->
mutex);
4689 mutex_enter(&fil_system->
mutex);
4703 mutex_exit(&fil_system->
mutex);
4708 os_file_flush(file);
4710 mutex_enter(&fil_system->
mutex);
4718 && fil_space_is_flushed(space)) {
4724 fil_system->unflushed_spaces,
4741 mutex_exit(&fil_system->
mutex);
4758 mutex_enter(&fil_system->
mutex);
4761 if (n_space_ids == 0) {
4763 mutex_exit(&fil_system->
mutex);
4771 space_ids =
static_cast<unsigned long *
>(mem_alloc(n_space_ids *
sizeof *space_ids));
4781 space_ids[n_space_ids++] = space->
id;
4785 mutex_exit(&fil_system->
mutex);
4789 for (i = 0; i < n_space_ids; i++) {
4810 mutex_enter(&fil_system->
mutex);
4818 while (space != NULL) {
4820 ut_a(ut_list_node_313->open
4821 || !ut_list_node_313->n_pending));
4825 while (fil_node != NULL) {
4830 if (fil_node->
open) {
4845 while (fil_node != NULL) {
4854 mutex_exit(&fil_system->
mutex);
4931 #ifndef UNIV_HOTBACKUP
#define UT_LIST_GET_LEN(BASE)
UNIV_INTERN void log_io_complete(log_group_t *group)
ib_int64_t modification_counter
UNIV_INTERN ibool fil_extend_space_to_desired_size(ulint *actual_size, ulint space_id, ulint size_after_extend)
#define rw_lock_create(K, L, level)
#define UT_LIST_GET_NEXT(NAME, N)
#define FIL_IBD_FILE_INITIAL_SIZE
UNIV_INTERN ulint fil_io(ulint type, ibool sync, ulint space_id, ulint zip_size, ulint block_offset, ulint byte_offset, ulint len, void *buf, void *message)
UNIV_INTERN ibool os_file_create_directory(const char *pathname, ibool fail_if_exists)
UNIV_INLINE void mach_write_to_4(byte *b, ulint n)
#define UT_LIST_VALIDATE(NAME, TYPE, BASE, ASSERTION)
ulint n_pending_ibuf_merges
ib_int64_t tablespace_version
UNIV_INLINE void page_zip_des_init(page_zip_des_t *page_zip)
UNIV_INTERN ib_int64_t os_file_get_size_as_iblonglong(os_file_t file)
UNIV_INTERN ibool os_file_get_size(os_file_t file, ulint *size, ulint *size_high)
UNIV_INTERN void srv_set_io_thread_op_info(ulint i, const char *str)
UNIV_INTERN void ut_print_filename(FILE *f, const char *name)
UNIV_INTERN ibool fil_assign_new_space_id(ulint *space_id)
UNIV_INLINE void mlog_close(mtr_t *mtr, byte *ptr)
const char * fil_path_to_mysql_datadir
ib_int64_t tablespace_version
UNIV_INTERN ibool fil_open_single_table_tablespace(ibool check_space_id, ulint id, ulint flags, const char *name)
UNIV_INTERN ib_int64_t fil_space_get_version(ulint id)
UNIV_INTERN void * ut_malloc(ulint n)
UNIV_INTERN ibool os_file_delete_if_exists(const char *name)
UNIV_INLINE void mach_write_to_8(byte *b, ib_uint64_t n)
UNIV_INTERN void fil_flush(ulint space_id)
UNIV_INTERN byte * fil_op_log_parse_or_replay(byte *ptr, byte *end_ptr, ulint type, ulint space_id, ulint log_flags)
UNIV_INLINE ulint dict_table_flags_to_zip_size(ulint flags) __attribute__((const ))
ibool is_in_unflushed_spaces
UNIV_INTERN void fil_node_create(const char *name, ulint size, ulint id, ibool is_raw)
UNIV_INTERN hash_table_t * hash_create(ulint n)
UNIV_INTERN ulint fil_space_get_zip_size(ulint id)
#define FIL_PAGE_FILE_FLUSH_LSN
#define DICT_TF_ZSSIZE_SHIFT
UNIV_INTERN ibool fil_rename_tablespace(const char *old_name, ulint id, const char *new_name)
UNIV_INTERN void buf_flush_init_for_writing(byte *page, void *page_zip_, ib_uint64_t newest_lsn)
UNIV_INTERN int os_file_readdir_next_file(const char *dirname, os_file_dir_t dir, os_file_stat_t *info)
#define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)
UNIV_INTERN ulint fil_space_get_type(ulint id)
UNIV_INTERN rw_lock_t * fil_space_get_latch(ulint id, ulint *zip_size)
#define PAGE_ZIP_MIN_SIZE
UNIV_INTERN ulint fil_page_get_next(const byte *page)
UNIV_INTERN os_file_dir_t os_file_opendir(const char *dirname, ibool error_is_fatal)
UNIV_INTERN ibool os_aio_simulated_handle(ulint segment, fil_node_t **message1, void **message2, ulint *type)
UNIV_INTERN ulint fsp_get_size_low(page_t *page)
#define HASH_GET_NEXT(NAME, DATA)
UNIV_INTERN void hash_table_free(hash_table_t *table)
UNIV_INLINE ulint ut_min(ulint n1, ulint n2)
typedef UT_LIST_BASE_NODE_T(mutex_t) ut_list_base_node_t
UNIV_INTERN void mtr_commit(mtr_t *mtr) __attribute__((nonnull))
#define UT_LIST_REMOVE(NAME, BASE, N)
#define OS_FILE_LOG_BLOCK_SIZE
UNIV_INTERN void fil_init(ulint hash_size, ulint max_n_open)
#define MLOG_FILE_CREATE2
UNIV_INTERN void fil_close(void)
UNIV_INTERN ulint fsp_header_get_space_id(const page_t *page)
ibool srv_start_raw_disk_in_use
UNIV_INTERN void fil_page_set_type(byte *page, ulint type)
UNIV_INLINE void * ut_align(const void *ptr, ulint align_no)
UNIV_INTERN ulint fil_page_get_prev(const byte *page)
#define HASH_GET_FIRST(TABLE, HASH_VAL)
#define ut_2pow_round(n, m)
UNIV_INTERN int os_file_closedir(os_file_dir_t dir)
UNIV_INTERN void buf_page_io_complete(buf_page_t *bpage)
UNIV_INTERN void os_thread_sleep(ulint tm)
UNIV_INTERN ibool fil_inc_pending_ibuf_merges(ulint id)
UNIV_INTERN ulint fil_space_get_flags(ulint id)
UNIV_INTERN void fil_read_flushed_lsn_and_arch_log_no(os_file_t data_file, ibool one_read_already, ib_uint64_t *min_flushed_lsn, ib_uint64_t *max_flushed_lsn)
UNIV_INTERN ulint fsp_header_get_flags(const page_t *page)
UNIV_INTERN void mlog_catenate_string(mtr_t *mtr, const byte *str, ulint len)
UNIV_INLINE void page_zip_set_size(page_zip_des_t *page_zip, ulint size)
UNIV_INTERN void fil_close_all_files(void)
#define UT_LIST_GET_PREV(NAME, N)
UNIV_INTERN ulint fil_space_get_size(ulint id)
UNIV_INTERN ulint fil_create_new_single_table_tablespace(ulint space_id, const char *tablename, ibool is_temp, ulint flags, ulint size)
UNIV_INTERN void fil_set_max_space_id_if_bigger(ulint max_id)
UNIV_INTERN ulint fil_page_get_type(const byte *page)
UNIV_INTERN ulint os_file_get_last_error(ibool report_all_errors)
UNIV_INTERN void srv_normalize_path_for_win(char *str)
#define UT_LIST_ADD_LAST(NAME, BASE, N)
#define MLOG_FILE_FLAG_TEMP
#define UT_LIST_GET_FIRST(BASE)
UNIV_INTERN ibool os_file_delete(const char *name)
UNIV_INLINE byte * mlog_open(mtr_t *mtr, ulint size)
UNIV_INTERN ibool fil_tablespace_is_being_deleted(ulint id)
#define SRV_LOG_SPACE_FIRST_ID
UNIV_INTERN void fil_space_release_free_extents(ulint id, ulint n_reserved)
#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, ASSERTION, TEST)
ulint fil_n_pending_tablespace_flushes
UNIV_INTERN ibool os_file_set_size(const char *name, os_file_t file, ulint size, ulint size_high)
UNIV_INTERN void ut_free(void *ptr)
#define UT_LIST_INIT(BASE)
UNIV_INLINE ulint ut_fold_string(const char *str) __attribute__((pure))
UNIV_INTERN void fsp_header_init_fields(page_t *page, ulint space_id, ulint flags)
UNIV_INLINE char * mem_strdup(const char *str)
UNIV_INTERN ibool fil_space_create(const char *name, ulint id, ulint zip_size, ulint purpose)
UNIV_INTERN void fil_open_log_and_system_tablespace_files(void)
ibool recv_no_ibuf_operations
#define UT_LIST_ADD_FIRST(NAME, BASE, N)
UNIV_INLINE ulint mach_read_from_4(const byte *b) __attribute__((nonnull
UNIV_INTERN void fil_flush_file_spaces(ulint purpose)
UNIV_INTERN ibool fil_space_reserve_free_extents(ulint id, ulint n_free_now, ulint n_to_reserve)
UNIV_INTERN void ut_print_timestamp(FILE *file)
UNIV_INTERN ibool fil_reset_too_high_lsns(const char *name, ib_uint64_t current_lsn)
UNIV_INTERN void os_aio_simulated_wake_handler_threads(void)
UNIV_INTERN ulint fil_write_flushed_lsn_to_data_files(ib_uint64_t lsn, ulint arch_log_no)
UNIV_INLINE void mach_write_to_2(byte *b, ulint n)
UT_LIST_NODE_T(fil_node_t) chain
UNIV_INTERN void fil_aio_wait(ulint segment)
UNIV_INTERN void buf_LRU_invalidate_tablespace(ulint id)
UNIV_INTERN ibool fil_tablespace_deleted_or_being_deleted_in_mem(ulint id, ib_int64_t version)
UNIV_INLINE byte * mlog_write_initial_log_record_for_file_op(ulint type, ulint space_id, ulint page_no, byte *log_ptr, mtr_t *mtr)
UNIV_INLINE void mtr_start(mtr_t *mtr) __attribute__((nonnull))
#define ibuf_page(space, zip_size, page_no, mtr)
#define HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA)
UNIV_INTERN ibool fil_addr_is_null(fil_addr_t addr)
#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID
UNIV_INLINE ulint mach_read_from_2(const byte *b) __attribute__((nonnull
UNIV_INTERN void dict_casedn_str(char *a)
UNIV_INTERN bool fil_is_exist(ulint space_id, ulint block_offset)
UNIV_INTERN ulint fsp_header_get_zip_size(const page_t *page)
#define OS_AIO_SIMULATED_WAKE_LATER
char name[OS_FILE_MAX_PATH]
UNIV_INTERN void ibuf_delete_for_discarded_space(ulint space)
UNIV_INTERN ibool fil_discard_tablespace(ulint id)
ib_int64_t modification_counter
UNIV_INTERN ibool fil_space_for_table_exists_in_mem(ulint id, const char *name, ibool is_temp, ibool mark_space, ibool print_error_if_does_not_exist)
UNIV_INTERN ibool fil_check_adress_in_tablespace(ulint id, ulint page_no)
UNIV_INLINE ib_uint64_t mach_read_from_8(const byte *b) __attribute__((nonnull
ulint fil_n_pending_log_flushes
UNIV_INTERN ibool fil_delete_tablespace(ulint id)
UNIV_INTERN void fil_decr_pending_ibuf_merges(ulint id)
UNIV_INLINE ibool ibuf_bitmap_page(ulint zip_size, ulint page_no)
#define UT_LIST_GET_LAST(BASE)
UNIV_INTERN ibool fil_validate(void)
UNIV_INLINE ulint hash_get_n_cells(hash_table_t *table)
UNIV_INTERN ulint fil_space_get_n_reserved_extents(ulint id)
UNIV_INTERN ulint fil_load_single_table_tablespaces(void)
UNIV_INTERN ibool fil_tablespace_exists_in_mem(ulint id)