#include "univ.i"
#include "ut0byte.h"
#include "buf0types.h"
#include "hash0hash.h"
#include "log0log.h"
Go to the source code of this file.
Classes | |
struct | recv_data_struct |
struct | recv_struct |
struct | recv_addr_struct |
struct | recv_sys_struct |
Macros | |
#define | log0recv_h |
#define | recv_recover_page(jri, block) recv_recover_page_func(jri, block) |
#define | recv_recovery_from_checkpoint_start(type, lim, min, max) recv_recovery_from_checkpoint_start_func(min,max) |
#define | RECV_PARSING_BUF_SIZE (2 * 1024 * 1024) |
#define | RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE) |
Typedefs | |
typedef struct recv_data_struct | recv_data_t |
typedef struct recv_struct | recv_t |
typedef struct recv_addr_struct | recv_addr_t |
typedef struct recv_sys_struct | recv_sys_t |
Enumerations | |
enum | recv_addr_state { RECV_NOT_PROCESSED, RECV_BEING_READ, RECV_BEING_PROCESSED, RECV_PROCESSED } |
Functions | |
UNIV_INLINE ibool | recv_recovery_is_on (void) |
UNIV_INTERN void | recv_recover_page_func (ibool just_read_in, buf_block_t *block) |
UNIV_INTERN ulint | recv_recovery_from_checkpoint_start_func (ib_uint64_t min_flushed_lsn, ib_uint64_t max_flushed_lsn) |
UNIV_INTERN void | recv_recovery_from_checkpoint_finish (void) |
UNIV_INTERN void | recv_recovery_rollback_active (void) |
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) |
UNIV_INTERN void | recv_reset_logs (ib_uint64_t lsn, ibool new_logs_created) |
UNIV_INTERN void | recv_sys_create (void) |
UNIV_INTERN void | recv_sys_close (void) |
UNIV_INTERN void | recv_sys_mem_free (void) |
UNIV_INTERN void | recv_sys_init (ulint available_memory) |
UNIV_INTERN void | recv_sys_var_init (void) |
UNIV_INTERN void | recv_apply_hashed_log_recs (ibool allow_ibuf) |
Variables | |
recv_sys_t * | recv_sys |
ibool | recv_recovery_on |
ibool | recv_no_ibuf_operations |
ibool | recv_needed_recovery |
ibool | recv_lsn_checks_on |
ulint | recv_max_parsed_page_no |
ulint | recv_n_pool_free_frames |
#define RECV_PARSING_BUF_SIZE (2 * 1024 * 1024) |
Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
times!
Definition at line 482 of file log0recv.h.
Referenced by recv_scan_log_recs(), and recv_sys_init().
#define recv_recover_page | ( | jri, | |
block | |||
) | recv_recover_page_func(jri, block) |
Wrapper for recv_recover_page_func().
Applies the hashed log records to the page, if the page lsn is less than the lsn of a log record. This can be called when a buffer page has just been read in, or also for a page already in the buffer pool.
jri | in: TRUE if just read in (the i/o handler calls this for a freshly read page) |
block | in/out: the buffer block |
Definition at line 115 of file log0recv.h.
Referenced by buf_page_io_complete(), and recv_apply_hashed_log_recs().
#define recv_recovery_from_checkpoint_start | ( | type, | |
lim, | |||
min, | |||
max | |||
) | recv_recovery_from_checkpoint_start_func(min,max) |
Wrapper for recv_recovery_from_checkpoint_start_func().
Recovers from a checkpoint. When this function returns, the database is able to start processing of new user transactions, but the function recv_recovery_from_checkpoint_finish should be called later to complete the recovery and free the resources used in it.
type | ignored: LOG_CHECKPOINT or LOG_ARCHIVE |
lim | ignored: recover up to this log sequence number if possible |
min | in: minimum flushed log sequence number from data files |
max | in: maximum flushed log sequence number from data files |
Definition at line 171 of file log0recv.h.
Referenced by innobase_start_or_create_for_mysql().
#define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE) |
Size of block reads when the log groups are scanned forward to do a
roll-forward
Definition at line 486 of file log0recv.h.
typedef struct recv_addr_struct recv_addr_t |
Hashed page file address struct
Definition at line 367 of file log0recv.h.
typedef struct recv_data_struct recv_data_t |
Block of log record data
Definition at line 324 of file log0recv.h.
typedef struct recv_sys_struct recv_sys_t |
Recovery system data structure
Definition at line 380 of file log0recv.h.
typedef struct recv_struct recv_t |
Stored log record struct
Definition at line 334 of file log0recv.h.
enum recv_addr_state |
States of recv_addr_struct
Definition at line 354 of file log0recv.h.
UNIV_INTERN void recv_apply_hashed_log_recs | ( | ibool | allow_ibuf) |
Empties the hash table of stored log records, applying them to appropriate pages. in: if TRUE, also ibuf operations are allowed during the application; if FALSE, no ibuf operations are allowed, and after the application all file pages are flushed to disk and invalidated in buffer pool: this alternative means that no new log records can be generated during the application
Empties the hash table of stored log records, applying them to appropriate pages.
allow_ibuf | in: if TRUE, also ibuf operations are allowed during the application; if FALSE, no ibuf operations are allowed, and after the application all file pages are flushed to disk and invalidated in buffer pool: this alternative means that no new log records can be generated during the application; the caller must in this case own the log mutex |
Definition at line 1738 of file log0recv.cc.
References recv_sys_struct::addr_hash, recv_sys_struct::apply_batch_on, recv_sys_struct::apply_log_recs, BUF_FLUSH_LIST, buf_page_get, buf_page_peek(), HASH_GET_FIRST, hash_get_n_cells(), HASH_GET_NEXT, mtr_commit(), mtr_start(), recv_sys_struct::mutex, log_struct::mutex, recv_sys_struct::n_addrs, os_thread_sleep(), recv_addr_struct::page_no, recv_apply_hashed_log_recs(), recv_no_ibuf_operations, RECV_NOT_PROCESSED, recv_recover_page, recv_sys, recv_addr_struct::space, recv_addr_struct::state, ut_a, ut_ad, ut_d, and ut_print_timestamp().
Referenced by log_checkpoint(), log_preflush_pool_modified_pages(), recv_apply_hashed_log_recs(), recv_recovery_from_checkpoint_finish(), and recv_scan_log_recs().
UNIV_INTERN void recv_recover_page_func | ( | ibool | just_read_in, |
buf_block_t * | block | ||
) |
Applies the hashed log records to the page, if the page lsn is less than the lsn of a log record. This can be called when a buffer page has just been read in, or also for a page already in the buffer pool. in/out: buffer block
Applies the hashed log records to the page, if the page lsn is less than the lsn of a log record. This can be called when a buffer page has just been read in, or also for a page already in the buffer pool.
just_read_in | in: TRUE if the i/o handler calls this for a freshly read page |
block | in/out: buffer block |
Definition at line 1468 of file log0recv.cc.
References recv_sys_struct::apply_log_recs, buf_block_get_page_no(), buf_block_get_page_zip, buf_block_get_space(), buf_flush_recv_note_modification(), BUF_KEEP_OLD, buf_page_get_newest_modification(), page_zip_des_struct::data, recv_struct::data, recv_struct::end_lsn, FIL_PAGE_END_LSN_OLD_CHKSUM, FIL_PAGE_INDEX, FIL_PAGE_LSN, recv_struct::len, log_flush_order_mutex_enter, log_flush_order_mutex_exit, mach_read_from_8(), mach_write_to_8(), mem_free, MLOG_INIT_FILE_PAGE, mtr_commit(), mtr_set_log_mode(), mtr_start(), recv_sys_struct::mutex, recv_sys_struct::n_addrs, recv_addr_struct::page_no, recv_addr_struct::rec_list, RECV_BEING_PROCESSED, RECV_PROCESSED, recv_recover_page_func(), recv_sys, rw_lock_x_lock_move_ownership(), recv_addr_struct::space, recv_struct::start_lsn, recv_addr_struct::state, recv_struct::type, ut_a, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.
Referenced by recv_recover_page_func().
UNIV_INTERN void recv_recovery_from_checkpoint_finish | ( | void | ) |
Completes recovery from a checkpoint.
Definition at line 3260 of file log0recv.cc.
References recv_sys_struct::found_corrupt_log, recv_apply_hashed_log_recs(), recv_recovery_from_checkpoint_finish(), recv_recovery_on, recv_sys, SRV_FORCE_NO_LOG_REDO, and trx_rollback_or_clean_recovered().
Referenced by innobase_start_or_create_for_mysql(), and recv_recovery_from_checkpoint_finish().
UNIV_INTERN ulint recv_recovery_from_checkpoint_start_func | ( | ib_uint64_t | min_flushed_lsn, |
ib_uint64_t | max_flushed_lsn | ||
) |
Recovers from a checkpoint. When this function returns, the database is able to start processing of new user transactions, but the function recv_recovery_from_checkpoint_finish should be called later to complete the recovery and free the resources used in it.
Recovers from a checkpoint. When this function returns, the database is able to start processing of new user transactions, but the function recv_recovery_from_checkpoint_finish should be called later to complete the recovery and free the resources used in it.
TRUE when recovering from a checkpoint
Recover up to this log sequence number
min_flushed_lsn | in: min flushed lsn from data files |
max_flushed_lsn | in: max flushed lsn from data files |
Definition at line 2887 of file log0recv.cc.
References recv_sys_struct::apply_log_recs, log_struct::buf, log_struct::buf_free, log_struct::buf_next_to_write, buf_pool_get_curr_size(), log_struct::checkpoint_buf, log_group_struct::id, recv_sys_struct::last_block, log_struct::last_checkpoint_lsn, recv_sys_struct::limit_lsn, log_checkpoint_get_nth_group_info(), log_group_get_capacity(), log_group_read_checkpoint_info(), log_struct::log_groups, log_struct::lsn, mach_read_from_4(), mach_read_from_8(), recv_sys_struct::mutex, log_struct::mutex, log_struct::next_checkpoint_lsn, log_struct::next_checkpoint_no, OS_FILE_LOG_BLOCK_SIZE, OS_FILE_READ, recv_sys_struct::parse_start_lsn, recv_sys_struct::recovered_lsn, recv_lsn_checks_on, recv_needed_recovery, recv_recovery_from_checkpoint_start_func(), recv_recovery_on, recv_sys, recv_sys_create(), recv_sys_init(), recv_sys_struct::scanned_checkpoint_no, recv_sys_struct::scanned_lsn, log_group_struct::scanned_lsn, log_group_struct::space_id, SRV_FORCE_NO_LOG_REDO, srv_start_lsn, trx_sys_doublewrite_init_or_restore_pages(), ut_a, ut_ad, ut_align(), ut_error, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, ut_memcmp(), ut_memcpy(), ut_uint64_align_down(), log_struct::written_to_all_lsn, and log_struct::written_to_some_lsn.
Referenced by recv_recovery_from_checkpoint_start_func().
UNIV_INLINE ibool recv_recovery_is_on | ( | void | ) |
Returns TRUE if recovery is currently running.
Referenced by buf_page_init_for_read(), buf_page_io_complete(), lock_sec_rec_cons_read_sees(), lock_sec_rec_read_check_and_lock(), and log_checkpoint().
UNIV_INTERN void recv_recovery_rollback_active | ( | void | ) |
Initiates the rollback of active transactions.
Definition at line 3304 of file log0recv.cc.
References os_thread_create(), os_thread_sleep(), recv_recovery_rollback_active(), row_merge_drop_temp_indexes(), row_mysql_drop_temp_tables(), SRV_FORCE_NO_TRX_UNDO, and trx_rollback_or_clean_all_recovered().
Referenced by innobase_start_or_create_for_mysql(), and recv_recovery_rollback_active().
UNIV_INTERN void recv_reset_logs | ( | ib_uint64_t | lsn, |
ibool | new_logs_created | ||
) |
Resets the logs. The contents of log files will be lost! in: TRUE if resetting logs is done at the log creation; FALSE if it is done after archive recovery
Resets the logs. The contents of log files will be lost!
lsn | in: reset to this lsn rounded up to be divisible by OS_FILE_LOG_BLOCK_SIZE, after which we add LOG_BLOCK_HDR_SIZE |
new_logs_created | in: TRUE if resetting logs is done at the log creation; FALSE if it is done after archive recovery |
Definition at line 3335 of file log0recv.cc.
References log_struct::buf, log_struct::buf_free, log_struct::buf_next_to_write, log_struct::last_checkpoint_lsn, log_block_init(), log_block_set_first_rec_group(), log_struct::log_groups, log_make_checkpoint_at(), log_group_struct::lsn, log_struct::lsn, log_group_struct::lsn_offset, log_struct::mutex, log_struct::next_checkpoint_no, OS_FILE_LOG_BLOCK_SIZE, recv_reset_logs(), ut_ad, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, ut_uint64_align_up(), log_struct::written_to_all_lsn, and log_struct::written_to_some_lsn.
Referenced by innobase_start_or_create_for_mysql(), and recv_reset_logs().
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 | ||
) |
Scans log from a buffer and stores new log data to the parsing buffer. Parses and hashes the log records if new data found. Unless UNIV_HOTBACKUP is defined, this function will apply log records automatically when the hash table becomes full.
Scans log from a buffer and stores new log data to the parsing buffer. Parses and hashes the log records if new data found. Unless UNIV_HOTBACKUP is defined, this function will apply log records automatically when the hash table becomes full.
available_memory | in: we let the hash table of recs to grow to this size, at the maximum |
store_to_hash | in: TRUE if the records should be stored to the hash table; this is set to FALSE if just debug checking is needed |
buf | in: buffer containing a log segment or garbage |
len | in: buffer length |
start_lsn | in: buffer start lsn |
contiguous_lsn | in/out: it is known that all log groups contain contiguous log data up to this lsn |
group_scanned_lsn | out: scanning succeeded up to this lsn |
Definition at line 2567 of file log0recv.cc.
References recv_sys_struct::found_corrupt_log, recv_sys_struct::heap, recv_sys_struct::len, log_block_calc_checksum(), log_block_convert_lsn_to_no(), log_block_get_checkpoint_no(), log_block_get_checksum(), log_block_get_data_len(), log_block_get_first_rec_group(), log_block_get_flush_bit(), log_block_get_hdr_no(), mem_heap_get_size(), OS_FILE_LOG_BLOCK_SIZE, recv_sys_struct::parse_start_lsn, recv_sys_struct::recovered_lsn, recv_sys_struct::recovered_offset, recv_apply_hashed_log_recs(), recv_needed_recovery, RECV_PARSING_BUF_SIZE, recv_scan_log_recs(), recv_sys, recv_sys_struct::scanned_checkpoint_no, recv_sys_struct::scanned_lsn, ut_a, ut_ad, and ut_error.
Referenced by recv_scan_log_recs().
UNIV_INTERN void recv_sys_close | ( | void | ) |
Release recovery system mutexes.
Definition at line 201 of file log0recv.cc.
References recv_sys_struct::addr_hash, recv_sys_struct::buf, recv_sys_struct::heap, recv_sys_struct::last_block_buf_start, mem_free, mem_heap_free, recv_sys_struct::mutex, recv_sys, recv_sys_close(), and ut_free().
Referenced by recv_sys_close().
UNIV_INTERN void recv_sys_create | ( | void | ) |
Creates the recovery system.
Definition at line 180 of file log0recv.cc.
References recv_sys_struct::addr_hash, recv_sys_struct::heap, recv_sys_struct::mutex, recv_sys, and recv_sys_create().
Referenced by log_init(), recv_recovery_from_checkpoint_start_func(), and recv_sys_create().
UNIV_INTERN void recv_sys_init | ( | ulint | available_memory) |
Inits the recovery system for a recovery operation. in: available memory in bytes
available_memory | in: available memory in bytes |
Definition at line 303 of file log0recv.cc.
References recv_sys_struct::addr_hash, recv_sys_struct::apply_batch_on, recv_sys_struct::apply_log_recs, recv_sys_struct::buf, buf_pool_get_curr_size(), recv_sys_struct::found_corrupt_log, recv_sys_struct::heap, recv_sys_struct::last_block, recv_sys_struct::last_block_buf_start, recv_sys_struct::len, mem_heap_create, mem_heap_create_in_buffer, recv_sys_struct::mutex, recv_sys_struct::n_addrs, OS_FILE_LOG_BLOCK_SIZE, recv_sys_struct::recovered_offset, recv_n_pool_free_frames, RECV_PARSING_BUF_SIZE, recv_sys, recv_sys_init(), ut_align(), and ut_malloc().
Referenced by log_init(), recv_recovery_from_checkpoint_start_func(), and recv_sys_init().
UNIV_INTERN void recv_sys_mem_free | ( | void | ) |
Frees the recovery system memory.
Definition at line 232 of file log0recv.cc.
References recv_sys_struct::addr_hash, recv_sys_struct::buf, recv_sys_struct::heap, recv_sys_struct::last_block_buf_start, mem_free, mem_heap_free, recv_sys, recv_sys_mem_free(), and ut_free().
Referenced by recv_sys_mem_free().
UNIV_INTERN void recv_sys_var_init | ( | void | ) |
Reset the state of the recovery system variables.
Definition at line 262 of file log0recv.cc.
References recv_lsn_checks_on, recv_max_parsed_page_no, recv_n_pool_free_frames, recv_needed_recovery, recv_no_ibuf_operations, recv_recovery_on, and recv_sys_var_init().
Referenced by recv_sys_var_init(), and srv_general_init().
ibool recv_lsn_checks_on |
TRUE if buf_page_is_corrupted() should check if the log sequence
number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by recv_recovery_from_checkpoint_start_func().
Definition at line 95 of file log0recv.cc.
Referenced by buf_page_is_corrupted(), recv_recovery_from_checkpoint_start_func(), and recv_sys_var_init().
ulint recv_max_parsed_page_no |
Maximum page number encountered in the redo log
Definition at line 141 of file log0recv.cc.
Referenced by recv_sys_var_init().
ulint recv_n_pool_free_frames |
This many frames must be left free in the buffer pool when we scan
the log and store the scanned log records in the buffer pool: we will use these free frames to read in pages when we start applying the log records to the database.
This many frames must be left free in the buffer pool when we scan
the log and store the scanned log records in the buffer pool: we will use these free frames to read in pages when we start applying the log records to the database. This is the default value. If the actual size of the buffer pool is larger than 10 MB we'll set this value to 512.
Definition at line 149 of file log0recv.cc.
Referenced by buf_read_recv_pages(), recv_sys_init(), and recv_sys_var_init().
ibool recv_needed_recovery |
TRUE when recv_init_crash_recovery() has been called.
Definition at line 85 of file log0recv.cc.
Referenced by innobase_start_or_create_for_mysql(), recv_recovery_from_checkpoint_start_func(), recv_scan_log_recs(), recv_sys_var_init(), and trx_sys_create_rsegs().
ibool recv_no_ibuf_operations |
If the following is TRUE, the buffer pool file pages must be invalidated
after recovery and no ibuf operations are allowed; this becomes TRUE if the log record hash table becomes too full, and log records must be merged to file pages already before the recovery is finished: in this case no ibuf operations are allowed, as they could modify the pages read in the buffer pool before the pages have been recovered to the up-to-date state.
TRUE means that recovery is running and no operations on the log files are allowed yet: the variable name is misleading.
Definition at line 116 of file log0recv.cc.
Referenced by buf_page_get_gen(), buf_page_init_for_read(), buf_page_io_complete(), fil_io(), ibuf_page_low(), log_write_up_to(), recv_apply_hashed_log_recs(), and recv_sys_var_init().
ibool recv_recovery_on |
TRUE when applying redo log records during crash recovery; FALSE
otherwise. Note that this is FALSE while a background thread is rolling back incomplete transactions.
Definition at line 77 of file log0recv.cc.
Referenced by buf_LRU_buf_pool_running_out(), fil_space_create(), log_preflush_pool_modified_pages(), recv_recovery_from_checkpoint_finish(), recv_recovery_from_checkpoint_start_func(), and recv_sys_var_init().
recv_sys_t* recv_sys |
The recovery system
Definition at line 73 of file log0recv.cc.
Referenced by log_init(), mlog_parse_nbytes(), mlog_parse_string(), page_cur_parse_insert_rec(), page_zip_parse_write_blob_ptr(), page_zip_parse_write_header(), page_zip_parse_write_node_ptr(), recv_apply_hashed_log_recs(), recv_recover_page_func(), recv_recovery_from_checkpoint_finish(), recv_recovery_from_checkpoint_start_func(), recv_scan_log_recs(), recv_sys_close(), recv_sys_create(), recv_sys_init(), and recv_sys_mem_free().