MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
log0recv.cc File Reference
#include "log0recv.h"
#include "mem0mem.h"
#include "buf0buf.h"
#include "buf0flu.h"
#include "mtr0mtr.h"
#include "mtr0log.h"
#include "page0cur.h"
#include "page0zip.h"
#include "btr0btr.h"
#include "btr0cur.h"
#include "ibuf0ibuf.h"
#include "trx0undo.h"
#include "trx0rec.h"
#include "fil0fil.h"
#include "buf0rea.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "trx0roll.h"
#include "row0merge.h"
#include "sync0sync.h"
Include dependency graph for log0recv.cc:

Go to the source code of this file.

Macros

#define RECV_DATA_BLOCK_SIZE   (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
#define RECV_READ_AHEAD_AREA   32
#define recv_is_making_a_backup   FALSE
#define recv_is_from_backup   FALSE
#define TYPE_CHECKPOINT   1
#define LIMIT_LSN   LSN_MAX

Functions

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_var_init (void)
UNIV_INTERN os_thread_ret_t
DECLARE_THREAD() 
recv_writer_thread (void *arg __attribute__((unused)))
UNIV_INTERN void recv_sys_init (ulint available_memory)
 while (group)
UNIV_INLINE ulint recv_fold (ulint space, ulint page_no)
UNIV_INLINE ulint recv_hash (ulint space, ulint page_no)
UNIV_INTERN void recv_recover_page_func (ibool just_read_in, buf_block_t *block)
UNIV_INTERN void recv_apply_hashed_log_recs (ibool allow_ibuf)
UNIV_INTERN ibool recv_scan_log_recs (ulint available_memory, ibool store_to_hash, const byte *buf, ulint len, lsn_t start_lsn, lsn_t *contiguous_lsn, lsn_t *group_scanned_lsn)
UNIV_INTERN dberr_t recv_recovery_from_checkpoint_start_func (lsn_t min_flushed_lsn, lsn_t max_flushed_lsn)
UNIV_INTERN void recv_recovery_from_checkpoint_finish (void)
UNIV_INTERN void recv_recovery_rollback_active (void)
UNIV_INTERN void recv_reset_logs (lsn_t lsn)

Variables

UNIV_INTERN recv_sys_trecv_sys = NULL
UNIV_INTERN ibool recv_recovery_on
UNIV_INTERN ibool recv_needed_recovery
UNIV_INTERN ibool recv_lsn_checks_on
UNIV_INTERN ibool recv_no_ibuf_operations
UNIV_INTERN ulint recv_max_parsed_page_no
UNIV_INTERN ulint recv_n_pool_free_frames
UNIV_INTERN lsn_t recv_max_page_lsn
UNIV_INTERN bool recv_writer_thread_active = false
UNIV_INTERN os_thread_t recv_writer_thread_handle = 0
static ulint *max_field
log_group_t
group = UT_LIST_GET_FIRST(log_sys->log_groups)
ib_uint64_t max_no = 0
ib_uint64_t checkpoint_no
ulint field
byte * buf = log_sys->checkpoint_buf
max_group = NULL
max_field = 0

Detailed Description

Recovery

Created 9/20/1997 Heikki Tuuri

Definition in file log0recv.cc.

Macro Definition Documentation

#define RECV_DATA_BLOCK_SIZE   (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
Log records are stored in the hash table in chunks at most of this size;

this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool

Definition at line 63 of file log0recv.cc.

#define recv_is_from_backup   FALSE

TRUE when recovering from a backed up redo log file

Definition at line 116 of file log0recv.cc.

#define recv_is_making_a_backup   FALSE

TRUE when the redo log is being backed up

Definition at line 114 of file log0recv.cc.

#define RECV_READ_AHEAD_AREA   32

Read-ahead area in applying log records to file pages

Definition at line 66 of file log0recv.cc.

Function Documentation

UNIV_INTERN void recv_apply_hashed_log_recs ( ibool  allow_ibuf)

Empties the hash table of stored log records, applying them to appropriate pages.

Parameters
allow_ibufin: 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 1819 of file log0recv.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE ulint recv_fold ( ulint  space,
ulint  page_no 
)

Calculates the fold value of a page file address: used in inserting or searching for a log record in the hash table.

Returns
folded value
Parameters
spacein: space
page_noin: page number

Definition at line 1373 of file log0recv.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE ulint recv_hash ( ulint  space,
ulint  page_no 
)

Calculates the hash value of a page file address: used in inserting or searching for a log record in the hash table.

Returns
folded value
Parameters
spacein: space
page_noin: page number

Definition at line 1387 of file log0recv.cc.

Here is the call graph for this function:

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.

