MySQL 9.0.0
Source Code Documentation
log0files_io.h File Reference

The log0files_io. More...

#include <string>
#include "log0types.h"
#include "mach0data.h"
#include "ut0crc32.h"
#include "ut0new.h"

Go to the source code of this file.

Functions

bool log_header_checksum_is_ok (const byte *buf)
 Computes checksum of the given header and verifies if the checksum is the same as the one stored in that header. More...
 
Log - file header read/write.
void log_file_header_serialize (const Log_file_header &header, byte *buf)
 Serializes the log file header to the buffer. More...
 
bool log_file_header_deserialize (const byte *buf, Log_file_header &header)
 Deserializes the log file header stored in the buffer. More...
 
dberr_t log_file_header_write (Log_file_handle &file_handle, const Log_file_header &header)
 Serializes and writes the log file header to the log file. More...
 
dberr_t log_file_header_write (Log_file_handle &file_handle, const byte *buf)
 Writes the serialized log file header to the log file. More...
 
dberr_t log_file_header_read (Log_file_handle &file_handle, byte *buf)
 Reads the serialized log file header to the buffer. More...
 
dberr_t log_file_header_read (Log_file_handle &file_handle, Log_file_header &header)
 Reads and deserializes the log file header. More...
 
void log_file_header_set_flag (Log_flags &log_flags, uint32_t bit)
 Sets a specific flag in the mask built of redo log flags. More...
 
void log_file_header_reset_flag (Log_flags &log_flags, uint32_t bit)
 Resets a specific flag in the mask built of redo log flags. More...
 
bool log_file_header_check_flag (Log_flags log_flags, uint32_t bit)
 Checks if a specific flag is set in the mask built of redo log flags. More...
 
Log - encryption header read/write.
dberr_t log_encryption_header_write (Log_file_handle &file_handle, const byte *buf)
 Writes the serialized encryption meta data to the log file. More...
 
dberr_t log_encryption_header_read (Log_file_handle &file_handle, byte *buf)
 Reads the serialized encryption meta data from the log file. More...
 
Log - checkpoint header read/write.
void log_checkpoint_header_serialize (const Log_checkpoint_header &header, byte *buf)
 Serializes the log checkpoint header to the buffer. More...
 
bool log_checkpoint_header_deserialize (const byte *buf, Log_checkpoint_header &header)
 Deserializes the log checkpoint header stored in the buffer. More...
 
dberr_t log_checkpoint_header_write (Log_file_handle &file_handle, Log_checkpoint_header_no checkpoint_header_no, const Log_checkpoint_header &header)
 Serializes and writes the log checkpoint header to the log file. More...
 
dberr_t log_checkpoint_header_write (Log_file_handle &file_handle, Log_checkpoint_header_no checkpoint_header_no, const byte *buf)
 Writes the serialized checkpoint header to the log file. More...
 
dberr_t log_checkpoint_header_read (Log_file_handle &file_handle, Log_checkpoint_header_no checkpoint_header_no, byte *buf)
 Reads the serialized log checkpoint header to the buffer. More...
 
dberr_t log_checkpoint_header_read (Log_file_handle &file_handle, Log_checkpoint_header_no checkpoint_header_no, Log_checkpoint_header &header)
 Reads and deserializes the log checkpoint header. More...
 
Log functions - data blocks read/write.
dberr_t log_data_blocks_write (Log_file_handle &file_handle, os_offset_t write_offset, size_t write_size, const byte *buf)
 Writes the formatted log blocks with redo records to the log file. More...
 
dberr_t log_data_blocks_read (Log_file_handle &file_handle, os_offset_t read_offset, size_t read_size, byte *buf)
 Reads log blocks with redo records from the log file, starting at the given offset. More...
 
Log - files creation/deletion, path computation.
std::string log_directory_path (const Log_files_context &ctx)
 Provides path to directory with redo log files. More...
 
