MySQL 26.7.0
Source Code Documentation
log0handler.cc File Reference
#include "log0handler.h"
#include <cstring>
#include <sstream>
#include "buf0flu.h"
#include "db0err.h"
#include "log0buf.h"
#include "log0chkp.h"
#include "log0encryption.h"
#include "log0helpers.h"
#include "log0log.h"
#include "log0pre_8_0_30.h"
#include "log0recv.h"
#include "log0sys_var_handler.h"
#include "log0test.h"
#include "log0types.h"
#include "log0write.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "ut0new.h"

Classes

struct  anonymous_namespace{log0handler.cc}::Log_checkpoint_location
 Describes location of a single checkpoint. More...
 

Namespaces

namespace  anonymous_namespace{log0handler.cc}
 
namespace  ib
 
namespace  ib::redo
 

Functions

static bool log_block_is_valid (const byte *log_block, Log_data_block_header block_header, lsn_t scanned_lsn, lsn_t total_scanned_lsn)
 Validates the raw REDO log block buffer. More...
 
static bool recv_sys_add_to_parsing_buf (const byte *log_block, lsn_t scanned_lsn, lsn_t &ignore_below_lsn, ib::redo::Buffer &parsing_buffer, size_t &parsed_length)
 Add raw REDO blocks to parsing buffer. More...
 
static ib::redo::Lsn recv_read_log_seg (log_t &log, byte *buf, ib::redo::Lsn start_lsn, ib::redo::Lsn end_lsn)
 Reads a specified log segment to a buffer. More...
 
static dberr_t read_checkpoint (log_t &log, ib::redo::Handler_interface::Metadata_value &block)
 Read the checkpoint block from the REDO log. More...
 
static dberr_t read_header (log_t &log, ib::redo::Handler_interface::Metadata_value &block)
 Read the REDO header block from the REDO log. More...
 
static dberr_t write_header (log_t &log, const ib::redo::Handler_interface::Metadata_value block)
 Write the REDO header block to the REDO log. More...
 
static bool recv_find_max_checkpoint (Log_file_handle &file_handle, Log_checkpoint_location &checkpoint)
 Find the latest checkpoint in the given log file. More...
 
static bool recv_find_max_checkpoint (log_t &log, Log_checkpoint_location &checkpoint)
 Find the latest checkpoint (check all existing redo log files). More...
 
static bool recv_scan_log_recs (const byte *buf, size_t buf_len, ib::redo::Lsn start_lsn, ib::redo::Lsn &total_scanned_lsn, ib::redo::Buffer &parsing_destination)
 Scans log from a buffer and stores new log data to the destination buffer. More...
 
static sn_t ib::redo::log_concurrency_margin (const size_t max_threads, const size_t reserved_bytes_per_thread, lsn_t log_capacity, bool &is_safe)
 Computes concurrency margin to be used within log_free_check calls, for a given redo log capacity (soft_logical_capacity). More...
 
Log_checkpoint_header_no recv_find_checkpoint_header_no (log_t &log, lsn_t checkpoint_lsn)
 
void log_track_changes_of_recovered_lsn (ib::redo::Lsn old_recovered_lsn, ib::redo::Lsn new_recovered_lsn, ib::redo::Lsn &last_block_first_mtr_boundary)
 Tracks changes of recovered_lsn and tracks proper values for what first_rec_group should be for consecutive blocks. More...
 
bool log_block_checksum_is_ok (const byte *block)
 Check the 4-byte checksum to the trailer checksum field of a log block. More...
 

Function Documentation

◆ log_block_checksum_is_ok()

bool log_block_checksum_is_ok ( const byte block)

Check the 4-byte checksum to the trailer checksum field of a log block.

Parameters
[in]blockpointer to a log block
Returns
whether the checksum matches

◆ log_block_is_valid()

static bool log_block_is_valid ( const byte log_block,
Log_data_block_header  block_header,
lsn_t  scanned_lsn,
lsn_t  total_scanned_lsn 
)
static

Validates the raw REDO log block buffer.

Parameters
[in]log_blockREDO log block which contains REDO logs
[in]block_headerREDO log block header
[in]scanned_lsnUpto which REDO has been scanned
[in]total_scanned_lsnTill the lsn REDO log is scanned
Returns
true if log block is validated, false otherwise

◆ log_track_changes_of_recovered_lsn()

