MySQL 9.1.0
Source Code Documentation
log0recv.h File Reference

Recovery. More...

#include "buf0types.h"
#include "dict0types.h"
#include "hash0hash.h"
#include "log0sys.h"
#include "mtr0types.h"
#include "os0file.h"
#include "ut0byte.h"
#include "ut0new.h"
#include "ut0todo_counter.h"
#include <list>
#include <unordered_map>
#include <unordered_set>
#include "log0recv.ic"

Go to the source code of this file.

Classes

struct  recv_data_t
 Block of log record data. More...
 
struct  recv_t
 Stored log record struct. More...
 
struct  recv_addr_t
 Hashed page file address struct. More...
 
class  MetadataRecover
 Class to parse persistent dynamic metadata redo log, store and merge them and apply them to in-memory table objects finally. More...
 
struct  recv_sys_t
 Recovery system data structure. More...
 
struct  recv_sys_t::Space
 Every space has its own heap and pages that belong to it. More...
 
struct  recv_sys_t::Encryption_Key
 
struct  recv_sys_t::Mlog_record
 Mini transaction log record. More...
 

Namespaces

namespace  dblwr
 
namespace  dblwr::recv
 

Macros

#define RECV_SCAN_SIZE   (4 * UNIV_PAGE_SIZE)
 Size of block reads when the log groups are scanned forward to do a roll-forward. More...
 

Enumerations

enum  recv_addr_state {
  RECV_NOT_PROCESSED , RECV_BEING_READ , RECV_BEING_PROCESSED , RECV_PROCESSED ,
  RECV_DISCARDED
}
 States of recv_addr_t. More...
 

Functions