std::string log_file_name (const Log_files_context &ctx, Log_file_id file_id)
 Provides name of the log file with the given file id, e.g. More...
 
std::string log_file_path (const Log_files_context &ctx, Log_file_id file_id)
 Provides full path to the log file, e.g. More...
 
std::string log_file_path_for_unused_file (const Log_files_context &ctx, Log_file_id file_id)
 Provides full path to the temporary log file, e.g. More...
 
dberr_t log_list_existing_files (const Log_files_context &ctx, ut::vector< Log_file_id > &ret)
 List existing log files in the directory (does not include unused files). More...
 
dberr_t log_list_existing_unused_files (const Log_files_context &ctx, ut::vector< Log_file_id > &ret)
 List existing unused log files in the directory. More...
 
dberr_t log_rename_unused_file (const Log_files_context &ctx, Log_file_id old_unused_file_id, Log_file_id new_unused_file_id)
 Renames the unused file to another unused file. More...
 
dberr_t log_mark_file_as_in_use (const Log_files_context &ctx, Log_file_id file_id)
 Renames a temporary log file to the non-temporary log file. More...
 
dberr_t log_mark_file_as_unused (const Log_files_context &ctx, Log_file_id file_id)
 Renames a non-temporary log file to the temporary log file. More...
 
dberr_t log_remove_unused_file (const Log_files_context &ctx, Log_file_id file_id)
 Removes a temporary log file, if it existed. More...
 
std::pair< dberr_t, ut::vector< Log_file_id > > log_remove_unused_files (const Log_files_context &ctx)
 Removes all temporary log files in the directory. More...
 
dberr_t log_remove_file (const Log_files_context &ctx, Log_file_id file_id)
 Removes a log file, if it existed. More...
 
std::pair< dberr_t, Log_file_idlog_remove_file (const Log_files_context &ctx)
 Removes a single existing log file (if it existed). More...
 
std::pair< dberr_t, ut::vector< Log_file_id > > log_remove_files (const Log_files_context &ctx)
 Removes existing log files. More...
 
dberr_t log_create_unused_file (const Log_files_context &ctx, Log_file_id file_id, os_offset_t size_in_bytes)
 Creates a new temporary log file and resizes the file to the given size. More...
 
dberr_t log_resize_unused_file (const Log_files_context &ctx, Log_file_id file_id, os_offset_t size_in_bytes)
 Resizes an existing temporary log file to the given size. More...
 
dberr_t log_resize_file (const Log_files_context &ctx, Log_file_id file_id, os_offset_t size_in_bytes)
 Resizes an existing log file to the given size. More...
 
dberr_t log_collect_existing_files (const Log_files_context &ctx, bool read_only, ut::vector< Log_file_id_and_size > &found)
 Searches for all possible log files existing on disk in the log directory. More...
 
Log_uuid log_generate_uuid ()
 Generate unique identifier for the redo log files. More...
 
Log - log blocks format.
uint32_t log_block_get_hdr_no (const byte *log_block)
 Gets a log block number stored in the header. More...
 
void log_block_set_hdr_no (byte *log_block, uint32_t n)
 Sets the log block number stored in the header. More...
 
uint32_t log_block_get_data_len (const byte *log_block)
 Gets a log block data length. More...
 
void log_block_set_data_len (byte *log_block, uint32_t len)
 Sets the log block data length. More...
 
uint32_t log_block_get_first_rec_group (const byte *log_block)
 Gets an offset to the beginning of the first group of log records in a given log block. More...
 
void log_block_set_first_rec_group (byte *log_block, uint32_t offset)
 Sets an offset to the beginning of the first group of log records in a given log block. More...
 
uint32_t log_block_get_epoch_no (const byte *log_block)
 Gets a log block epoch_no. More...
 
void log_block_set_epoch_no (byte *log_block, uint32_t no)
 Sets a log block epoch_no. More...
 
