MySQL 8.0.39
Source Code Documentation
|
Redo log functions related to checkpointing and log free check. More...
#include "log0log.h"
#include "log0sys.h"
#include "log0types.h"
#include "srv0srv.h"
#include "sync0debug.h"
#include "sync0types.h"
Go to the source code of this file.
Functions | |
Log - basic information about checkpoints. | |
lsn_t | log_get_checkpoint_lsn (const log_t &log) |
Gets the last checkpoint lsn stored and flushed to disk. More... | |
lsn_t | log_get_checkpoint_age (const log_t &log) |
Calculates age of current checkpoint as number of bytes since last checkpoint. More... | |
Log_checkpoint_header_no | log_next_checkpoint_header (Log_checkpoint_header_no checkpoint_header_no) |
Provides opposite checkpoint header number to the given checkpoint header number. More... | |
lsn_t | log_sync_flush_lsn (log_t &log) |
Computes lsn up to which sync flush should be done or returns 0 if there is no need to execute sync flush now. More... | |
Log - requests to make checkpoint. | |
void | log_request_checkpoint (log_t &log, bool sync) |
Requests a fuzzy checkpoint write (for currently available lsn). More... | |
void | log_request_checkpoint_in_next_file (log_t &log) |
Requests a checkpoint written in the next log file (not in the one, to which current log.last_checkpoint_lsn belongs to). More... | |
bool | log_request_latest_checkpoint (log_t &log, lsn_t &requested_lsn) |
Requests a checkpoint at the current lsn. More... | |
bool | log_make_latest_checkpoint (log_t &log) |
Make a checkpoint at the current lsn. More... | |
bool | log_make_latest_checkpoint () |
Make a checkpoint at the current lsn. More... | |
void | log_set_dict_max_allowed_checkpoint_lsn (log_t &log, lsn_t max_lsn) |
Updates the field log.dict_max_allowed_checkpoint_lsn. More... | |
Log - concurrency margins. | |
sn_t | log_concurrency_margin (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... | |
void | log_update_concurrency_margin (log_t &log) |
Updates log.concurrency_margin and log.concurrency_margin_is_safe for the current capacity of the redo log and current innodb_thread_concurrency value. More... | |
Log - free check waiting. | |
void | log_free_check_wait (log_t &log) |
Waits until there is free space in log files which includes concurrency margin required for all threads. More... | |
lsn_t | log_free_check_margin (const log_t &log) |
Provides current margin used in the log_free_check calls. More... | |
lsn_t | log_free_check_capacity (const log_t &log, lsn_t free_check_margin) |
Computes capacity of redo log available until log_free_check() needs to wait. More... | |
lsn_t | log_free_check_capacity (const log_t &log) |
Computes capacity of redo log available until log_free_check() needs to wait. More... | |
bool | log_free_check_is_required (const log_t &log) |
Checks if log_free_check() call should better be executed. More... | |
bool | log_free_check_is_required () |
Checks if log_free_check() call should better be executed. More... | |
void | log_free_check_validate () |
Performs debug checks to validate some of the assumptions. More... | |
void | log_free_check (log_t &log) |
Reserves free_check_margin in the redo space for the current thread. More... | |
void | log_free_check () |
Checks for free space in the redo log. More... | |
Log - free check updates. | |
void | log_update_limits_low (log_t &log) |
Updates log.free_check_limit_lsn in the log. More... | |
void | log_set_dict_persist_margin (log_t &log, sn_t margin) |
Updates log.dict_persist_margin and recompute free check limit. More... | |
Log - other functions related to checkpoints. | |
dberr_t | log_files_write_checkpoint_low (log_t &log, Log_file_handle &checkpoint_file_handle, Log_checkpoint_header_no checkpoint_header_no, lsn_t next_checkpoint_lsn) |
Writes checkpoint to the file containing the written checkpoint_lsn. More... | |
dberr_t | log_files_write_first_data_block_low (log_t &log, Log_file_handle &file_handle, lsn_t checkpoint_lsn, lsn_t file_start_lsn) |
Writes the first data block to the log file using the provided handle to the opened log file. More... | |
dberr_t | log_files_next_checkpoint (log_t &log, lsn_t lsn) |
Writes the next checkpoint to the log file, by writing a single checkpoint header with the checkpoint lsn. More... | |
Log - checkpointer thread and checkpointer mutex. | |
#define | log_checkpointer_mutex_enter(log) mutex_enter(&((log).checkpointer_mutex)) |
#define | log_checkpointer_mutex_exit(log) mutex_exit(&((log).checkpointer_mutex)) |
#define | log_checkpointer_mutex_own(log) (mutex_own(&((log).checkpointer_mutex)) || !log_checkpointer_is_active()) |
void | log_checkpointer (log_t *log_ptr) |
The log checkpointer thread routine. More... | |
bool | log_checkpointer_is_active () |
Checks if log checkpointer thread is active. More... | |
Redo log functions related to checkpointing and log free check.
#define log_checkpointer_mutex_enter | ( | log | ) | mutex_enter(&((log).checkpointer_mutex)) |
#define log_checkpointer_mutex_exit | ( | log | ) | mutex_exit(&((log).checkpointer_mutex)) |
#define log_checkpointer_mutex_own | ( | log | ) | (mutex_own(&((log).checkpointer_mutex)) || !log_checkpointer_is_active()) |
void log_checkpointer | ( | log_t * | log_ptr | ) |
The log checkpointer thread routine.
[in,out] | log_ptr | pointer to redo log |
|
inline |
Checks if log checkpointer thread is active.
Computes concurrency margin to be used within log_free_check calls, for a given redo log capacity (soft_logical_capacity).
[in] | log_capacity | redo log capacity (soft) |
[out] | is_safe | true iff the computed margin wasn't truncated because of too small log_capacity |
Writes the next checkpoint to the log file, by writing a single checkpoint header with the checkpoint lsn.
Flushes the file after the write and updates the log.last_checkpoint_lsn.
[in,out] | log | redo log |
[in] | lsn | writes checkpoint at this lsn |
dberr_t log_files_write_checkpoint_low | ( | log_t & | log, |
Log_file_handle & | checkpoint_file_handle, | ||
Log_checkpoint_header_no | checkpoint_header_no, | ||
lsn_t | next_checkpoint_lsn | ||
) |
Writes checkpoint to the file containing the written checkpoint_lsn.
The checkpoint is written to the given checkpoint header. Unless InnoDB is starting: checkpointer, writer and files mutexes must be acquired before calling this function.
[in,out] | log | redo log |
[in] | checkpoint_file_handle | handle to opened file |
[in] | checkpoint_header_no | checkpoint header to be written |
[in] | next_checkpoint_lsn | the checkpoint lsn to write |
dberr_t log_files_write_first_data_block_low | ( | log_t & | log, |
Log_file_handle & | file_handle, | ||
lsn_t | checkpoint_lsn, | ||
lsn_t | file_start_lsn | ||
) |
Writes the first data block to the log file using the provided handle to the opened log file.
The block is addressed by the given checkpoint_lsn, filled with 0x00 and its data length points to checkpoint_lsn inside, making the block logically empty.
[in,out] | log | redo log |
[in] | file_handle | handle to the opened log file |
[in] | checkpoint_lsn | the checkpoint lsn |
[in] | file_start_lsn | start_lsn of the file |
|
inline |
Checks for free space in the redo log.
Must be called when no latches are held (except those listed as exceptions). Any database operation must call this before it has produced LOG_CHECKPOINT_FREE_PER_THREAD * UNIV_PAGE_SIZE bytes of redo log records. That's because that is the margin in redo log we reserve by calling this function.
For sake of simplicity, you should better not keep any latch when calling to the log_free_check() unless you are really sure about what you are doing.
|
inline |
Reserves free_check_margin in the redo space for the current thread.
For further details please look at description of
[in] | log | redo log |
We prefer to wait now for the space in log file, because now are not holding any latches of dirty pages.
Computes capacity of redo log available until log_free_check() needs to wait.
It calls log_free_check_margin(log) to obtain the current log_free_check_margin.
[in] | log | redo log |
Computes capacity of redo log available until log_free_check() needs to wait.
It uses a provided size of the log_free_check_margin.
[in] | log | redo log |
[in] | free_check_margin | size of the log_free_check_margin; |
|
inline |
Checks if log_free_check() call should better be executed.
|
inline |
Checks if log_free_check() call should better be executed.
[in] | log | redo log |
Provides current margin used in the log_free_check calls.
It is a sum of dict_persist_margin and concurrency_margin.
[in] | log | redo log |
void log_free_check_validate | ( | ) |
Performs debug checks to validate some of the assumptions.
void log_free_check_wait | ( | log_t & | log | ) |
Waits until there is free space in log files which includes concurrency margin required for all threads.
You should rather use log_free_check().
[in] | log | redo log |
Calculates age of current checkpoint as number of bytes since last checkpoint.
This includes bytes for headers and footers of all log blocks. The calculation is based on the latest written checkpoint lsn, and the current lsn, which points to the first non reserved data byte. Note that the current lsn could not fit the free space in the log files. This means that the checkpoint age could potentially be larger than capacity of the log files. However we do the best effort to avoid such situations, and if they happen, user threads wait until the space is reclaimed.
[in] | log | redo log |
Gets the last checkpoint lsn stored and flushed to disk.
bool log_make_latest_checkpoint | ( | ) |
Make a checkpoint at the current lsn.
Reads current lsn and waits until all dirty pages have been flushed up to that lsn. Afterwards requests a checkpoint write and waits until it is finished.
bool log_make_latest_checkpoint | ( | log_t & | log | ) |
Make a checkpoint at the current lsn.
Reads current lsn and waits until all dirty pages have been flushed up to that lsn. Afterwards requests a checkpoint write and waits until it is finished.
[in,out] | log | redo log |
Log_checkpoint_header_no log_next_checkpoint_header | ( | Log_checkpoint_header_no | checkpoint_header_no | ) |
Provides opposite checkpoint header number to the given checkpoint header number.
[in] | checkpoint_header_no | the given checkpoint header number |
void log_request_checkpoint | ( | log_t & | log, |
bool | sync | ||
) |
Requests a fuzzy checkpoint write (for currently available lsn).
[in,out] | log | redo log |
[in] | sync | whether request is sync (function should wait) |
void log_request_checkpoint_in_next_file | ( | log_t & | log | ) |
Requests a checkpoint written in the next log file (not in the one, to which current log.last_checkpoint_lsn belongs to).
[in,out] | log | redo log |
Requests a checkpoint at the current lsn.
[in,out] | log | redo log |
[out] | requested_lsn | lsn for which checkpoint was requested, or stays unmodified if it wasn't requested |
Updates the field log.dict_max_allowed_checkpoint_lsn.
This is limitation for lsn at which checkpoint might be written, imposed by cached changes to the DD table buffer. It is called from DD code.
[in,out] | log | redo log |
[in] | max_lsn | new value for the limitation |
Updates log.dict_persist_margin and recompute free check limit.
[in,out] | log | redo log |
[in] | margin | new value for log.dict_persist_margin |
Computes lsn up to which sync flush should be done or returns 0 if there is no need to execute sync flush now.
[in,out] | log | redo log |
void log_update_concurrency_margin | ( | log_t & | log | ) |
Updates log.concurrency_margin and log.concurrency_margin_is_safe for the current capacity of the redo log and current innodb_thread_concurrency value.
[in,out] | log | redo log |
void log_update_limits_low | ( | log_t & | log | ) |
Updates log.free_check_limit_lsn in the log.
The log_limits_mutex must be acquired before a call (unless srv_is_being_started is true).
[in,out] | log | redo log |