MySQL 9.1.0
Source Code Documentation
log0files_finder.cc File Reference

Redo log - finding log files and inspecting their meta data. More...

#include <string>
#include "log0files_finder.h"
#include "log0files_io.h"
#include "log0pre_8_0_30.h"
#include "log0types.h"
#include "os0file.h"

Functions

Log - multiple files analysis
static bool log_files_validate_format (const Log_files_context &files_ctx, const ut::vector< Log_file_id_and_header > &files, Log_format &format)
 Validates that all redo files have the same format and the format is in range [Log_format::VERSION_8_0_30, Log_format::CURRENT]. More...
 
static bool log_files_validate_start_lsn (const Log_files_context &files_ctx, const ut::vector< Log_file_id_and_header > &file_headers)
 Validates that all log files have start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0,. More...
 
static bool log_files_validate_lsn_chain (const Log_files_context &files_ctx, const ut::vector< Log_file_id_and_size > &file_sizes, const ut::vector< Log_file_id_and_header > &file_headers)
 Validates that all log files create a chain of consecutive lsn ranges. More...
 
static bool log_files_validate_log_uuid (const Log_files_context &files_ctx, const ut::vector< Log_file_id_and_header > &files, Log_uuid &log_uuid)
 Validates if all existing redo log files have the same log_uuid. More...
 
static bool log_files_validate_file_sizes_equal (const Log_files_context &files_ctx, const ut::vector< Log_file_id_and_size > &files)
 Validates if a set of redo log files consists of files of equal size. More...
 
Log - files finder
Log_files_find_result log_files_find_and_analyze (bool read_only, Encryption_metadata &encryption_metadata, Log_files_dict &files, Log_format &format, std::string &creator_name, Log_flags &log_flags, Log_uuid &log_uuid)
 Scans for existing log files on disk. More...
 

Detailed Description

Redo log - finding log files and inspecting their meta data.

Function Documentation

◆ log_files_find_and_analyze()

Log_files_find_result log_files_find_and_analyze ( bool  read_only,
Encryption_metadata encryption_metadata,
Log_files_dict files,
Log_format format,
std::string &  creator_name,
Log_flags log_flags,
Log_uuid log_uuid 
)

Scans for existing log files on disk.

Performs basic validation for the files that have been found. Clears and builds the Log_files_dict. Determines global properties of the redo log files: format, creator, flags and uuid.

Parameters
[in]read_onlyT: check file permissions only for reading, F: check for both reading and writing
[in]encryption_metadatapointer to encryption metadata to be used by all redo log file IO operations except those related to the first LOG_FILE_HDR_SIZE bytes of each log file
See also
Log_file_handle::m_encryption_metadata
Parameters
[out]filesdictionary of files that have been found when FOUND_VALID_FILES is returned; otherwise stays untouched
[out]formatdiscovered format of the redo log files
[out]creator_namename of creator of the files
[out]log_flagsdiscovered flags of the redo log files
[out]log_uuiddiscovered uuid of the redo log files
Returns
result of the scan and validation -
See also
Log_files_find_result

The size_capacity was computed by iterating files_list, in which we potentially could have two files with the same m_id if some bug was introduced. This should be caught easily by this check.

◆ log_files_validate_file_sizes_equal()

static bool log_files_validate_file_sizes_equal ( const Log_files_context files_ctx,
const ut::vector< Log_file_id_and_size > &  files 
)
static

Validates if a set of redo log files consists of files of equal size.

This is used for files with older redo format.

Parameters
[in]files_ctxcontext within which files exist
[in]filesnon-empty list of file headers of existing log files, ordered by file_id
Returns
true iff all redo log files have the same size

◆ log_files_validate_format()

static bool log_files_validate_format ( const Log_files_context files_ctx,
const ut::vector< Log_file_id_and_header > &  files,
Log_format format 
)
static

Validates that all redo files have the same format and the format is in range [Log_format::VERSION_8_0_30, Log_format::CURRENT].

Parameters
[in]files_ctxcontext within which files exist
[in]filesnon-empty list of file headers of existing log files, ordered by file_id
[out]formatdiscovered format if true was returned
Returns
true iff all files have the same format and the format is neither older than Log_format::VERSION_8_0_30 nor newer than Log_format::CURRENT

◆ log_files_validate_log_uuid()

static bool log_files_validate_log_uuid ( const Log_files_context files_ctx,
const ut::vector< Log_file_id_and_header > &  files,
Log_uuid log_uuid 
)
static

Validates if all existing redo log files have the same log_uuid.

Parameters
[in]files_ctxcontext within which files exist
[in]filesnon-empty list of file headers of existing log files, ordered by file_id
[out]log_uuidthe log_uuid that has been discovered
Returns
true iff all existing log files had the same log_uuid value

◆ log_files_validate_lsn_chain()

static bool log_files_validate_lsn_chain ( const Log_files_context files_ctx,
const ut::vector< Log_file_id_and_size > &  file_sizes,
const ut::vector< Log_file_id_and_header > &  file_headers 
)
static

Validates that all log files create a chain of consecutive lsn ranges.

Parameters
[in]files_ctxcontext within which files exist
[in]file_sizesnon-empty list of file sizes of existing log files, ordered by file_id
[in]file_headersnon-empty list of file headers of existing log files, ordered by file_id
Returns
true iff lsn ranges seem to be consistent and form a single chain

◆ log_files_validate_start_lsn()

static bool log_files_validate_start_lsn ( const Log_files_context files_ctx,
const ut::vector< Log_file_id_and_header > &  file_headers 
)
static

Validates that all log files have start_lsn % OS_FILE_LOG_BLOCK_SIZE == 0,.

Parameters
[in]files_ctxcontext within which files exist
[in]file_headersnon-empty list of file headers of existing log files, ordered by file_id
Returns
true if all files have possibly proper value of start_lsn