uint32_t log_block_convert_lsn_to_epoch_no (lsn_t lsn)
 Converts a lsn to a log block epoch number. More...
 
uint32_t log_block_convert_lsn_to_hdr_no (lsn_t lsn)
 Converts a lsn to a log block number. More...
 
uint32_t log_block_calc_checksum (const byte *log_block)
 Calculates the checksum for a log block. More...
 
uint32_t log_block_calc_checksum_crc32 (const byte *log_block)
 Calculates the checksum for a log block using the MySQL 5.7 algorithm. More...
 
uint32_t log_block_calc_checksum_none (const byte *)
 Calculates the checksum for a log block using the "no-op" algorithm. More...
 
uint32_t log_block_get_checksum (const byte *log_block)
 Gets value of a log block checksum field. More...
 
void log_block_set_checksum (byte *log_block, uint32_t checksum)
 Sets value of a log block checksum field. More...
 
void log_block_store_checksum (byte *log_block)
 Stores a 4-byte checksum to the trailer checksum field of a log block. More...
 
bool log_block_get_encrypt_bit (const byte *log_block)
 Gets value of a log block encrypt bit (true or false). More...
 
void log_block_set_encrypt_bit (byte *log_block, bool val)
 Sets value of a log block encrypt bit (true or false). More...
 
void log_data_block_header_serialize (const Log_data_block_header &header, byte *buf)
 Serializes the log data block header to the redo log block buffer which already contains redo log data (must have the redo data before this call). More...
 
bool log_data_block_header_deserialize (const byte *buf, Log_data_block_header &header)
 Deserializes the log data block header stored in the buffer. More...
 

Variables

Log_checksum_algorithm_atomic_ptr log_checksum_algorithm_ptr
 Atomic pointer to the log checksum calculation function. More...
 

Detailed Description

The log0files_io.

{cc,h} is a low-level independent library for IO operations performed directly on redo log files.

The library provides functions which allow to:

  • serialize,
  • deserialize,
  • read,
  • or write each kind of header stored in redo log files, and individual redo log blocks.

NOTE: Parsing of individual redo records is NOT in scope of this library.

Remarks

Main goal for this library is to make IO operations simpler, no matter what is the motivation behind reading or writing fragments of redo log files.

That's why:

  1. Functions defined in this library form a set of simple independent tools. They are state-less (they do not change state of the library, but obviously "write" functions might change redo log files).
  2. For each kind of redo header, three forms of the header are recognized:
    • structure with typed fields (e.g. struct Log_checkpoint_header),
    • array of bytes representing the serialized header,
    • data stored on disk. Functions to translate between any two of these forms are provided for each kind of header. In order to make life easier (when having to remind yourself what was the name for the given function), the following naming convention has been defined:
    • structure -> array of bytes: log_X_header_serialize,
    • array of bytes -> structure: log_X_header_deserialize,
    • structure -> disk: log_X_header_write(Log_file_id, ..., const The_struct& ),
    • disk -> structure: log_X_header_read(Log_file_id, ..., The_struct& ),
    • array of bytes -> disk: log_X_header_write(Log_file_id, ..., const byte* ),
    • disk -> array of bytes: log_X_header_read(Log_file_id, ..., byte* ).
Note
There is no structure with typed fields for encryption header (yet) and for redo data blocks.
  1. The functions defined in this library MUST NOT depend on log_t or recovery implementation, because this library is designed to be lightweight and easy to use.
Note

Functions that operate on set of redo files are also part of this library. This includes functions to:

  • build a path to the redo log file with the given id,
  • list existing redo files,
  • remove redo files,
  • create empty redo files,
  • mark/unmark individual redo files as unused.

Function Documentation

◆ log_block_calc_checksum()

uint32_t log_block_calc_checksum ( const byte log_block)
inline

Calculates the checksum for a log block.

Parameters
[in]log_blocklog block
Returns
checksum

◆ log_block_calc_checksum_crc32()