Parameters
just_read_inin: TRUE if the i/o handler calls this for a freshly read page
blockin/out: buffer block

Definition at line 1552 of file log0recv.cc.

Here is the call graph for this function:

UNIV_INTERN void recv_recovery_from_checkpoint_finish ( void  )

Completes recovery from a checkpoint.

Definition at line 3364 of file log0recv.cc.

Here is the call graph for this function:

UNIV_INTERN dberr_t recv_recovery_from_checkpoint_start_func ( lsn_t  min_flushed_lsn,
lsn_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.

Returns
error code or DB_SUCCESS

TRUE when recovering from a checkpoint

Recover up to this log sequence number

Parameters
min_flushed_lsnin: min flushed lsn from data files
max_flushed_lsnin: max flushed lsn from data files

Definition at line 2988 of file log0recv.cc.

Here is the call graph for this function:

UNIV_INTERN void recv_recovery_rollback_active ( void  )

Initiates the rollback of active transactions.

Definition at line 3447 of file log0recv.cc.

Here is the call graph for this function:

UNIV_INTERN void recv_reset_logs ( lsn_t  lsn)

Resets the logs. The contents of log files will be lost!

Parameters
lsnin: reset to this lsn rounded up to be divisible by OS_FILE_LOG_BLOCK_SIZE, after which we add LOG_BLOCK_HDR_SIZE

Definition at line 3488 of file log0recv.cc.

Here is the call graph for this function:

UNIV_INTERN ibool recv_scan_log_recs ( ulint  available_memory,
ibool  store_to_hash,
const byte *  buf,
ulint  len,
lsn_t  start_lsn,
lsn_t *  contiguous_lsn,
lsn_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.

Returns
TRUE if limit_lsn has been reached, or not able to scan any more in this log group
Parameters
available_memoryin: we let the hash table of recs to grow to this size, at the maximum
store_to_hashin: TRUE if the records should be stored to the hash table; this is set to FALSE if just debug checking is needed
bufin: buffer containing a log segment or garbage
lenin: buffer length
start_lsnin: buffer start lsn
contiguous_lsnin/out: it is known that all log groups contain contiguous log data up to this lsn
group_scanned_lsnout: scanning succeeded up to this lsn

Definition at line 2653 of file log0recv.cc.

Here is the call graph for this function:

UNIV_INTERN void recv_sys_close ( void  )

Release recovery system mutexes.

Definition at line 215 of file log0recv.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void recv_sys_create ( void  )

Creates the recovery system.

Definition at line 190 of file log0recv.cc.

Here is the caller graph for this function:

UNIV_INTERN void recv_sys_init ( ulint  available_memory)

Inits the recovery system for a recovery operation. in: available memory in bytes

Parameters
available_memoryin: available memory in bytes

Definition at line 374 of file log0recv.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void recv_sys_mem_free ( void  )

Frees the recovery system memory.

Definition at line 251 of file log0recv.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void recv_sys_var_init ( void  )

Reset the state of the recovery system variables.

Definition at line 281 of file log0recv.cc.

Here is the caller graph for this function:

UNIV_INTERN os_thread_ret_t DECLARE_THREAD() recv_writer_thread ( void *arg   __attribute__(unused))

recv_writer thread tasked with flushing dirty pages from the buffer pools.

Returns
a dummy parameter
Parameters
__attribute__in: a dummy parameter required by os_thread_create

Definition at line 323 of file log0recv.cc.

Here is the call graph for this function:

Variable Documentation

group = UT_LIST_GET_FIRST(log_sys->log_groups)

< out: max group

< out: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2

Definition at line 744 of file log0recv.cc.

UNIV_INTERN 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 91 of file log0recv.cc.

UNIV_INTERN lsn_t recv_max_page_lsn
The maximum lsn we see for a page during the recovery process. If this

is bigger than the lsn we are able to scan up to, that is an indication that the recovery failed and the database may be corrupt.

Definition at line 150 of file log0recv.cc.

UNIV_INTERN ulint recv_max_parsed_page_no

Maximum page number encountered in the redo log

Definition at line 137 of file log0recv.cc.

UNIV_INTERN 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 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 145 of file log0recv.cc.

UNIV_INTERN ibool recv_needed_recovery

TRUE when recv_init_crash_recovery() has been called.

Definition at line 81 of file log0recv.cc.

UNIV_INTERN 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 112 of file log0recv.cc.

UNIV_INTERN 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 73 of file log0recv.cc.

UNIV_INTERN recv_sys_t* recv_sys = NULL

The recovery system

Definition at line 69 of file log0recv.cc.

UNIV_INTERN bool recv_writer_thread_active = false

Flag indicating if recv_writer thread is active.

Definition at line 170 of file log0recv.cc.