45#include "xtrabackup_api.h"
58UNIV_INTERN ibool recv_replay_file_ops = TRUE;
61#include <boost/scoped_array.hpp>
63#include <drizzled/errmsg_print.h>
67#define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
70#define RECV_READ_AHEAD_AREA 32
78#ifdef UNIV_LOG_ARCHIVE
80UNIV_INTERN ibool recv_recovery_from_backup_on;
89UNIV_INTERN ibool recv_no_log_write = FALSE;
105static ibool recv_log_scan_is_startup_type;
118# define recv_is_making_a_backup FALSE
120# define recv_is_from_backup FALSE
122# define recv_needed_recovery FALSE
124UNIV_INTERN ibool recv_is_making_a_backup = FALSE;
126UNIV_INTERN ibool recv_is_from_backup = FALSE;
127# define buf_pool_get_curr_size() (5 * 1024 * 1024)
131static ulint recv_scan_print_counter;
134static ulint recv_previous_parsed_rec_type;
136static ulint recv_previous_parsed_rec_offset;
138static ulint recv_previous_parsed_rec_is_multi;
154UNIV_INTERN ib_uint64_t recv_max_page_lsn;
156#ifdef UNIV_PFS_THREAD
157UNIV_INTERN mysql_pfs_key_t trx_rollback_clean_thread_key;
161UNIV_INTERN mysql_pfs_key_t recv_sys_mutex_key;
166#ifndef UNIV_HOTBACKUP
172recv_init_crash_recovery(
void);
191 mutex_create(recv_sys_mutex_key, &
recv_sys->mutex, SYNC_RECV);
206 hash_table_free(
recv_sys->addr_hash);
217 if (
recv_sys->last_block_buf_start != NULL) {
237 hash_table_free(
recv_sys->addr_hash);
248 if (
recv_sys->last_block_buf_start != NULL) {
257#ifndef UNIV_HOTBACKUP
271#ifdef UNIV_LOG_ARCHIVE
272 recv_recovery_from_backup_on = FALSE;
279 recv_log_scan_is_startup_type = FALSE;
283 recv_scan_print_counter = 0;
285 recv_previous_parsed_rec_type = 999999;
287 recv_previous_parsed_rec_offset = 0;
289 recv_previous_parsed_rec_is_multi = 0;
295 recv_max_page_lsn = 0;
305 ulint available_memory)
312#ifndef UNIV_HOTBACKUP
317#ifndef UNIV_HOTBACKUP
326 recv_is_from_backup = TRUE;
339 recv_sys->addr_hash = hash_create(available_memory / 512);
349 recv_sys->found_corrupt_log = FALSE;
351 recv_max_page_lsn = 0;
360recv_sys_empty_hash(
void)
366 drizzled::errmsg_printf(drizzled::error::ERROR,
367 "InnoDB: Error: %lu pages with log records were left unprocessed!\n"
368 "InnoDB: Maximum page number with log records on it %lu\n",
374 hash_table_free(
recv_sys->addr_hash);
380#ifndef UNIV_HOTBACKUP
381# ifndef UNIV_LOG_DEBUG
386recv_sys_debug_free(
void)
391 hash_table_free(
recv_sys->addr_hash);
399 recv_sys->last_block_buf_start = NULL;
415 ib_uint64_t recovered_lsn,
417 ib_uint64_t limit_lsn,
419 ib_uint64_t checkpoint_lsn,
421 ib_uint64_t archived_lsn)
424 ib_uint64_t start_lsn;
426 ib_uint64_t finish_lsn1;
427 ib_uint64_t finish_lsn2;
428 ib_uint64_t finish_lsn;
432 if (archived_lsn == IB_ULONGLONG_MAX) {
434 archived_lsn = checkpoint_lsn;
445 if (limit_lsn != IB_ULONGLONG_MAX) {
449 finish_lsn = finish_lsn1;
452 finish_lsn = finish_lsn1 < finish_lsn2
453 ? finish_lsn1 : finish_lsn2;
461 *(log_sys->buf + i) =
'\0';
467 if (start_lsn != recovered_lsn) {
474 (ulint) (recovered_lsn - start_lsn));
477 if (start_lsn >= finish_lsn) {
485 if (end_lsn > finish_lsn) {
487 end_lsn = finish_lsn;
490 len = (ulint) (end_lsn - start_lsn);
493 if (end_lsn >= finish_lsn) {
501 *(log_sys->buf + i) =
'\0';
519 ib_uint64_t recovered_lsn)
522 ib_uint64_t start_lsn;
538 if (end_lsn > recovered_lsn) {
544 up_to_date_group, start_lsn, end_lsn);
546 len = (ulint) (end_lsn - start_lsn);
550 if (end_lsn >= recovered_lsn) {
566recv_synchronize_groups(
572 ib_uint64_t start_lsn;
574 ib_uint64_t recovered_lsn;
576 recovered_lsn =
recv_sys->recovered_lsn;
585 ut_a(start_lsn != end_lsn);
588 up_to_date_group, start_lsn, end_lsn);
593 if (group != up_to_date_group) {
597 recv_copy_group(group, up_to_date_group,
616 mutex_exit(&(log_sys->mutex));
620 rw_lock_s_unlock(&(log_sys->checkpoint_lock));
622 mutex_enter(&(log_sys->mutex));
630recv_check_cp_is_consistent(
639 buf + LOG_CHECKPOINT_CHECKSUM_1)) {
644 LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN);
647 buf + LOG_CHECKPOINT_CHECKSUM_2)) {
654#ifndef UNIV_HOTBACKUP
659recv_find_max_checkpoint(
667 ib_uint64_t checkpoint_no;
680 group->
state = LOG_GROUP_CORRUPTED;
682 for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
683 field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {
687 if (!recv_check_cp_is_consistent(buf)) {
689 if (log_debug_writes) {
690 drizzled::errmsg_printf(drizzled::error::INFO,
691 "InnoDB: Checkpoint in group %lu at %lu invalid, %lu\n",
696 + LOG_CHECKPOINT_CHECKSUM_1));
703 group->
state = LOG_GROUP_OK;
706 buf + LOG_CHECKPOINT_LSN);
708#ifdef UNIV_LOG_ARCHIVE
709#error "UNIV_LOG_ARCHIVE could not be enabled"
713 buf + LOG_CHECKPOINT_ARCHIVED_LSN);
714 if (
sizeof(ulint) != 4
715 && tmp_lsn_offset != IB_ULONGLONG_MAX) {
719 buf + LOG_CHECKPOINT_OFFSET);
724 buf + LOG_CHECKPOINT_NO);
727 if (log_debug_writes) {
728 drizzled::errmsg_printf(drizzled::error::INFO,
729 "InnoDB: Checkpoint number %lu found in group %lu\n",
730 (ulong) checkpoint_no,
735 if (checkpoint_no >= max_no) {
738 max_no = checkpoint_no;
748 if (*max_group == NULL) {
750 drizzled::errmsg_printf(drizzled::error::ERROR,
751 "InnoDB: No valid checkpoint found. If this error appears when you are"
752 " creating an InnoDB database,InnoDB: the problem may be that during"
753 " an earlier attempt you managed to create the InnoDB data files,"
754 " but log file creation failed. If that is the case, please refer to\n"
755 "InnoDB: " REFMAN
"error-creating-innodb.html\n");
767recv_read_cp_info_for_backup(
777 ib_uint64_t* first_header_lsn)
782 ib_uint64_t max_cp_no = 0;
785 cp_buf = hdr + LOG_CHECKPOINT_1;
787 if (recv_check_cp_is_consistent(cp_buf)) {
789 max_cp = LOG_CHECKPOINT_1;
792 cp_buf = hdr + LOG_CHECKPOINT_2;
794 if (recv_check_cp_is_consistent(cp_buf)) {
796 max_cp = LOG_CHECKPOINT_2;
804 cp_buf = hdr + max_cp;
812 == LOG_CHECKPOINT_FSP_MAGIC_N_VAL) {
815 cp_buf + LOG_CHECKPOINT_FSP_FREE_LIMIT);
817 if (*fsp_limit == 0) {
818 *fsp_limit = 1000000000;
821 *fsp_limit = 1000000000;
841log_block_checksum_is_ok_or_old_format(
859 "InnoDB: Scanned old format < InnoDB-3.23.52"
860 " log block number %lu\n",
875recv_scan_log_seg_for_backup(
879 ib_uint64_t* scanned_lsn,
881 ulint* scanned_checkpoint_no,
885 ulint* n_bytes_scanned)
893 *n_bytes_scanned = 0;
895 for (log_block = buf; log_block < buf + buf_len;
901 fprintf(stderr,
"Log block header no %lu\n", no);
905 || !log_block_checksum_is_ok_or_old_format(log_block)) {
908 "Log block n:o %lu, scanned lsn n:o %lu\n",
916 "Next log block n:o %lu\n",
922 if (*scanned_checkpoint_no > 0
924 < *scanned_checkpoint_no
925 && *scanned_checkpoint_no
933 "Scanned cp n:o %lu, block cp n:o %lu\n",
934 *scanned_checkpoint_no,
942 *scanned_checkpoint_no
944 *scanned_lsn += data_len;
946 *n_bytes_scanned += data_len;
952 fprintf(stderr,
"Log block data len %lu\n",
967recv_parse_or_apply_log_rec_body(
979 dict_index_t* index = NULL;
986 ut_ad(!block == !mtr);
991 ut_d(page_type = fil_page_get_type(page));
999#ifdef UNIV_LOG_LSN_DEBUG
1007 && end_ptr >= ptr + 2) {
1027 || offs == IBUF_TREE_SEG_HEADER
1028 + IBUF_HEADER + FSEG_HDR_OFFSET
1029 || offs == PAGE_BTR_IBUF_FREE_LIST
1030 + PAGE_HEADER + FIL_ADDR_BYTE
1031 || offs == PAGE_BTR_IBUF_FREE_LIST
1032 + PAGE_HEADER + FIL_ADDR_BYTE
1034 || offs == PAGE_BTR_SEG_LEAF
1035 + PAGE_HEADER + FSEG_HDR_OFFSET
1036 || offs == PAGE_BTR_SEG_TOP
1037 + PAGE_HEADER + FSEG_HDR_OFFSET
1038 || offs == PAGE_BTR_IBUF_FREE_LIST_NODE
1039 + PAGE_HEADER + FIL_ADDR_BYTE
1041 || offs == PAGE_BTR_IBUF_FREE_LIST_NODE
1042 + PAGE_HEADER + FIL_ADDR_BYTE
1050 || offs == IBUF_TREE_SEG_HEADER
1051 + IBUF_HEADER + FSEG_HDR_SPACE
1052 || offs == IBUF_TREE_SEG_HEADER
1053 + IBUF_HEADER + FSEG_HDR_PAGE_NO
1054 || offs == PAGE_BTR_IBUF_FREE_LIST
1056 || offs == PAGE_BTR_IBUF_FREE_LIST
1057 + PAGE_HEADER + FIL_ADDR_PAGE
1058 || offs == PAGE_BTR_IBUF_FREE_LIST
1059 + PAGE_HEADER + FIL_ADDR_PAGE
1061 || offs == PAGE_BTR_SEG_LEAF
1062 + PAGE_HEADER + FSEG_HDR_PAGE_NO
1063 || offs == PAGE_BTR_SEG_LEAF
1064 + PAGE_HEADER + FSEG_HDR_SPACE
1065 || offs == PAGE_BTR_SEG_TOP
1066 + PAGE_HEADER + FSEG_HDR_PAGE_NO
1067 || offs == PAGE_BTR_SEG_TOP
1068 + PAGE_HEADER + FSEG_HDR_SPACE
1069 || offs == PAGE_BTR_IBUF_FREE_LIST_NODE
1070 + PAGE_HEADER + FIL_ADDR_PAGE
1072 || offs == PAGE_BTR_IBUF_FREE_LIST_NODE
1073 + PAGE_HEADER + FIL_ADDR_PAGE
1105 ptr = btr_cur_parse_del_mark_set_clust_rec(
1106 ptr, end_ptr, page, page_zip, index);
1122 ptr = btr_cur_parse_del_mark_set_sec_rec(ptr, end_ptr,
1135 ptr = btr_cur_parse_update_in_place(ptr, end_ptr, page,
1166 ptr, end_ptr, block, index, mtr);
1179 ptr = btr_parse_page_reorganize(ptr, end_ptr, index,
1219 ptr = btr_parse_set_min_rec_mark(
1239 ptr = ibuf_parse_bitmap_init(ptr, end_ptr, block, mtr);
1243 ptr = fsp_parse_init_file_page(ptr, end_ptr, block);
1253 ptr = fil_op_log_parse_or_replay(ptr, end_ptr, type, 0, 0);
1277 recv_sys->found_corrupt_log = TRUE;
1281 dict_table_t* table = index->table;
1283 dict_mem_index_free(index);
1284 dict_mem_table_free(table);
1323recv_get_fil_addr_struct(
1331 recv_hash(space, page_no)));
1333 if ((recv_addr->
space == space)
1334 && (recv_addr->
page_no == page_no)) {
1349recv_add_to_hash_table(
1356 ib_uint64_t start_lsn,
1357 ib_uint64_t end_lsn)
1365 if (fil_tablespace_deleted_or_being_deleted_in_mem(space, -1)) {
1372 len = rec_end - body;
1376 recv->
len = rec_end - body;
1380 recv_addr = recv_get_fil_addr_struct(space, page_no);
1382 if (recv_addr == NULL) {
1385 recv_addr->
space = space;
1392 recv_fold(space, page_no), recv_addr);
1395 fprintf(stderr,
"Inserting log rec for space %lu, page %lu\n",
1402 prev_field = &(recv->
data);
1408 while (rec_end > body) {
1410 len = rec_end - body;
1412 if (len > RECV_DATA_BLOCK_SIZE) {
1413 len = RECV_DATA_BLOCK_SIZE;
1418 *prev_field = recv_data;
1420 memcpy(recv_data + 1, body, len);
1422 prev_field = &(recv_data->
next);
1434recv_data_copy_to_buf(
1444 recv_data = recv->
data;
1447 if (len > RECV_DATA_BLOCK_SIZE) {
1448 part_len = RECV_DATA_BLOCK_SIZE;
1458 recv_data = recv_data->next;
1470#ifndef UNIV_HOTBACKUP
1482 ib_uint64_t start_lsn;
1483 ib_uint64_t end_lsn;
1484 ib_uint64_t page_lsn;
1485 ib_uint64_t page_newest_lsn;
1486 ibool modification_to_page;
1487#ifndef UNIV_HOTBACKUP
1494 if (
recv_sys->apply_log_recs == FALSE) {
1506 if ((recv_addr == NULL)
1516 fprintf(stderr,
"Recovering space %lu, page %lu\n",
1527 page = block->frame;
1530#ifndef UNIV_HOTBACKUP
1540 success = buf_page_get_known_nowait(RW_X_LATCH, block,
1546 buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
1552#ifndef UNIV_HOTBACKUP
1558 if (page_newest_lsn) {
1560 page_lsn = page_newest_lsn;
1564 page_newest_lsn = 0;
1567 modification_to_page = FALSE;
1568 start_lsn = end_lsn = 0;
1575 if (recv->
len > RECV_DATA_BLOCK_SIZE) {
1579 buf =
static_cast<byte *
>(mem_alloc(recv->
len));
1581 recv_data_copy_to_buf(buf, recv);
1587 page_lsn = page_newest_lsn;
1600 ib_uint64_t page_end_lsn;
1602 if (!modification_to_page) {
1604 modification_to_page = TRUE;
1609 if (log_debug_writes) {
1611 "InnoDB: Applying log rec"
1613 " to space %lu page no %lu\n",
1614 (ulong) recv->
type, (ulong) recv->
len,
1615 (ulong) recv_addr->
space,
1620 recv_parse_or_apply_log_rec_body(recv->
type, buf,
1628 + page, page_end_lsn);
1632 + page_zip->
data, page_end_lsn);
1636 if (recv->
len > RECV_DATA_BLOCK_SIZE) {
1643#ifdef UNIV_ZIP_DEBUG
1648 ut_a(page_zip_validate_low(page_zip, page, FALSE));
1655 if (recv_max_page_lsn < page_lsn) {
1656 recv_max_page_lsn = page_lsn;
1666#ifndef UNIV_HOTBACKUP
1667 if (modification_to_page) {
1679 mtr.modifications = FALSE;
1684#ifndef UNIV_HOTBACKUP
1698 ulint page_nos[RECV_READ_AHEAD_AREA];
1702 low_limit = page_no - (page_no % RECV_READ_AHEAD_AREA);
1706 for (page_no = low_limit; page_no < low_limit + RECV_READ_AHEAD_AREA;
1708 recv_addr = recv_get_fil_addr_struct(space, page_no);
1717 page_nos[n] = page_no;
1726 buf_read_recv_pages(FALSE, space, zip_size, page_nos, n);
1753 ibool has_printed = FALSE;
1767 ut_ad(!allow_ibuf == mutex_own(&log_sys->mutex));
1781 ulint space = recv_addr->
space;
1782 ulint zip_size = fil_space_get_zip_size(space);
1783 ulint page_no = recv_addr->
page_no;
1788 fputs(
" InnoDB: Starting an"
1789 " apply batch of log records"
1790 " to the database...\n"
1791 "InnoDB: Progress in percents: ",
1804 space, zip_size, page_no,
1806 buf_block_dbg_add_level(
1807 block, SYNC_NO_ORDER_CHECK);
1812 recv_read_in_area(space, zip_size,
1827 fprintf(stderr,
"%lu ", (ulong)
1846 fprintf(stderr,
"\n");
1853 ut_d(recv_no_log_write = TRUE);
1855 mutex_exit(&(log_sys->mutex));
1857 n_pages = buf_flush_list(ULINT_MAX, IB_ULONGLONG_MAX);
1858 ut_a(n_pages != ULINT_UNDEFINED);
1864 mutex_enter(&(log_sys->mutex));
1866 ut_d(recv_no_log_write = FALSE);
1874 recv_sys_empty_hash();
1877 fprintf(stderr,
"InnoDB: Apply batch completed\n");
1887recv_apply_log_recs_for_backup(
void)
1901 block = back_block1;
1903 fputs(
"InnoDB: Starting an apply batch of log records"
1904 " to the database...\n"
1905 "InnoDB: Progress in percents: ", stderr);
1909 for (i = 0; i < n_hash_cells; i++) {
1913 while (recv_addr != NULL) {
1916 = fil_space_get_zip_size(recv_addr->
space);
1918 if (zip_size == ULINT_UNDEFINED) {
1921 "InnoDB: Warning: cannot apply"
1923 " tablespace %lu page %lu,\n"
1924 "InnoDB: because tablespace with"
1925 " that id does not exist.\n",
1933 goto skip_this_recv_addr;
1940 buf_page_init_for_backup_restore(
1949 success = fil_extend_space_to_desired_size(
1954 "InnoDB: Fatal error: cannot extend"
1955 " tablespace %lu to hold %lu pages\n",
1966 recv_addr->
space, zip_size,
1967 recv_addr->
page_no, 0, zip_size,
1968 block->page.zip.data, NULL);
1969 if (error == DB_SUCCESS
1970 && !buf_zip_decompress(block, TRUE)) {
1975 recv_addr->
space, 0,
1978 block->frame, NULL);
1981 if (error != DB_SUCCESS) {
1983 "InnoDB: Fatal error: cannot read"
1985 " %lu page number %lu\n",
1986 (ulong) recv_addr->
space,
1998 buf_flush_init_for_writing(
2003 error = fil_io(OS_FILE_WRITE, TRUE,
2004 recv_addr->
space, zip_size,
2007 block->page.zip.data, NULL);
2009 error = fil_io(OS_FILE_WRITE, TRUE,
2010 recv_addr->
space, 0,
2013 block->frame, NULL);
2019 if ((100 * i) / n_hash_cells
2020 != (100 * (i + 1)) / n_hash_cells) {
2021 fprintf(stderr,
"%lu ",
2022 (ulong) ((100 * i) / n_hash_cells));
2027 recv_sys_empty_hash();
2049 if (ptr == end_ptr) {
2064 *space = ULINT_UNDEFINED - 1;
2073 if (UNIV_UNLIKELY(!new_ptr)) {
2078#ifdef UNIV_LOG_LSN_DEBUG
2079 if (*type == MLOG_LSN) {
2080 ib_uint64_t lsn = (ib_uint64_t) *space << 32 | *page_no;
2081# ifdef UNIV_LOG_DEBUG
2082 ut_a(lsn == log_sys->old_lsn);
2089 new_ptr = recv_parse_or_apply_log_rec_body(*type, new_ptr, end_ptr,
2091 if (UNIV_UNLIKELY(new_ptr == NULL)) {
2100 return(new_ptr - ptr);
2107recv_calc_lsn_on_data_add(
2117 - LOG_BLOCK_HDR_SIZE;
2119 - LOG_BLOCK_TRL_SIZE);
2120 lsn_len = (ulint) len;
2121 lsn_len += (lsn_len + frag_len)
2123 - LOG_BLOCK_TRL_SIZE)
2124 * (LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE);
2126 return(lsn + lsn_len);
2129#ifdef UNIV_LOG_DEBUG
2135recv_check_incomplete_log_recs(
2146 for (i = 0; i < len; i++) {
2147 ut_a(0 == recv_parse_log_rec(ptr, ptr + i, &type, &space,
2157recv_report_corrupt_log(
2165 "InnoDB: ############### CORRUPT LOG RECORD FOUND\n"
2166 "InnoDB: Log record type %lu, space id %lu, page number %lu\n"
2167 "InnoDB: Log parsing proceeded successfully up to %" PRIu64
"\n"
2168 "InnoDB: Previous log record type %lu, is multi %lu\n"
2169 "InnoDB: Recv offset %lu, prev %lu\n",
2170 (ulong) type, (ulong) space, (ulong) page_no,
2172 (ulong) recv_previous_parsed_rec_type,
2173 (ulong) recv_previous_parsed_rec_is_multi,
2175 (ulong) recv_previous_parsed_rec_offset);
2177 if ((ulint)(ptr -
recv_sys->buf + 100)
2178 > recv_previous_parsed_rec_offset
2179 && (ulint)(ptr -
recv_sys->buf + 100
2180 - recv_previous_parsed_rec_offset)
2182 fputs(
"InnoDB: Hex dump of corrupt log starting"
2183 " 100 bytes before the start\n"
2184 "InnoDB: of the previous log rec,\n"
2185 "InnoDB: and ending 100 bytes after the start"
2186 " of the corrupt rec:\n",
2191 + recv_previous_parsed_rec_offset - 100,
2193 - recv_previous_parsed_rec_offset);
2197#ifndef UNIV_HOTBACKUP
2198 if (!srv_force_recovery) {
2199 fputs(
"InnoDB: Set innodb_force_recovery"
2200 " to ignore this error.\n", stderr);
2205 fputs(
"InnoDB: WARNING: the log file may have been corrupt and it\n"
2206 "InnoDB: is possible that the log scan did not proceed\n"
2207 "InnoDB: far enough in recovery! Please run CHECK TABLE\n"
2208 "InnoDB: on your InnoDB tables to check that they are ok!\n"
2209 "InnoDB: If mysqld crashes after this recovery, look at\n"
2210 "InnoDB: " REFMAN
"forcing-innodb-recovery.html\n"
2211 "InnoDB: about forcing recovery.\n", stderr);
2224 ibool store_to_hash)
2233 ib_uint64_t new_recovered_lsn;
2234 ib_uint64_t old_lsn;
2240 ut_ad(mutex_own(&(log_sys->mutex)));
2247 if (ptr == end_ptr) {
2262 len = recv_parse_log_rec(ptr, end_ptr, &type, &space,
2265 if (len == 0 ||
recv_sys->found_corrupt_log) {
2268 recv_report_corrupt_log(ptr,
2269 type, space, page_no);
2275 new_recovered_lsn = recv_calc_lsn_on_data_add(old_lsn, len);
2277 if (new_recovered_lsn >
recv_sys->scanned_lsn) {
2285 recv_previous_parsed_rec_type = (ulint)type;
2286 recv_previous_parsed_rec_offset =
recv_sys->recovered_offset;
2287 recv_previous_parsed_rec_is_multi = 0;
2290 recv_sys->recovered_lsn = new_recovered_lsn;
2293 if (log_debug_writes) {
2295 "InnoDB: Parsed a single log rec"
2296 " type %lu len %lu space %lu page no %lu\n",
2297 (ulong) type, (ulong) len, (ulong) space,
2305 }
else if (!store_to_hash) {
2309#ifdef UNIV_LOG_DEBUG
2310 recv_check_incomplete_log_recs(ptr, len);
2318#ifdef UNIV_HOTBACKUP
2319 if (recv_replay_file_ops) {
2326 if (NULL == fil_op_log_parse_or_replay(
2327 body, end_ptr, type,
2330 "InnoDB: Error: file op"
2331 " log record of type %lu"
2332 " space %lu not complete in\n"
2333 "InnoDB: the replay phase."
2344#ifdef UNIV_LOG_LSN_DEBUG
2345 }
else if (type == MLOG_LSN) {
2351 recv_add_to_hash_table(type, space, page_no, body,
2361 len = recv_parse_log_rec(ptr, end_ptr, &type, &space,
2363 if (len == 0 ||
recv_sys->found_corrupt_log) {
2367 recv_report_corrupt_log(
2368 ptr, type, space, page_no);
2374 recv_previous_parsed_rec_type = (ulint)type;
2375 recv_previous_parsed_rec_offset
2376 =
recv_sys->recovered_offset + total_len;
2377 recv_previous_parsed_rec_is_multi = 1;
2379#ifdef UNIV_LOG_DEBUG
2381 recv_check_incomplete_log_recs(ptr, len);
2386 if (log_debug_writes) {
2388 "InnoDB: Parsed a multi log rec"
2390 " space %lu page no %lu\n",
2391 (ulong) type, (ulong) len,
2392 (ulong) space, (ulong) page_no);
2407 new_recovered_lsn = recv_calc_lsn_on_data_add(
2408 recv_sys->recovered_lsn, total_len);
2410 if (new_recovered_lsn >
recv_sys->scanned_lsn) {
2424 len = recv_parse_log_rec(ptr, end_ptr, &type, &space,
2428 recv_report_corrupt_log(ptr,
2429 type, space, page_no);
2437 = recv_calc_lsn_on_data_add(old_lsn, len);
2446#ifdef UNIV_LOG_LSN_DEBUG
2450 recv_add_to_hash_table(type, space, page_no,
2469recv_sys_add_to_parsing_buf(
2471 const byte* log_block,
2472 ib_uint64_t scanned_lsn)
2491 if (
recv_sys->parse_start_lsn >= scanned_lsn) {
2495 }
else if (
recv_sys->scanned_lsn >= scanned_lsn) {
2500 more_len = (ulint) (scanned_lsn -
recv_sys->parse_start_lsn);
2502 more_len = (ulint) (scanned_lsn -
recv_sys->scanned_lsn);
2505 if (more_len == 0) {
2510 ut_ad(data_len >= more_len);
2512 start_offset = data_len - more_len;
2514 if (start_offset < LOG_BLOCK_HDR_SIZE) {
2515 start_offset = LOG_BLOCK_HDR_SIZE;
2518 end_offset = data_len;
2524 ut_ad(start_offset <= end_offset);
2526 if (start_offset < end_offset) {
2528 log_block + start_offset, end_offset - start_offset);
2530 recv_sys->len += end_offset - start_offset;
2542recv_sys_justify_left_parsing_buf(
void)
2564 ulint available_memory,
2566 ibool store_to_hash,
2573 ib_uint64_t start_lsn,
2574 ib_uint64_t* contiguous_lsn,
2577 ib_uint64_t* group_scanned_lsn)
2580 const byte* log_block;
2582 ib_uint64_t scanned_lsn;
2590 ut_a(store_to_hash <= TRUE);
2595 scanned_lsn = start_lsn;
2607 || !log_block_checksum_is_ok_or_old_format(log_block)) {
2610 && !log_block_checksum_is_ok_or_old_format(
2613 "InnoDB: Log block no %lu at"
2614 " lsn %" PRIu64
" has\n"
2615 "InnoDB: ok header, but checksum field"
2616 " contains %lu, should be %lu\n",
2640 if (scanned_lsn > *contiguous_lsn) {
2641 *contiguous_lsn = scanned_lsn;
2648 && scanned_lsn + data_len >
recv_sys->scanned_lsn
2649 && (
recv_sys->scanned_checkpoint_no > 0)
2652 && (
recv_sys->scanned_checkpoint_no
2660#ifdef UNIV_LOG_DEBUG
2675 recv_sys->parse_start_lsn = scanned_lsn
2681 scanned_lsn += data_len;
2683 if (scanned_lsn >
recv_sys->scanned_lsn) {
2689#ifndef UNIV_HOTBACKUP
2690 if (recv_log_scan_is_startup_type
2694 "InnoDB: Log scan progressed"
2695 " past the checkpoint lsn %" PRIu64
"\n",
2697 recv_init_crash_recovery();
2708 "InnoDB: Error: log parsing"
2710 " Recovery may have failed!\n");
2712 recv_sys->found_corrupt_log = TRUE;
2714#ifndef UNIV_HOTBACKUP
2715 if (!srv_force_recovery) {
2717 " innodb_force_recovery"
2718 " to ignore this error.\n",
2724 }
else if (!
recv_sys->found_corrupt_log) {
2725 more_data = recv_sys_add_to_parsing_buf(
2726 log_block, scanned_lsn);
2729 recv_sys->scanned_lsn = scanned_lsn;
2742 }
while (log_block < buf + len && !finished);
2744 *group_scanned_lsn = scanned_lsn;
2747 || (recv_is_from_backup && !recv_is_making_a_backup)) {
2748 recv_scan_print_counter++;
2750 if (finished || (recv_scan_print_counter % 80 == 0)) {
2752 drizzled::errmsg_printf(drizzled::error::INFO,
2753 "InnoDB: Doing recovery: scanned up to log sequence number %" PRIu64
" ",
2754 *group_scanned_lsn);
2758 if (more_data && !
recv_sys->found_corrupt_log) {
2761 recv_parse_log_recs(store_to_hash);
2763#ifndef UNIV_HOTBACKUP
2780 recv_sys_justify_left_parsing_buf();
2787#ifndef UNIV_HOTBACKUP
2793recv_group_scan_log_recs(
2796 ib_uint64_t* contiguous_lsn,
2799 ib_uint64_t* group_scanned_lsn)
2803 ib_uint64_t start_lsn;
2804 ib_uint64_t end_lsn;
2808 start_lsn = *contiguous_lsn;
2814 group, start_lsn, end_lsn);
2821 start_lsn, contiguous_lsn, group_scanned_lsn);
2822 start_lsn = end_lsn;
2826 if (log_debug_writes) {
2827 drizzled::errmsg_printf(drizzled::error::INFO,
2828 "InnoDB: Scanned group %lu up to log sequence number %" PRIu64
" ", (ulong) group->
id, *group_scanned_lsn);
2838recv_init_crash_recovery(
void)
2848 " InnoDB: Database was not"
2849 " shut down normally!\n"
2850 "InnoDB: Starting crash recovery.\n");
2853 "InnoDB: Reading tablespace information"
2854 " from the .ibd files...\n");
2866 "InnoDB: Restoring possible"
2867 " half-written data pages from"
2868 " the doublewrite\n"
2869 "InnoDB: buffer...\n");
2884#ifdef UNIV_LOG_ARCHIVE
2887 ib_uint64_t limit_lsn,
2890 ib_uint64_t min_flushed_lsn,
2892 ib_uint64_t max_flushed_lsn)
2899 ulint log_hdr_log_block_size;
2900 ib_uint64_t checkpoint_lsn;
2901 ib_uint64_t checkpoint_no;
2902 ib_uint64_t old_scanned_lsn;
2903 ib_uint64_t group_scanned_lsn= 0;
2904 ib_uint64_t contiguous_lsn;
2905#ifdef UNIV_LOG_ARCHIVE
2906 ib_uint64_t archived_lsn;
2909 boost::scoped_array<byte> log_hdr_buf_base(
2915#ifdef UNIV_LOG_ARCHIVE
2916 ut_ad(type != LOG_CHECKPOINT || limit_lsn == IB_ULONGLONG_MAX);
2918# define TYPE_CHECKPOINT (type == LOG_CHECKPOINT)
2920# define LIMIT_LSN limit_lsn
2923# define TYPE_CHECKPOINT 1
2925# define LIMIT_LSN IB_ULONGLONG_MAX
2928 if (TYPE_CHECKPOINT) {
2934 drizzled::errmsg_printf(drizzled::error::INFO,
2935 "InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on Skipping log redo.");
2944 mutex_enter(&(log_sys->mutex));
2948 err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field);
2950 if (err != DB_SUCCESS) {
2952 mutex_exit(&(log_sys->mutex));
2959 buf = log_sys->checkpoint_buf;
2963#ifdef UNIV_LOG_ARCHIVE
2971 0, 0, LOG_FILE_HDR_SIZE,
2972 log_hdr_buf, max_cp_group);
2974 if (0 ==
ut_memcmp(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
2975 (
byte*)
"ibbackup", (
sizeof "ibbackup") - 1)) {
2979 drizzled::errmsg_printf(drizzled::error::INFO,
2980 "InnoDB: The log file was created by ibbackup --apply-log at %s\n",
2981 log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP);
2982 drizzled::errmsg_printf(drizzled::error::INFO,
2983 "InnoDB: NOTE: the following crash recovery is part of a normal restore.\n");
2987 memset(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
2990 fil_io(OS_FILE_WRITE | OS_FILE_LOG, TRUE,
2993 log_hdr_buf, max_cp_group);
2996 log_hdr_log_block_size
2998 if (log_hdr_log_block_size == 0) {
3000 log_hdr_log_block_size = 512;
3002 if (log_hdr_log_block_size != srv_log_block_size) {
3003 drizzled::errmsg_printf(drizzled::error::ERROR,
3004 "InnoDB: Error: The block size of ib_logfile (%lu) "
3005 "is not equal to innodb_log_block_size.\n"
3006 "InnoDB: Error: Suggestion - Recreate log files.\n",
3007 log_hdr_log_block_size);
3011#ifdef UNIV_LOG_ARCHIVE
3016 &(group->archived_file_no),
3017 &(group->archived_offset));
3023 if (TYPE_CHECKPOINT) {
3028 recv_sys->parse_start_lsn = checkpoint_lsn;
3029 recv_sys->scanned_lsn = checkpoint_lsn;
3030 recv_sys->scanned_checkpoint_no = 0;
3031 recv_sys->recovered_lsn = checkpoint_lsn;
3038 if (TYPE_CHECKPOINT) {
3039 up_to_date_group = max_cp_group;
3040#ifdef UNIV_LOG_ARCHIVE
3050 if (
recv_sys->scanned_lsn > checkpoint_lsn + capacity
3051 || checkpoint_lsn >
recv_sys->scanned_lsn + capacity) {
3053 mutex_exit(&(log_sys->mutex));
3061 recv_group_scan_log_recs(group, &contiguous_lsn,
3062 &group_scanned_lsn);
3063 if (
recv_sys->scanned_lsn < checkpoint_lsn) {
3065 mutex_exit(&(log_sys->mutex));
3075 up_to_date_group = group;
3083#ifdef UNIV_LOG_ARCHIVE
3084 if ((type == LOG_ARCHIVE) && (group ==
recv_sys->archive_group)) {
3090 recv_log_scan_is_startup_type = TYPE_CHECKPOINT;
3092 old_scanned_lsn =
recv_sys->scanned_lsn;
3094 recv_group_scan_log_recs(group, &contiguous_lsn,
3095 &group_scanned_lsn);
3098 if (old_scanned_lsn < group_scanned_lsn) {
3101 up_to_date_group = group;
3104#ifdef UNIV_LOG_ARCHIVE
3105 if ((type == LOG_ARCHIVE)
3106 && (group ==
recv_sys->archive_group)) {
3115 recv_log_scan_is_startup_type = FALSE;
3116 if (TYPE_CHECKPOINT) {
3121 if (checkpoint_lsn != max_flushed_lsn
3122 || checkpoint_lsn != min_flushed_lsn) {
3124 if (checkpoint_lsn < max_flushed_lsn) {
3125 drizzled::errmsg_printf(drizzled::error::ERROR,
3126 "InnoDB: #########################"
3127 "#################################\n"
3130 "InnoDB: The log sequence number"
3131 " in ibdata files is higher\n"
3132 "InnoDB: than the log sequence number"
3133 " in the ib_logfiles! Are you sure\n"
3134 "InnoDB: you are using the right"
3135 " ib_logfiles to start up"
3137 "InnoDB: Log sequence number in"
3138 " ib_logfiles is %" PRIu64
", log\n"
3139 "InnoDB: sequence numbers stamped"
3140 " to ibdata file headers are between\n"
3141 "InnoDB: %" PRIu64
" and %" PRIu64
".\n"
3142 "InnoDB: #########################"
3143 "#################################\n",
3150 drizzled::errmsg_printf(drizzled::error::ERROR,
3151 "InnoDB: The log sequence number in ibdata files does not match the log sequence number in the ib_logfiles!");
3152 recv_init_crash_recovery();
3163 if (group_scanned_lsn < checkpoint_lsn) {
3164 drizzled::errmsg_printf(drizzled::error::ERROR,
3165 "InnoDB: ERROR: We were only able to scan the log up to %" PRIu64
", but a checkpoint was at %" PRIu64
". "
3166 "It is possible that the database is now corrupt!",
3171 if (group_scanned_lsn < recv_max_page_lsn) {
3172 drizzled::errmsg_printf(drizzled::error::ERROR,
3173 "InnoDB: ERROR: We were only able to scan the log up to %" PRIu64
" "
3174 " but a database page a had an lsn %" PRIu64
". It is possible that the database is now corrupt!",
3179 if (
recv_sys->recovered_lsn < checkpoint_lsn) {
3181 mutex_exit(&(log_sys->mutex));
3183 if (
recv_sys->recovered_lsn >= LIMIT_LSN) {
3196 log_sys->next_checkpoint_lsn = checkpoint_lsn;
3197 log_sys->next_checkpoint_no = checkpoint_no + 1;
3199#ifdef UNIV_LOG_ARCHIVE
3200 log_sys->archived_lsn = archived_lsn;
3203 recv_synchronize_groups(up_to_date_group);
3211 log_sys->lsn =
recv_sys->recovered_lsn;
3216 log_sys->buf_next_to_write = log_sys->buf_free;
3217 log_sys->written_to_some_lsn = log_sys->lsn;
3218 log_sys->written_to_all_lsn = log_sys->lsn;
3220 log_sys->last_checkpoint_lsn = checkpoint_lsn;
3222 log_sys->next_checkpoint_no = checkpoint_no + 1;
3224#ifdef UNIV_LOG_ARCHIVE
3225 if (archived_lsn == IB_ULONGLONG_MAX) {
3227 log_sys->archiving_state = LOG_ARCH_OFF;
3237 mutex_exit(&(log_sys->mutex));
3247#undef TYPE_CHECKPOINT
3266 if (log_debug_writes) {
3267 drizzled::errmsg_printf(drizzled::error::INFO,
3268 "InnoDB: Log records applied to the database.");
3273 drizzled::errmsg_printf(drizzled::error::ERROR,
3274 "InnoDB: WARNING: the log file may have been corrupt and it\n"
3275 "InnoDB: is possible that the log scan or parsing did not proceed\n"
3276 "InnoDB: far enough in recovery. Please run CHECK TABLE on your InnoDB tables to check that they are ok! "
3277 "InnoDB: It may be safest to recover your database from a backup!");
3284#ifndef UNIV_LOG_DEBUG
3285 recv_sys_debug_free();
3291 if (! srv_apply_log_only)
3304#ifdef UNIV_SYNC_DEBUG
3310 sync_order_checks_on = TRUE;
3337#ifdef UNIV_LOG_ARCHIVE
3340 ibool new_logs_created)
3347 ut_ad(mutex_own(&(log_sys->mutex)));
3354 group->
lsn = log_sys->lsn;
3356#ifdef UNIV_LOG_ARCHIVE
3357 group->archived_file_no = arch_log_no;
3358 group->archived_offset = 0;
3361 if (!new_logs_created) {
3362 recv_truncate_group(group, group->
lsn, group->
lsn,
3369 log_sys->buf_next_to_write = 0;
3370 log_sys->written_to_some_lsn = log_sys->lsn;
3371 log_sys->written_to_all_lsn = log_sys->lsn;
3373 log_sys->next_checkpoint_no = 0;
3374 log_sys->last_checkpoint_lsn = 0;
3376#ifdef UNIV_LOG_ARCHIVE
3377 log_sys->archived_lsn = log_sys->lsn;
3383 log_sys->buf_free = LOG_BLOCK_HDR_SIZE;
3384 log_sys->lsn += LOG_BLOCK_HDR_SIZE;
3386 mutex_exit(&(log_sys->mutex));
3393 mutex_enter(&(log_sys->mutex));
3397#ifdef UNIV_HOTBACKUP
3402recv_reset_log_files_for_backup(
3404 const char* log_dir,
3406 ulint log_file_size,
3416 static const char ib_logfile_basename[] =
"ib_logfile";
3418 log_dir_len = strlen(log_dir);
3422 ut_a(log_dir_len + strlen(ib_logfile_basename) + 11 <
sizeof(name));
3427 for (i = 0; i < n_log_files; i++) {
3429 sprintf(name,
"%s%s%lu", log_dir,
3430 ib_logfile_basename, (ulong)i);
3432 log_file = os_file_create_simple(innodb_file_log_key,
3433 name, OS_FILE_CREATE,
3437 drizzled::errmsg_printf(drizzled::error::ERROR,
3438 "InnoDB: Cannot create %s. Check that the file does not exist yet.\n", name);
3443 drizzled::errmsg_printf(drizzled::error::INFO,
3444 "Setting log file size to %lu %lu\n",
3446 (ulong) log_file_size & 0xFFFFFFFFUL);
3449 log_file_size & 0xFFFFFFFFUL,
3453 drizzled::errmsg_printf(drizzled::error::ERROR,
3454 "InnoDB: Cannot set %s size to %lu %lu\n",
3456 (ulong) (log_file_size & 0xFFFFFFFFUL));
3460 os_file_flush(log_file);
3461 os_file_close(log_file);
3466 log_reset_first_header_and_checkpoint(buf, lsn);
3470 LOG_BLOCK_HDR_SIZE);
3471 sprintf(name,
"%s%s%lu", log_dir, ib_logfile_basename, (ulong)0);
3473 log_file = os_file_create_simple(innodb_file_log_key,
3475 OS_FILE_READ_WRITE, &success);
3477 drizzled::errmsg_printf(drizzled::error::ERROR,
"InnoDB: Cannot open %s.\n", name);
3482 os_file_write(name, log_file, buf, 0, 0,
3484 os_file_flush(log_file);
3485 os_file_close(log_file);
3491#ifdef UNIV_LOG_ARCHIVE
3498log_group_recover_from_archive_file(
3503 ib_uint64_t start_lsn;
3504 ib_uint64_t file_end_lsn;
3505 ib_uint64_t dummy_lsn;
3506 ib_uint64_t scanned_lsn;
3512 ulint file_size_high;
3525 file_handle = os_file_create(innodb_file_log_key,
3527 OS_FILE_LOG, OS_FILE_AIO, &ret);
3532 "InnoDB: Do you want to copy additional"
3533 " archived log files\n"
3534 "InnoDB: to the directory\n");
3536 "InnoDB: or were these all the files needed"
3539 "InnoDB: (Y == copy more files; N == this is all)?");
3541 input_char = getchar();
3543 if (input_char == (
int)
'N') {
3546 }
else if (input_char == (
int)
'Y') {
3548 goto try_open_again;
3557 ut_a(file_size_high == 0);
3559 drizzled::errmsg_printf(drizzled::error::INFO,
3560 "InnoDB: Opened archived log file %s\n", name);
3562 ret = os_file_close(file_handle);
3564 if (file_size < LOG_FILE_HDR_SIZE) {
3565 drizzled::errmsg_printf(drizzled::error::ERROR,
3566 "InnoDB: Archive file header incomplete %s\n", name);
3575 fil_node_create(name, 1 + file_size / UNIV_PAGE_SIZE,
3576 group->archive_space_id, FALSE);
3577#if RECV_SCAN_SIZE < LOG_FILE_HDR_SIZE
3578# error "RECV_SCAN_SIZE < LOG_FILE_HDR_SIZE"
3582 fil_io(
OS_FILE_READ | OS_FILE_LOG, TRUE, group->archive_space_id, 0, 0,
3583 LOG_FILE_HDR_SIZE, buf, NULL);
3589 != group->archived_file_no) {
3590 drizzled::errmsg_printf(drizzled::error::ERROR,
3591 "InnoDB: Archive file header inconsistent %s\n", name);
3597 drizzled::errmsg_printf(drizzled::error::ERROR,
3598 "InnoDB: Archive file not completely written %s\n",
3609 if (
recv_sys->parse_start_lsn < start_lsn) {
3610 drizzled::errmsg_printf(drizzled::error::ERROR,
3611 "InnoDB: Archive log file %s starts from too big a lsn\n", name);
3618 if (
recv_sys->scanned_lsn != start_lsn) {
3620 drizzled::errmsg_printf(drizzled::error::ERROR,
3621 "InnoDB: Archive log file %s starts from a wrong lsn\n", name);
3625 read_offset = LOG_FILE_HDR_SIZE;
3630 if (read_offset + len > file_size) {
3641 if (log_debug_writes) {
3642 drizzled::errmsg_printf(drizzled::error::INFO,
3643 "InnoDB: Archive read starting at lsn %" PRIu64
", len %lu from file %s\n",
3644 start_lsn, (ulong) len, name);
3649 group->archive_space_id, read_offset / UNIV_PAGE_SIZE,
3650 read_offset % UNIV_PAGE_SIZE, len, buf, NULL);
3655 * UNIV_PAGE_SIZE, TRUE, buf, len, start_lsn,
3656 &dummy_lsn, &scanned_lsn);
3658 if (scanned_lsn == file_end_lsn) {
3664 drizzled::errmsg_printf(drizzled::error::ERROR,
3665 "InnoDB: Archive log file %s does not scan right.", name);
3672 ut_ad(start_lsn == scanned_lsn);
3683recv_recovery_from_archive_start(
3685 ib_uint64_t min_flushed_lsn,
3687 ib_uint64_t limit_lsn,
3707 recv_recovery_from_backup_on = TRUE;
3716 if (group->
id == group_id) {
3725 drizzled::errmsg_printf(drizzled::error::ERROR,
3726 "InnoDB: There is no log group defined with id %lu!\n",
3731 group->archived_file_no = first_log_no;
3733 recv_sys->parse_start_lsn = min_flushed_lsn;
3736 recv_sys->scanned_checkpoint_no = 0;
3743 mutex_enter(&(log_sys->mutex));
3746 ret = log_group_recover_from_archive_file(group);
3751 trunc_len = UNIV_PAGE_SIZE
3752 * fil_space_get_size(group->archive_space_id);
3753 if (trunc_len > 0) {
3754 fil_space_truncate_start(group->archive_space_id,
3758 group->archived_file_no++;
3761 if (
recv_sys->recovered_lsn < limit_lsn) {
3768 mutex_exit(&(log_sys->mutex));
3774 if (err != DB_SUCCESS) {
3779 mutex_enter(&(log_sys->mutex));
3782 if (limit_lsn != IB_ULONGLONG_MAX) {
3789 mutex_exit(&(log_sys->mutex));
3798recv_recovery_from_archive_finish(
void)
3803 recv_recovery_from_backup_on = FALSE;
UNIV_INLINE ib_uint64_t buf_page_get_newest_modification(const buf_page_t *bpage)
UNIV_INLINE ibool buf_page_peek(ulint space, ulint offset)
UNIV_INLINE ulint buf_pool_get_curr_size(void)
UNIV_INTERN void buf_pool_invalidate(void)
UNIV_INLINE ulint buf_block_get_space(const buf_block_t *block) __attribute__((pure))
#define buf_block_get_page_zip(block)
UNIV_INLINE ulint buf_block_get_page_no(const buf_block_t *block) __attribute__((pure))
UNIV_INLINE ulint buf_pool_get_n_pages(void)
#define buf_page_get(SP, ZS, OF, LA, MTR)
UNIV_INTERN void buf_flush_free_flush_rbt(void)
UNIV_INLINE void buf_flush_recv_note_modification(buf_block_t *block, ib_uint64_t start_lsn, ib_uint64_t end_lsn)
UNIV_INTERN void buf_flush_init_flush_rbt(void)
struct buf_block_struct buf_block_t
UNIV_INLINE ibool dict_table_is_comp(const dict_table_t *table)
#define FIL_PAGE_END_LSN_OLD_CHKSUM
#define FIL_PAGE_UNDO_LOG
#define FIL_PAGE_TYPE_ALLOCATED
UNIV_INTERN ulint fil_load_single_table_tablespaces(void)
UNIV_INLINE hash_cell_t * hash_get_nth_cell(hash_table_t *table, ulint n)
#define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)
UNIV_INLINE ulint hash_get_n_cells(hash_table_t *table)
UNIV_INLINE ulint hash_calc_hash(ulint fold, hash_table_t *table)
#define HASH_GET_NEXT(NAME, DATA)
#define HASH_GET_FIRST(TABLE, HASH_VAL)
UNIV_INTERN void log_group_set_fields(log_group_t *group, ib_uint64_t lsn)
UNIV_INTERN void log_group_read_checkpoint_info(log_group_t *group, ulint field)
UNIV_INLINE ulint log_block_get_checkpoint_no(const byte *log_block)
#define log_flush_order_mutex_exit()
UNIV_INTERN void log_make_checkpoint_at(ib_uint64_t lsn, ibool write_always)
UNIV_INLINE ulint log_block_get_data_len(const byte *log_block)
UNIV_INTERN ulint log_group_get_capacity(const log_group_t *group)
UNIV_INLINE ulint log_block_get_hdr_no(const byte *log_block)
UNIV_INLINE ulint log_block_convert_lsn_to_no(ib_uint64_t lsn)
UNIV_INLINE ulint log_block_calc_checksum(const byte *block)
UNIV_INLINE void log_block_init_in_old_format(byte *log_block, ib_uint64_t lsn)
UNIV_INTERN void log_checkpoint_get_nth_group_info(const byte *buf, ulint n, ulint *file_no, ulint *offset)
UNIV_INLINE ibool log_block_get_flush_bit(const byte *log_block)
UNIV_INLINE void log_block_init(byte *log_block, ib_uint64_t lsn)
UNIV_INLINE void log_block_set_data_len(byte *log_block, ulint len)
UNIV_INLINE ulint log_block_get_checksum(const byte *log_block)
UNIV_INTERN void log_group_write_buf(log_group_t *group, byte *buf, ulint len, ib_uint64_t start_lsn, ulint new_data_offset)
UNIV_INLINE ulint log_block_get_first_rec_group(const byte *log_block)
UNIV_INTERN void log_group_read_log_seg(ulint type, byte *buf, log_group_t *group, ib_uint64_t start_lsn, ib_uint64_t end_lsn)
#define log_flush_order_mutex_enter()
struct log_group_struct log_group_t
UNIV_INTERN void log_archived_file_name_gen(char *buf, ulint id, ulint file_no)
UNIV_INLINE void log_block_set_first_rec_group(byte *log_block, ulint offset)
UNIV_INTERN void log_groups_write_checkpoint_info(void)
UNIV_INTERN void recv_recovery_rollback_active(void)
UNIV_INTERN void recv_reset_logs(ib_uint64_t lsn, ibool new_logs_created)
struct recv_addr_struct recv_addr_t
ibool recv_needed_recovery
UNIV_INTERN ulint recv_recovery_from_checkpoint_start_func(ib_uint64_t min_flushed_lsn, ib_uint64_t max_flushed_lsn)
#define RECV_PARSING_BUF_SIZE
struct recv_struct recv_t
UNIV_INTERN void recv_sys_mem_free(void)
struct recv_data_struct recv_data_t
struct recv_sys_struct recv_sys_t
UNIV_INTERN void recv_sys_close(void)
UNIV_INTERN void recv_apply_hashed_log_recs(ibool allow_ibuf)
UNIV_INTERN void recv_recover_page_func(ibool just_read_in, buf_block_t *block)
ulint recv_max_parsed_page_no
UNIV_INTERN void recv_sys_var_init(void)
UNIV_INTERN void recv_sys_create(void)
#define recv_recovery_from_checkpoint_start(type, lim, min, max)
UNIV_INTERN ibool recv_scan_log_recs(ulint available_memory, ibool store_to_hash, const byte *buf, ulint len, ib_uint64_t start_lsn, ib_uint64_t *contiguous_lsn, ib_uint64_t *group_scanned_lsn)
ibool recv_no_ibuf_operations
ulint recv_n_pool_free_frames
UNIV_INTERN void recv_recovery_from_checkpoint_finish(void)
#define recv_recover_page(jri, block)
UNIV_INTERN void recv_sys_init(ulint available_memory)
UNIV_INLINE ib_uint64_t mach_read_from_8(const byte *b) __attribute__((nonnull
UNIV_INLINE void mach_write_to_8(byte *b, ib_uint64_t n)
UNIV_INLINE ulint mach_read_from_2(const byte *b) __attribute__((nonnull
UNIV_INLINE ulint mach_read_from_4(const byte *b) __attribute__((nonnull
#define mem_heap_create(N)
UNIV_INLINE ulint mem_heap_get_size(mem_heap_t *heap)
UNIV_INLINE void mem_heap_empty(mem_heap_t *heap)
#define mem_heap_create_in_buffer(N)
UNIV_INLINE void * mem_heap_alloc(mem_heap_t *heap, ulint n)
#define mem_heap_free(heap)
UNIV_INTERN byte * mlog_parse_string(byte *ptr, byte *end_ptr, byte *page, void *page_zip)
UNIV_INTERN byte * mlog_parse_initial_log_record(byte *ptr, byte *end_ptr, byte *type, ulint *space, ulint *page_no)
UNIV_INTERN byte * mlog_parse_index(byte *ptr, const byte *end_ptr, ibool comp, dict_index_t **index)
UNIV_INTERN byte * mlog_parse_nbytes(ulint type, byte *ptr, byte *end_ptr, byte *page, void *page_zip)
#define MLOG_REC_UPDATE_IN_PLACE
#define MLOG_UNDO_HDR_DISCARD
#define MLOG_COMP_REC_CLUST_DELETE_MARK
#define MLOG_INIT_FILE_PAGE
#define MLOG_DUMMY_RECORD
UNIV_INTERN void mtr_commit(mtr_t *mtr) __attribute__((nonnull))
#define MLOG_COMP_PAGE_CREATE
#define MLOG_MULTI_REC_END
#define MLOG_UNDO_ERASE_END
#define MLOG_COMP_REC_UPDATE_IN_PLACE
#define MLOG_COMP_PAGE_REORGANIZE
#define MLOG_ZIP_WRITE_NODE_PTR
#define MLOG_COMP_LIST_END_COPY_CREATED
#define MLOG_REC_MIN_MARK
#define MLOG_COMP_REC_SEC_DELETE_MARK
UNIV_INLINE void mtr_start(mtr_t *mtr) __attribute__((nonnull))
#define MLOG_ZIP_PAGE_COMPRESS
#define MLOG_LIST_END_DELETE
#define MLOG_COMP_REC_MIN_MARK
#define MLOG_UNDO_HDR_REUSE
#define MLOG_COMP_LIST_END_DELETE
#define MLOG_SINGLE_REC_FLAG
#define MLOG_COMP_LIST_START_DELETE
#define MLOG_REC_SEC_DELETE_MARK
#define MLOG_COMP_REC_INSERT
#define MLOG_IBUF_BITMAP_INIT
#define MLOG_REC_CLUST_DELETE_MARK
#define MLOG_ZIP_WRITE_HEADER
#define MLOG_PAGE_REORGANIZE
#define MLOG_UNDO_HDR_CREATE
UNIV_INLINE ulint mtr_set_log_mode(mtr_t *mtr, ulint mode)
#define MLOG_ZIP_WRITE_BLOB_PTR
#define MLOG_COMP_REC_DELETE
#define MLOG_LIST_END_COPY_CREATED
#define MLOG_LIST_START_DELETE
#define MLOG_FILE_CREATE2
#define MLOG_WRITE_STRING
UNIV_INTERN ibool os_file_get_size(os_file_t file, ulint *size, ulint *size_high)
#define OS_FILE_LOG_BLOCK_SIZE
UNIV_INTERN ibool os_file_set_size(const char *name, os_file_t file, ulint size, ulint size_high)
UNIV_INTERN os_thread_t os_thread_create(os_posix_f_t start_f, void *arg, os_thread_id_t *thread_id)
UNIV_INTERN void os_thread_sleep(ulint tm)
UNIV_INTERN byte * page_cur_parse_insert_rec(ibool is_short, byte *ptr, byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
UNIV_INTERN byte * page_parse_copy_rec_list_to_created_page(byte *ptr, byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
UNIV_INTERN byte * page_cur_parse_delete_rec(byte *ptr, byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
UNIV_INTERN byte * page_parse_create(byte *ptr, byte *end_ptr, ulint comp, buf_block_t *block, mtr_t *mtr)
UNIV_INLINE ulint page_is_comp(const page_t *page)
UNIV_INTERN byte * page_parse_delete_rec_list(byte type, byte *ptr, byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
struct page_zip_des_struct page_zip_des_t
UNIV_INTERN byte * page_zip_parse_write_blob_ptr(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip)
UNIV_INTERN byte * page_zip_parse_write_header(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip)
UNIV_INTERN void UNIV_INTERN byte * page_zip_parse_write_node_ptr(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip)
UNIV_INTERN byte * page_zip_parse_compress(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip) __attribute__((nonnull(1
UNIV_INTERN void row_merge_drop_temp_indexes(void)
UNIV_INTERN void row_mysql_drop_temp_tables(void)
ulint srv_buf_pool_instances
ib_uint64_t srv_start_lsn
enum recv_addr_state state
#define rw_lock_s_lock(M)
UNIV_INTERN void rw_lock_x_lock_move_ownership(rw_lock_t *lock)
UNIV_INTERN byte * trx_undo_parse_add_undo_rec(byte *ptr, byte *end_ptr, page_t *page)
UNIV_INTERN byte * trx_undo_parse_erase_page_end(byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)
UNIV_INTERN void trx_rollback_or_clean_recovered(ibool all)
UNIV_INTERN os_thread_ret_t trx_rollback_or_clean_all_recovered(void *arg)
UNIV_INTERN void trx_sys_doublewrite_init_or_restore_pages(ibool restore_corrupt_pages)
UNIV_INTERN byte * trx_undo_parse_page_header(ulint type, byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)
UNIV_INTERN byte * trx_undo_parse_page_init(byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)
UNIV_INTERN byte * trx_undo_parse_discard_latest(byte *ptr, byte *end_ptr, page_t *page, mtr_t *mtr)
UNIV_INLINE void * ut_align(const void *ptr, ulint align_no)
UNIV_INLINE ib_uint64_t ut_uint64_align_up(ib_uint64_t n, ulint align_no)
UNIV_INLINE ib_uint64_t ut_uint64_align_down(ib_uint64_t n, ulint align_no)
#define UT_LIST_GET_FIRST(BASE)
#define UT_LIST_ADD_LAST(NAME, BASE, N)
#define UT_LIST_GET_NEXT(NAME, N)
#define UT_LIST_INIT(BASE)
UNIV_INLINE void * ut_memcpy(void *dest, const void *sour, ulint n)
UNIV_INLINE void * ut_memmove(void *dest, const void *sour, ulint n)
UNIV_INLINE int ut_memcmp(const void *str1, const void *str2, ulint n)
UNIV_INTERN void ut_free(void *ptr)
UNIV_INTERN void * ut_malloc(ulint n)
UNIV_INLINE ulint ut_fold_ulint_pair(ulint n1, ulint n2) __attribute__((const))
UNIV_INLINE ulint ut_fold_binary(const byte *str, ulint len) __attribute__((pure))
UNIV_INTERN void ut_print_buf(FILE *file, const void *buf, ulint len)
UNIV_INTERN void ut_print_timestamp(FILE *file)
#define ut_calc_align_down(n, m)
UNIV_INTERN ulint ut_get_high32(ulint a)