uint32_t log_block_calc_checksum_crc32 ( const byte log_block)
inline

Calculates the checksum for a log block using the MySQL 5.7 algorithm.

Parameters
[in]log_blocklog block
Returns
checksum

◆ log_block_calc_checksum_none()

uint32_t log_block_calc_checksum_none ( const byte )
inline

Calculates the checksum for a log block using the "no-op" algorithm.

Returns
checksum

◆ log_block_convert_lsn_to_epoch_no()

uint32_t log_block_convert_lsn_to_epoch_no ( lsn_t  lsn)
inline

Converts a lsn to a log block epoch number.

For details

See also
LOG_BLOCK_EPOCH_NO.
Parameters
[in]lsnlsn of a byte within the block
Returns
log block epoch number, it is > 0

◆ log_block_convert_lsn_to_hdr_no()

uint32_t log_block_convert_lsn_to_hdr_no ( lsn_t  lsn)
inline

Converts a lsn to a log block number.

Consecutive log blocks have consecutive numbers (unless the sequence wraps). It is guaranteed that the calculated number is greater than zero.

Parameters
[in]lsnlsn of a byte within the block
Returns
log block number, it is > 0 and <= 1G

◆ log_block_get_checksum()

uint32_t log_block_get_checksum ( const byte log_block)
inline

Gets value of a log block checksum field.

Parameters
[in]log_blocklog block
Returns
checksum

◆ log_block_get_data_len()

uint32_t log_block_get_data_len ( const byte log_block)
inline

Gets a log block data length.

Parameters
[in]log_blocklog block
Returns
log block data length measured as a byte offset from the block start

◆ log_block_get_encrypt_bit()

bool log_block_get_encrypt_bit ( const byte log_block)
inline

Gets value of a log block encrypt bit (true or false).

Parameters
[in]log_blocklog block
Returns
true iff encrypt bit is set

◆ log_block_get_epoch_no()

uint32_t log_block_get_epoch_no ( const byte log_block)
inline

Gets a log block epoch_no.

For details:

See also
LOG_BLOCK_EPOCH_NO.
Parameters
[in]log_blocklog block
Returns
epoch number

◆ log_block_get_first_rec_group()

uint32_t log_block_get_first_rec_group ( const byte log_block)
inline

Gets an offset to the beginning of the first group of log records in a given log block.

Parameters
[in]log_blocklog block
Returns
first mtr log record group byte offset from the block start, 0 if none.

◆ log_block_get_hdr_no()

uint32_t log_block_get_hdr_no ( const byte log_block)
inline

Gets a log block number stored in the header.

The number corresponds to lsn range for data stored in the block.

During recovery, when a next block is being parsed, a next range of lsn values is expected to be read. This corresponds to a log block number increased by one (modulo LOG_BLOCK_MAX_NO). However, if an unexpected number is read from the header, it is then considered the end of the redo log and recovery is finished. In such case, the next block is most likely an empty block or a block from the past, because the redo log files might be reused.

Parameters
[in]log_blocklog block (may be invalid or empty block)
Returns
log block number stored in the block header

◆ log_block_set_checksum()

void log_block_set_checksum ( byte log_block,
uint32_t  checksum 
)
inline

Sets value of a log block checksum field.

Parameters
[in,out]log_blocklog block
[in]checksumchecksum

◆ log_block_set_data_len()

void log_block_set_data_len ( byte log_block,
uint32_t  len 
)
inline

Sets the log block data length.

Parameters
[in,out]log_blocklog block
[in]lendata length (
See also
log_block_get_data_len)

◆ log_block_set_encrypt_bit()

void log_block_set_encrypt_bit ( byte log_block,
bool  val 
)
inline

Sets value of a log block encrypt bit (true or false).

Parameters
[in]log_blocklog block to modify
[in]valthe value to set (true or false)

◆ log_block_set_epoch_no()