void recv_recover_page_func (bool 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. More...
 
static void recv_recover_page (bool jri, buf_block_t *block)
 Wrapper for recv_recover_page_func(). More...
 
void recv_sys_free ()
 Frees the recovery system. More...
 
void recv_sys_var_init ()
 Reset the state of the recovery system variables. More...
 
static bool recv_recovery_is_on ()
 Returns true if recovery is currently running. More...
 
bool recv_page_is_brand_new (buf_block_t *block)
 Returns true if the page is brand new (the next log record is init_file_page or no records to apply). More...
 
dberr_t recv_recovery_from_checkpoint_start (log_t &log, lsn_t flush_lsn)
 Start recovering from a redo log checkpoint. More...
 
dberr_t recv_verify_log_is_clean_pre_8_0_30 (log_t &log)
 Determine if a redo log from a version before MySQL 8.0.30 is clean. More...
 
MetadataRecoverrecv_recovery_from_checkpoint_finish (bool aborting)
 Complete the recovery from the latest checkpoint. More...
 
void recv_sys_create ()
 Creates the recovery system. More...
 
void recv_sys_close ()
 Release recovery system mutexes. More...
 
void recv_sys_init ()
 Inits the recovery system for a recovery operation. More...
 
lsn_t recv_calc_lsn_on_data_add (lsn_t lsn, os_offset_t len)
 Calculates the new value for lsn when more data is added to the log. More...
 
void recv_apply_hashed_log_recs (log_t &log, bool allow_ibuf)
 Empties the hash table of stored log records, applying them to appropriate pages. More...
 
const char * get_mlog_string (mlog_id_t type)
 Return string name of the redo log record type. More...
 

Variables

recv_sys_trecv_sys
 The recovery system. More...
 
volatile bool recv_recovery_on
 true when applying redo log records during crash recovery; false otherwise. More...
 
bool 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. More...
 
bool recv_needed_recovery
 true when recv_init_crash_recovery() has been called. More...
 
bool recv_lsn_checks_on
 true if buf_page_is_corrupted() should check if the log sequence number (FIL_PAGE_LSN) is in the future. More...
 
constexpr uint32_t RECV_PARSING_BUF_SIZE = 2 * 1024 * 1024
 Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many times! More...
 
size_t recv_n_frames_for_pages_per_pool_instance
 This many blocks must be left in each Buffer Pool instance to be managed by the LRU when we scan the log and store the scanned log records in a hashmap allocated in the Buffer Pool in frames of non-LRU managed blocks. More...
 

Detailed Description

Recovery.

Created 9/20/1997 Heikki Tuuri

Macro Definition Documentation

◆ RECV_SCAN_SIZE

#define RECV_SCAN_SIZE   (4 * UNIV_PAGE_SIZE)

Size of block reads when the log groups are scanned forward to do a roll-forward.

Enumeration Type Documentation

◆ recv_addr_state

States of recv_addr_t.

Enumerator
RECV_NOT_PROCESSED 

not yet processed

RECV_BEING_READ 

page is being read

RECV_BEING_PROCESSED 

log records are being applied on the page

RECV_PROCESSED 

log records have been applied on the page

RECV_DISCARDED 

log records have been discarded because the tablespace does not exist

Function Documentation

◆ get_mlog_string()

const char * get_mlog_string ( mlog_id_t  type)

Return string name of the redo log record type.

Parameters
[in]typerecord log record enum
Returns
string name of record log record

◆ recv_apply_hashed_log_recs()

void recv_apply_hashed_log_recs ( log_t log,
bool  allow_ibuf 
)

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

Parameters
[in,out]logredo log
[in]allow_ibufif true, 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

◆ recv_calc_lsn_on_data_add()

lsn_t recv_calc_lsn_on_data_add ( lsn_t  lsn,
os_offset_t  len 
)

Calculates the new value for lsn when more data is added to the log.

Parameters
[in]lsnOld LSN
[in]lenThis many bytes of data is added, log block headers not included
Returns
LSN after data addition

◆ recv_page_is_brand_new()

bool recv_page_is_brand_new ( buf_block_t block)

Returns true if the page is brand new (the next log record is init_file_page or no records to apply).

Parameters
[in]blockbuffer block
Returns
true if brand new

◆ recv_recover_page()

static void recv_recover_page ( bool  jri,
buf_block_t block 
)
inlinestatic

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.

Parameters
jriin: true if just read in (the i/o handler calls this for a freshly read page)
[in,out]blockbuffer block

◆ recv_recover_page_func()

void recv_recover_page_func ( bool  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
[in]just_read_intrue if the IO handler calls this for a freshly read page
[in,out]blockbuffer block

◆ recv_recovery_from_checkpoint_finish()

MetadataRecover * recv_recovery_from_checkpoint_finish ( bool  aborting)

Complete the recovery from the latest checkpoint.

Parameters
[in]abortingtrue if the server has to abort due to an error
Returns
recovered persistent metadata or nullptr if aborting

◆ recv_recovery_from_checkpoint_start()

dberr_t recv_recovery_from_checkpoint_start ( log_t log,
lsn_t  flush_lsn 
)

Start recovering from a redo log checkpoint.

See also
recv_recovery_from_checkpoint_finish
Parameters
[in,out]logredo log
[in]flush_lsnlsn stored at offset FIL_PAGE_FILE_FLUSH_LSN in the system tablespace header
Returns
error code or DB_SUCCESS

◆ recv_recovery_is_on()

static bool recv_recovery_is_on ( )
inlinestatic

Returns true if recovery is currently running.

Returns
recv_recovery_on

◆ recv_sys_close()

void recv_sys_close ( )

Release recovery system mutexes.

◆ recv_sys_create()

void recv_sys_create ( )

Creates the recovery system.

◆ recv_sys_free()

void recv_sys_free ( )

Frees the recovery system.

◆ recv_sys_init()

void recv_sys_init ( )

Inits the recovery system for a recovery operation.

◆ recv_sys_var_init()

void recv_sys_var_init ( )

Reset the state of the recovery system variables.

◆ recv_verify_log_is_clean_pre_8_0_30()

dberr_t recv_verify_log_is_clean_pre_8_0_30 ( log_t log)

Determine if a redo log from a version before MySQL 8.0.30 is clean.

Parameters
[in,out]logredo log
Returns
error code
Return values
DB_SUCCESSif the redo log is clean
DB_ERRORif the redo log is corrupted or dirty

Variable Documentation

◆ recv_lsn_checks_on

bool recv_lsn_checks_on
extern

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().

◆ recv_n_frames_for_pages_per_pool_instance

size_t recv_n_frames_for_pages_per_pool_instance
extern

This many blocks must be left in each Buffer Pool instance to be managed by the LRU when we scan the log and store the scanned log records in a hashmap allocated in the Buffer Pool in frames of non-LRU managed blocks.

We will use these free blocks to read in pages when we start applying the log records to the database.

◆ recv_needed_recovery

bool recv_needed_recovery
extern

true when recv_init_crash_recovery() has been called.

◆ recv_no_ibuf_operations

bool recv_no_ibuf_operations
extern

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.

◆ RECV_PARSING_BUF_SIZE

constexpr uint32_t RECV_PARSING_BUF_SIZE = 2 * 1024 * 1024
constexpr

Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many times!

◆ recv_recovery_on

volatile bool recv_recovery_on
extern

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.

◆ recv_sys

recv_sys_t* recv_sys
extern

The recovery system.