void log_track_changes_of_recovered_lsn ( ib::redo::Lsn  old_recovered_lsn,
ib::redo::Lsn  new_recovered_lsn,
ib::redo::Lsn last_block_first_mtr_boundary 
)

Tracks changes of recovered_lsn and tracks proper values for what first_rec_group should be for consecutive blocks.

Must be called when recv_sys->recovered_lsn is changed to next lsn pointing at boundary between consecutive parsed mini-transactions.

◆ read_checkpoint()

static dberr_t read_checkpoint ( log_t log,
ib::redo::Handler_interface::Metadata_value block 
)
static

Read the checkpoint block from the REDO log.

Parameters
[in]logRedo log
[out]blockBlock containing checkpoint found
Returns
DB_SUCCESS if checkpoint found, error otherwise.

◆ read_header()

static dberr_t read_header ( log_t log,
ib::redo::Handler_interface::Metadata_value block 
)
static

Read the REDO header block from the REDO log.

Parameters
[in]logRedo log
[out]blockBlock containing header info
Returns
DB_SUCCESS if header read successfully, error otherwise.

◆ recv_find_checkpoint_header_no()

Log_checkpoint_header_no recv_find_checkpoint_header_no ( log_t log,
lsn_t  checkpoint_lsn 
)

◆ recv_find_max_checkpoint() [1/2]

static bool recv_find_max_checkpoint ( Log_file_handle file_handle,
Log_checkpoint_location &  checkpoint 
)
static

Find the latest checkpoint in the given log file.

Parameters
[in]file_handlehandle for the opened redo log file
[out]checkpointthe latest checkpoint found (if any)
Returns
true iff any checkpoint has been found

◆ recv_find_max_checkpoint() [2/2]

static bool recv_find_max_checkpoint ( log_t log,
Log_checkpoint_location &  checkpoint 
)
static

Find the latest checkpoint (check all existing redo log files).

Parameters
[in]logredo log
[out]checkpointthe latest checkpoint found (if any)
Returns
true iff any checkpoint has been found

◆ recv_read_log_seg()

ib::redo::Lsn recv_read_log_seg ( log_t log,
byte buf,
ib::redo::Lsn  start_lsn,
ib::redo::Lsn  end_lsn 
)
static

Reads a specified log segment to a buffer.

Parameters
[in,out]logredo log
[in,out]bufbuffer where to read
[in]start_lsnread area start
[in]end_lsnread area end
Returns
lsn up to which data was available on disk (ideally end_lsn) or zero in case of error

◆ recv_scan_log_recs()

static bool recv_scan_log_recs ( const byte buf,
size_t  buf_len,
ib::redo::Lsn  start_lsn,
ib::redo::Lsn total_scanned_lsn,
ib::redo::Buffer parsing_destination 
)
static

Scans log from a buffer and stores new log data to the destination buffer.

Parameters
[in]bufbuffer containing a log segment or garbage
[in]buf_lenbuffer length
[in]start_lsnbuffer start lsn
[in,out]total_scanned_lsntill the lsn REDO log is scanned
[out]parsing_destinationParsing buffer where RAW REDOs are stored
Returns
true if reached the end of redo log or not able to scan anymore during this call. Check parsing_destination.size to see how much was actually read before reaching the end in such case.

◆ recv_sys_add_to_parsing_buf()

static bool recv_sys_add_to_parsing_buf ( const byte log_block,
lsn_t  scanned_lsn,
lsn_t ignore_below_lsn,
ib::redo::Buffer parsing_buffer,
size_t &  parsed_length 
)
static

Add raw REDO blocks to parsing buffer.

Parameters
[in]log_blockREDO log block which contains REDO logs
[in]scanned_lsnUpto which REDO has been scanned
[in,out]ignore_below_lsnDon't add anything to parsing buffer below this LSN. If a suitable parse start lsn is found then, set upto which REDO has been added to the parsing buffer so that callers could ignore below that LSN if required.
[out]parsing_bufferA buffer where REDOs to be added
[out]parsed_lengthLength of the REDOs added to parsing buffer
Returns
true if all REDOs from the log block are added successfully, false otherwise

◆ write_header()

static dberr_t write_header ( log_t log,
const ib::redo::Handler_interface::Metadata_value  block 
)
static

Write the REDO header block to the REDO log.

Parameters
[in]logRedo log
[out]blockBlock containing header info
Returns
DB_SUCCESS if header read successfully, error otherwise.