void log_block_set_epoch_no ( byte log_block,
uint32_t  no 
)
inline

Sets a log block epoch_no.

For details:

See also
LOG_BLOCK_EPOCH_NO.
Parameters
[in,out]log_blocklog block
[in]noepoch number

◆ log_block_set_first_rec_group()

void log_block_set_first_rec_group ( byte log_block,
uint32_t  offset 
)
inline

Sets an offset to the beginning of the first group of log records in a given log block.

Parameters
[in,out]log_blocklog block
[in]offsetoffset, 0 if none

◆ log_block_set_hdr_no()

void log_block_set_hdr_no ( byte log_block,
uint32_t  n 
)
inline

Sets the log block number stored in the header.

NOTE that this must be set before the flush bit!

Parameters
[in,out]log_blocklog block
[in]nlog block number: must be in (0, 1G]

◆ log_block_store_checksum()

void log_block_store_checksum ( byte log_block)
inline

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

This is used before writing the log block to disk. The checksum in a log block is used in recovery to check the consistency of the log block.

Parameters
[in]log_blocklog block (completely filled in!)

◆ log_checkpoint_header_deserialize()

bool log_checkpoint_header_deserialize ( const byte buf,
Log_checkpoint_header header 
)

Deserializes the log checkpoint header stored in the buffer.

Parameters
[in]bufthe buffer to deserialize
[out]headerthe deserialized header
Returns
true iff checksum is correct

◆ log_checkpoint_header_read() [1/2]

dberr_t log_checkpoint_header_read ( Log_file_handle file_handle,
Log_checkpoint_header_no  checkpoint_header_no,
byte buf 
)

Reads the serialized log checkpoint header to the buffer.

Parameters
[in]file_handlehandle for the opened log file
[in]checkpoint_header_nocheckpoint header to read
[out]bufthe allocated buffer for read
Returns
DB_SUCCESS or error

◆ log_checkpoint_header_read() [2/2]

dberr_t log_checkpoint_header_read ( Log_file_handle file_handle,
Log_checkpoint_header_no  checkpoint_header_no,
Log_checkpoint_header header 
)

Reads and deserializes the log checkpoint header.

Parameters
[in]file_handlehandle for the opened log file
[in]checkpoint_header_nocheckpoint header to read
[out]headerthe checkpoint header read
Returns
DB_SUCCESS or error

◆ log_checkpoint_header_serialize()

void log_checkpoint_header_serialize ( const Log_checkpoint_header header,
byte buf 
)

Serializes the log checkpoint header to the buffer.

Parameters
[in]headerthe header to serialize
[out]bufthe allocated buffer

◆ log_checkpoint_header_write() [1/2]

dberr_t log_checkpoint_header_write ( Log_file_handle file_handle,
Log_checkpoint_header_no  checkpoint_header_no,
const byte buf 
)

Writes the serialized checkpoint header to the log file.

Parameters
[in]file_handlehandle for the opened log file
[in]checkpoint_header_nocheckpoint header to be written
[in]bufbuffer containing the serialized checkpoint header to write
Returns
DB_SUCCESS or error

◆ log_checkpoint_header_write() [2/2]

dberr_t log_checkpoint_header_write ( Log_file_handle file_handle,
Log_checkpoint_header_no  checkpoint_header_no,
const Log_checkpoint_header header 
)

Serializes and writes the log checkpoint header to the log file.

Parameters
[in]file_handlehandle for the opened log file
[in]checkpoint_header_nocheckpoint header to be written
[in]headerthe checkpoint header
Returns
DB_SUCCESS or error

◆ log_collect_existing_files()

dberr_t log_collect_existing_files ( const Log_files_context ctx,
bool  read_only,
ut::vector< Log_file_id_and_size > &  found 
)

Searches for all possible log files existing on disk in the log directory.

Performs only very minimal validation of the files, checking if files could be opened and have valid file size.

