MySQL 8.0.39
Source Code Documentation
|
Redo log - the main header. More...
#include "log0files_capacity.h"
#include "log0files_dict.h"
#include "log0files_finder.h"
#include "log0files_governor.h"
#include "log0files_io.h"
#include "log0sys.h"
#include "log0types.h"
Go to the source code of this file.
Functions | |
Log - LSN computations. | |
constexpr lsn_t | log_translate_sn_to_lsn (sn_t sn) |
Calculates lsn value for given sn value. More... | |
sn_t | log_translate_lsn_to_sn (lsn_t lsn) |
Calculates sn value for given lsn value. More... | |
bool | log_is_data_lsn (lsn_t lsn) |
Validates a given lsn value. More... | |
Log - general functions. | |
static sn_t | log_get_sn (const log_t &log) |
lsn_t | log_get_lsn (const log_t &log) |
Gets the current lsn value. More... | |
void | log_wait_for_space (log_t &log, sn_t end_sn) |
Waits until there is free space for range of sn values ending at the provided sn, in both the log buffer and in the log files. More... | |
void | log_print (const log_t &log, FILE *file) |
Prints information about important lsn values used in the redo log, and some statistics about speed of writing and flushing of data. More... | |
void | log_refresh_stats (log_t &log) |
Refreshes the statistics used to print per-second averages in log_print(). More... | |
void | log_update_exported_variables (const log_t &log) |
Log - initialization of the redo log system. | |
dberr_t | log_sys_init (bool expect_no_files, lsn_t flushed_lsn, lsn_t &new_files_lsn) |
Initializes log_sys and finds existing redo log files, or creates a new set of redo log files. More... | |
dberr_t | log_start (log_t &log, lsn_t checkpoint_lsn, lsn_t start_lsn, bool allow_checkpoints=true) |
Starts the initialized redo log system using a provided checkpoint_lsn and current lsn. More... | |
void | log_sys_close () |
Close the log system and free all the related memory. More... | |
void | log_write_ahead_resize (log_t &log, size_t new_size) |
Resizes the write ahead buffer in the redo log. More... | |
Log - the log position locking. | |
void | log_position_lock (log_t &log) |
Lock redo log. More... | |
void | log_position_unlock (log_t &log) |
Unlock the locked redo log. More... | |
void | log_position_collect_lsn_info (const log_t &log, lsn_t *current_lsn, lsn_t *checkpoint_lsn) |
Collect coordinates in the locked redo log. More... | |
Log - persisting the flags. | |
void | log_persist_disable (log_t &log) |
Disable redo logging and persist the information. More... | |
void | log_persist_enable (log_t &log) |
Enable redo logging and persist the information. More... | |
void | log_persist_crash_safe (log_t &log) |
Persist the information that it is safe to restart server. More... | |
void | log_persist_initialized (log_t &log) |
Marks the redo log files as belonging to the initialized data directory with initialized set of redo log files. More... | |
void | log_crash_safe_validate (log_t &log) |
Asserts that the log is not marked as crash-unsafe. More... | |
Log - the log threads and mutexes | |
#define | log_limits_mutex_enter(log) mutex_enter(&((log).limits_mutex)) |
#define | log_limits_mutex_exit(log) mutex_exit(&((log).limits_mutex)) |
#define | log_limits_mutex_own(log) mutex_own(&(log).limits_mutex) |
void | log_background_threads_active_validate (const log_t &log) |
Validates that all the log background threads are active. More... | |
void | log_background_threads_inactive_validate () |
Validates that all the log background threads are inactive. More... | |
void | log_start_background_threads (log_t &log) |
Starts all the log background threads. More... | |
void | log_stop_background_threads (log_t &log) |
Stops all the log background threads. More... | |
void | log_stop_background_threads_nowait (log_t &log) |
Marks the flag which tells log threads to stop and wakes them. More... | |
void | log_make_empty_and_stop_background_threads (log_t &log) |
Function similar to. More... | |
void | log_wake_threads (log_t &log) |
Wakes up all log threads which are alive. More... | |
Redo log - the main header.
Basic types are defined inside log0types.h.
Constant values are defined inside log0constants.h, but that file should only be included by log0types.h.
The log_sys is defined in log0sys.h.
Functions related to the log buffer are declared in log0buf.h.
Functions related to the checkpoints are declared in log0chkp.h.
Functions related to the writer/flusher are declared in log0write.h.
Functions computing capacity of redo and related margins are declared in log0files_capacity.h.
Functions doing IO to log files and formatting log blocks are declared in log0files_io.h.
#define log_limits_mutex_enter | ( | log | ) | mutex_enter(&((log).limits_mutex)) |
#define log_limits_mutex_exit | ( | log | ) | mutex_exit(&((log).limits_mutex)) |
#define log_limits_mutex_own | ( | log | ) | mutex_own(&(log).limits_mutex) |
void log_background_threads_active_validate | ( | const log_t & | log | ) |
Validates that all the log background threads are active.
Used only to assert, that the state is correct.
[in] | log | redo log |
void log_background_threads_inactive_validate | ( | ) |
Validates that all the log background threads are inactive.
Used only to assert, that the state is correct.
void log_crash_safe_validate | ( | log_t & | log | ) |
Asserts that the log is not marked as crash-unsafe.
[in,out] | log | redo log |
Gets the current lsn value.
This value points to the first non reserved data byte in the redo log. When next user thread reserves space in the redo log, it starts at this lsn.
If the last reservation finished exactly before footer of log block, this value points to the first byte after header of the next block.
|
inline |
Validates a given lsn value.
Checks if the lsn value points to data bytes inside log block (not to some bytes in header/footer). It is used by assertions.
void log_make_empty_and_stop_background_threads | ( | log_t & | log | ) |
Function similar to.
void log_persist_crash_safe | ( | log_t & | log | ) |
Persist the information that it is safe to restart server.
[in,out] | log | redo log |
void log_persist_disable | ( | log_t & | log | ) |
Disable redo logging and persist the information.
[in,out] | log | redo log |
void log_persist_enable | ( | log_t & | log | ) |
Enable redo logging and persist the information.
[in,out] | log | redo log |
void log_persist_initialized | ( | log_t & | log | ) |
Marks the redo log files as belonging to the initialized data directory with initialized set of redo log files.
Flushes the log_flags without the flag LOG_HEADER_FLAG_NOT_INITIALIZED to the newest redo log file.
[in,out] | log | redo log |
void log_position_collect_lsn_info | ( | const log_t & | log, |
lsn_t * | current_lsn, | ||
lsn_t * | checkpoint_lsn | ||
) |
Collect coordinates in the locked redo log.
[in] | log | locked redo log |
[out] | current_lsn | stores current lsn there |
[out] | checkpoint_lsn | stores checkpoint lsn there |
void log_position_lock | ( | log_t & | log | ) |
Lock redo log.
Both current lsn and checkpoint lsn will not change until the redo log is unlocked.
[in,out] | log | redo log to lock |
void log_position_unlock | ( | log_t & | log | ) |
Unlock the locked redo log.
[in,out] | log | redo log to unlock |
void log_print | ( | const log_t & | log, |
FILE * | file | ||
) |
Prints information about important lsn values used in the redo log, and some statistics about speed of writing and flushing of data.
[in] | log | redo log for which print information |
[out] | file | file where to print |
void log_refresh_stats | ( | log_t & | log | ) |
Refreshes the statistics used to print per-second averages in log_print().
[in,out] | log | redo log |
dberr_t log_start | ( | log_t & | log, |
lsn_t | checkpoint_lsn, | ||
lsn_t | start_lsn, | ||
bool | allow_checkpoints = true |
||
) |
Starts the initialized redo log system using a provided checkpoint_lsn and current lsn.
Block for current_lsn must be properly initialized in the log buffer prior to calling this function. Therefore a proper value of first_rec_group must be set for that block before log_start is called.
[in,out] | log | redo log |
[in] | checkpoint_lsn | checkpoint lsn |
[in] | start_lsn | current lsn to start at |
[in] | allow_checkpoints | true iff allows writing newer checkpoints |
void log_start_background_threads | ( | log_t & | log | ) |
Starts all the log background threads.
This can be called only, when the threads are inactive. This should never be called concurrently. This may not be called during read-only mode.
[in,out] | log | redo log |
void log_stop_background_threads | ( | log_t & | log | ) |
Stops all the log background threads.
This can be called only, when the threads are active. This should never be called concurrently. This may not be called in read-only mode. Note that is is impossible to start log background threads in such case.
[in,out] | log | redo log |
void log_stop_background_threads_nowait | ( | log_t & | log | ) |
Marks the flag which tells log threads to stop and wakes them.
Does not wait until they are stopped.
[in,out] | log | redo log |
void log_sys_close | ( | ) |
Close the log system and free all the related memory.
Initializes log_sys and finds existing redo log files, or creates a new set of redo log files.
New redo log files are created in following cases:
After this call, the log_sys global variable is allocated and initialized. InnoDB might start recovery then.
[in] | expect_no_files | true means we should return DB_ERROR if log files are present in the directory before proceeding any further |
[in] | flushed_lsn | lsn at which new redo log files might be started if they had to be created during this call; this should be lsn stored in the system tablespace header at offset FIL_PAGE_FILE_FLUSH_LSN if the data directory has been initialized; |
[out] | new_files_lsn | updated to the lsn of the first checkpoint created in the new log files if new log files are created; else: 0 |
Calculates sn value for given lsn value.
[in] | lsn | lsn value |
Calculates lsn value for given sn value.
Sequence of sn values enumerate all data bytes in the redo log. Sequence of lsn values enumerate all data bytes and bytes used for headers and footers of all log blocks in the redo log. For every LOG_BLOCK_DATA_SIZE bytes of data we have OS_FILE_LOG_BLOCK_SIZE bytes in the redo log. NOTE that LOG_BLOCK_DATA_SIZE + LOG_BLOCK_HDR_SIZE + LOG_BLOCK_TRL_SIZE == OS_FILE_LOG_BLOCK_SIZE. The calculated lsn value will always point to some data byte (will be % OS_FILE_LOG_BLOCK_SIZE >= LOG_BLOCK_HDR_SIZE, and < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE).
[in] | sn | sn value |
void log_update_exported_variables | ( | const log_t & | log | ) |
Waits until there is free space for range of sn values ending at the provided sn, in both the log buffer and in the log files.
[in] | log | redo log |
[in] | end_sn | end of the range of sn values |
void log_wake_threads | ( | log_t & | log | ) |
Wakes up all log threads which are alive.
[in,out] | log | redo log |
void log_write_ahead_resize | ( | log_t & | log, |
size_t | new_size | ||
) |
Resizes the write ahead buffer in the redo log.
[in,out] | log | redo log |
[in] | new_size | new size (in bytes) |