Parameters
[in]ctxcontext within which files exist
[in]read_onlytrue: check file permissions only for reading, false: check for both reading and writing
[out]foundlist of <file_id, size of file> for each file found
Returns
DB_SUCCESS, DB_NOT_FOUND or DB_ERROR

◆ log_create_unused_file()

dberr_t log_create_unused_file ( const Log_files_context ctx,
Log_file_id  file_id,
os_offset_t  size_in_bytes 
)

Creates a new temporary log file and resizes the file to the given size.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file to create
[in]size_in_bytessize of the file, in bytes
Returns
DB_SUCCESS or DB_ERROR

◆ log_data_block_header_deserialize()

bool log_data_block_header_deserialize ( const byte buf,
Log_data_block_header header 
)
inline

Deserializes the log data block header stored in the buffer.

Parameters
[in]bufthe buffer to deserialize
[out]headerthe deserialized header
Returns
true iff checksum is correct

◆ log_data_block_header_serialize()

void log_data_block_header_serialize ( const Log_data_block_header header,
byte buf 
)
inline

Serializes the log data block header to the redo log block buffer which already contains redo log data (must have the redo data before this call).

Parameters
[in]headerthe header to serialize
[out]bufthe buffer containing the redo log block with the data

◆ log_data_blocks_read()

dberr_t log_data_blocks_read ( Log_file_handle file_handle,
os_offset_t  read_offset,
size_t  read_size,
byte buf 
)

Reads log blocks with redo records from the log file, starting at the given offset.

The log blocks must exist within single log file.

Parameters
[in]file_handlehandle for the opened log file
[in]read_offsetoffset from the beginning of the given file
[in]read_sizesize of the data to read (must be divisible by OS_FILE_LOG_BLOCK_SIZE)
[out]bufallocated buffer to fill by the read
Returns
DB_SUCCESS or error

◆ log_data_blocks_write()

dberr_t log_data_blocks_write ( Log_file_handle file_handle,
os_offset_t  write_offset,
size_t  write_size,
const byte buf 
)

Writes the formatted log blocks with redo records to the log file.

The given log blocks must fit within the same single log file.

Parameters
[in]file_handlehandle for the opened log file
[in]write_offsetoffset from the beginning of the given file
[in]write_sizesize of the data to write (must be divisible by OS_FILE_LOG_BLOCK_SIZE)
[in]bufformatted log blocks with the data to write
Returns
DB_SUCCESS or error

◆ log_directory_path()

std::string log_directory_path ( const Log_files_context ctx)

Provides path to directory with redo log files.

Parameters
[in]ctxcontext within which files exist
Returns
path to innodb_redo directory

◆ log_encryption_header_read()

dberr_t log_encryption_header_read ( Log_file_handle file_handle,
byte buf 
)

Reads the serialized encryption meta data from the log file.

Parameters
[in]file_handlehandle for the opened log file
[out]bufthe allocated buffer for read
Returns
DB_SUCCESS or error

◆ log_encryption_header_write()

dberr_t log_encryption_header_write ( Log_file_handle file_handle,
const byte buf 
)

Writes the serialized encryption meta data to the log file.

Parameters
[in]file_handlehandle for the opened log file
[in]bufthe filled encryption buffer to write
Returns
DB_SUCCESS or error

◆ log_file_header_check_flag()

bool log_file_header_check_flag ( Log_flags  log_flags,
uint32_t  bit 
)

Checks if a specific flag is set in the mask built of redo log flags.

Parameters
[in]log_flagsmask of log flags
[in]bitbit number to check (flag)
Returns
true, iff flag is set

◆ log_file_header_deserialize()

bool log_file_header_deserialize ( const byte buf,
Log_file_header header 
)

Deserializes the log file header stored in the buffer.

Parameters
[in]bufthe buffer to deserialize
[out]headerthe deserialized header
Returns
true iff checksum is correct

◆ log_file_header_read() [1/2]

dberr_t log_file_header_read ( Log_file_handle file_handle,
byte buf 
)

Reads the serialized log file header to the buffer.

Parameters
[in]file_handlehandle for the opened log file
[out]bufthe allocated buffer for read
Returns
DB_SUCCESS or error

◆ log_file_header_read() [2/2]

dberr_t log_file_header_read ( Log_file_handle file_handle,
Log_file_header header 
)

Reads and deserializes the log file header.

Parameters
[in]file_handlehandle for the opened log file
[out]headerthe file header read
Returns
DB_SUCCESS or error

◆ log_file_header_reset_flag()

void log_file_header_reset_flag ( Log_flags log_flags,
uint32_t  bit 
)

Resets a specific flag in the mask built of redo log flags.

Parameters
[in]log_flagsmask of log flags
[in]bitbit number to set (flag)

◆ log_file_header_serialize()

void log_file_header_serialize ( const Log_file_header header,
byte buf 
)

Serializes the log file header to the buffer.

Parameters
[in]headerthe header to serialize
[out]bufthe allocated buffer

◆ log_file_header_set_flag()

void log_file_header_set_flag ( Log_flags log_flags,
uint32_t  bit 
)

Sets a specific flag in the mask built of redo log flags.

Parameters
[in]log_flagsmask of log flags
[in]bitbit number to set (flag)

◆ log_file_header_write() [1/2]

dberr_t log_file_header_write ( Log_file_handle file_handle,
const byte buf 
)

Writes the serialized log file header to the log file.

Parameters
[in]file_handlehandle for the opened log file
[in]bufthe serialized file header
Returns
DB_SUCCESS or error

◆ log_file_header_write() [2/2]

dberr_t log_file_header_write ( Log_file_handle file_handle,
const Log_file_header header 
)

Serializes and writes the log file header to the log file.

Parameters
[in]file_handlehandle for the opened log file
[in]headerthe file header
Returns
DB_SUCCESS or error

◆ log_file_name()

std::string log_file_name ( const Log_files_context ctx,
Log_file_id  file_id 
)

Provides name of the log file with the given file id, e.g.

'ib_redo0'.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the log file
Returns
file name

◆ log_file_path()

std::string log_file_path ( const Log_files_context ctx,
Log_file_id  file_id 
)

Provides full path to the log file, e.g.

'/data/innodb_redo/ib_redo2'.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the log file
Returns
path to the log file (including file name)

◆ log_file_path_for_unused_file()

std::string log_file_path_for_unused_file ( const Log_files_context ctx,
Log_file_id  file_id 
)

Provides full path to the temporary log file, e.g.

'/data/innodb_redo/ib_redo2_tmp'.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file
Returns
path to the temporary log file (including file name)

◆ log_generate_uuid()

Log_uuid log_generate_uuid ( )

Generate unique identifier for the redo log files.

Returns
random uuid > 0

◆ log_header_checksum_is_ok()

bool log_header_checksum_is_ok ( const byte buf)

Computes checksum of the given header and verifies if the checksum is the same as the one stored in that header.

Parameters
[in]bufheader to verify
Returns
true iff checksums are the same

◆ log_list_existing_files()

dberr_t log_list_existing_files ( const Log_files_context ctx,
ut::vector< Log_file_id > &  ret 
)

List existing log files in the directory (does not include unused files).

Parameters
[in]ctxcontext within which files exist
[out]retidentifiers of existing log files
Returns
DB_SUCCESS or DB_ERROR

◆ log_list_existing_unused_files()

dberr_t log_list_existing_unused_files ( const Log_files_context ctx,
ut::vector< Log_file_id > &  ret 
)

List existing unused log files in the directory.

Parameters
[in]ctxcontext within which files exist
[out]retidentifiers of existing unused log files
Returns
DB_SUCCESS or DB_ERROR

◆ log_mark_file_as_in_use()

dberr_t log_mark_file_as_in_use ( const Log_files_context ctx,
Log_file_id  file_id 
)

Renames a temporary log file to the non-temporary log file.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file to rename
Returns
DB_SUCCESS or DB_ERROR

◆ log_mark_file_as_unused()

dberr_t log_mark_file_as_unused ( const Log_files_context ctx,
Log_file_id  file_id 
)

Renames a non-temporary log file to the temporary log file.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file to rename
Returns
DB_SUCCESS or DB_ERROR

◆ log_remove_file() [1/2]

std::pair< dberr_t, Log_file_id > log_remove_file ( const Log_files_context ctx)

Removes a single existing log file (if it existed).

Parameters
[in]ctxcontext within which files exist
Returns
first: DB_SUCCESS, DB_NOT_FOUND or DB_ERROR second: id of the removed file (if removed)

◆ log_remove_file() [2/2]

dberr_t log_remove_file ( const Log_files_context ctx,
Log_file_id  file_id 
)

Removes a log file, if it existed.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file to remove
Returns
DB_SUCCESS, DB_NOT_FOUND or DB_ERROR

◆ log_remove_files()

std::pair< dberr_t, ut::vector< Log_file_id > > log_remove_files ( const Log_files_context ctx)

Removes existing log files.

When failed to remove a file, stops and returns error. In such case the last element of the returned identifiers of files, represents the file for which error has been encountered when trying to remove it.

Parameters
[in]ctxcontext within which files exist
Returns
first: DB_SUCCESS or DB_ERROR second: identifiers of files for which remove has been called

◆ log_remove_unused_file()

dberr_t log_remove_unused_file ( const Log_files_context ctx,
Log_file_id  file_id 
)

Removes a temporary log file, if it existed.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file to remove
Returns
DB_SUCCESS, DB_NOT_FOUND or DB_ERROR

◆ log_remove_unused_files()

std::pair< dberr_t, ut::vector< Log_file_id > > log_remove_unused_files ( const Log_files_context ctx)

Removes all temporary log files in the directory.

When failed to remove a file, stops and returns error. In such case the last element of the returned identifiers of files, represents the file for which error has been encountered when trying to remove it.

Parameters
[in]ctxcontext within which files exist
Returns
first: DB_SUCCESS or DB_ERROR second: identifiers of files for which remove has been called

◆ log_rename_unused_file()

dberr_t log_rename_unused_file ( const Log_files_context ctx,
Log_file_id  old_unused_file_id,
Log_file_id  new_unused_file_id 
)

Renames the unused file to another unused file.

Parameters
[in]ctxcontext within which files exist
[in]old_unused_file_idid of file to rename
[in]new_unused_file_idnew file id
Returns
DB_SUCCESS or DB_ERROR

◆ log_resize_file()

dberr_t log_resize_file ( const Log_files_context ctx,
Log_file_id  file_id,
os_offset_t  size_in_bytes 
)

Resizes an existing log file to the given size.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file to resize
[in]size_in_bytesrequested size of the file, in bytes
Returns
DB_SUCCESS, DB_NOT_FOUND, DB_OUT_OF_DISK_SPACE or DB_ERROR

◆ log_resize_unused_file()

dberr_t log_resize_unused_file ( const Log_files_context ctx,
Log_file_id  file_id,
os_offset_t  size_in_bytes 
)

Resizes an existing temporary log file to the given size.

Parameters
[in]ctxcontext within which files exist
[in]file_idid of the file to resize
[in]size_in_bytesrequested size of the file, in bytes
Returns
DB_SUCCESS, DB_NOT_FOUND, DB_OUT_OF_DISK_SPACE or DB_ERROR

Variable Documentation

◆ log_checksum_algorithm_ptr

Log_checksum_algorithm_atomic_ptr log_checksum_algorithm_ptr
extern

Atomic pointer to the log checksum calculation function.

This is actually the only remaining "state" of the library. Hopefully can become removed.