MySQL 8.0.40
Source Code Documentation
|
Responsible for the redo log capacity computations. More...
#include <log0files_capacity.h>
Classes | |
struct | Exposed |
Private Attributes | |
Exposed | m_exposed {} |
Cache for values returned by getters in this object, which otherwise would need to be computed on-demand. More... | |
os_offset_t | m_current_physical_capacity {0} |
This is limitation for space on disk we are never allowed to exceed. More... | |
os_offset_t | m_target_physical_capacity {0} |
Goal we are trying to achieve for m_current_physical_capacity when resize operation is in progress, else: equal to m_current_physical_capacity. More... | |
Log_resize_mode | m_resize_mode {Log_resize_mode::NONE} |
Current resize direction. More... | |
Log_files_capacity implementation | |
void | initialize (const Log_files_dict &files, lsn_t current_logical_size, lsn_t current_checkpoint_age) |
Initialize on discovered set of redo log files (empty set if new redo is being created). More... | |
void | update (const Log_files_dict &files, lsn_t current_logical_size, lsn_t current_checkpoint_age) |
Updates all internal limits according to the provided parameters. More... | |
bool | is_resizing_down () const |
os_offset_t | current_physical_capacity () const |
Provides maximum limitation for space occupied on disk. More... | |
os_offset_t | target_physical_capacity () const |
If a redo downsize is in progress, it is the targeted value for the current_physical_capacity() (is equal if there is no resize in progress). More... | |
lsn_t | soft_logical_capacity () const |
Soft limit for logical capacity of the redo log. More... | |
lsn_t | hard_logical_capacity () const |
Hard limit for logical capacity of the redo log. More... | |
lsn_t | adaptive_flush_min_age () const |
Once checkpoint age exceeds this value, the flushing of pages starts to be adaptive. More... | |
lsn_t | adaptive_flush_max_age () const |
Once checkpoint age exceeds that value, the flushing of pages is the most aggressive possible since then. More... | |
lsn_t | aggressive_checkpoint_min_age () const |
Once checkpoint age exceeds that value, the log checkpointer thread keeps writing checkpoints aggressively (whatever the progress of last_checkpoint_lsn would it make). More... | |
os_offset_t | next_file_size () const |
Provides size of the next redo log file that will be created. More... | |
lsn_t | next_file_earlier_margin () const |
Provides margin which might be used ahead of the newest lsn to create a next file earlier if needed (it will be created as unused redo file). More... | |
static os_offset_t | next_file_size (os_offset_t physical_capacity) |
Computes size of a next redo log file that would be chosen for a given physical capacity. More... | |
static lsn_t | next_file_earlier_margin (os_offset_t physical_capacity) |
Computes margin which might be used ahead of the newest lsn to create a next file earlier if needed (it will be created as unused redo file). More... | |
static lsn_t | guess_hard_logical_capacity_for_soft (lsn_t soft_logical_capacity) |
Computes hard logical capacity, that corresponds to the provided soft logical capacity of the redo log (. More... | |
static lsn_t | soft_logical_capacity_for_hard (lsn_t hard_logical_capacity) |
Computes soft logical capacity, that corresponds to the provided hard logical capacity of the redo log (. More... | |
static lsn_t | hard_logical_capacity_for_physical (os_offset_t physical_capacity) |
Computes hard logical capacity, that corresponds to the provided physical capacity of the redo log (. More... | |
static lsn_t | sync_flush_logical_capacity_for_soft (lsn_t soft_logical_capacity) |
Computes maximum age of dirty pages up to which there is no sync flush enforced on page cleaners. More... | |
static lsn_t | guess_soft_logical_capacity_for_sync_flush (lsn_t adaptive_flush_max_age) |
Computes soft logical capacity, that corresponds to the provided maximum age of dirty pages up to which there is no sync flush enforced on page cleaners. More... | |
void | cancel_resize () |
Cancels current resize operation immediately. More... | |
void | update_target () |
Updates m_target_physical_capacity (reading srv_redo_log_capacity_used) and possibly starts a new downsize operation. More... | |
bool | is_target_reached_for_logical_size (lsn_t current_logical_size) const |
Checks if target of the resize is reached, with regards to the criteria based on the current logical size of the redo. More... | |
bool | is_target_reached_for_physical_size (os_offset_t current_physical_size) const |
Checks if target of the resize is reached, with regards to the criteria based on the current physical size of existing log files (excludes unused). More... | |
bool | is_target_reached_for_max_file_size (const Log_files_dict &files) const |
Checks if target of the resize is reached, with regards to the criteria based on the largest existing redo file. More... | |
bool | is_target_reached_for_resizing_down (const Log_files_dict &files, lsn_t current_logical_size) const |
Checks if target of the resize is reached. More... | |
void | update_if_target_reached (const Log_files_dict &files, lsn_t current_logical_size) |
Checks if target of the resize is reached with regards to all criteria and updates the m_resize_mode, m_current_physical_capacity when that happens (marking the resize operation as finished). More... | |
void | update_resize_status_variable () |
Updates value of server status variable: innodb_redo_log_resize_status. More... | |
void | update_status_variables (const Log_files_dict &files, lsn_t current_logical_size) |
Updates values of server status variables: innodb_redo_log_capacity_resized, innodb_redo_log_logical_size, innodb_redo_log_physical_size, innodb_redo_log_resize_status. More... | |
void | update_exposed (lsn_t current_logical_size) |
Updates cached and exposed values related to the logical redo capacity: More... | |
lsn_t | get_suggested_hard_logical_capacity (lsn_t current_checkpoint_age) const |
Computes suggested value for the current hard logical capacity. More... | |
Responsible for the redo log capacity computations.
Computes size for the next log file that will be created. Tracks the redo resize operation when the innodb_redo_log_capacity gets changed. Computes maximum ages for dirty pages, which are then used by page cleaner coordinator.
lsn_t Log_files_capacity::adaptive_flush_max_age | ( | ) | const |
Once checkpoint age exceeds that value, the flushing of pages is the most aggressive possible since then.
For more details
lsn_t Log_files_capacity::adaptive_flush_min_age | ( | ) | const |
Once checkpoint age exceeds this value, the flushing of pages starts to be adaptive.
The adaptive page flushing is becoming more and more aggressive in the following range: adaptive_flush_min_age()..adaptive_flush_max_age().
adaptive_flush_min_age adaptive_flush_max_age aggressive_checkpoint_min_age | | | ----—!---------------------—!------------------—!--------------—>age regular adaptive flushing aggressive flushing aggr. checkpoints
lsn_t Log_files_capacity::aggressive_checkpoint_min_age | ( | ) | const |
Once checkpoint age exceeds that value, the log checkpointer thread keeps writing checkpoints aggressively (whatever the progress of last_checkpoint_lsn would it make).
Before that happens, checkpoints could be written periodically (for more details
|
private |
Cancels current resize operation immediately.
os_offset_t Log_files_capacity::current_physical_capacity | ( | ) | const |
Provides maximum limitation for space occupied on disk.
|
private |
Computes suggested value for the current hard logical capacity.
[in] | current_checkpoint_age | current checkpoint age, used only when resizing down |
|
static |
Computes hard logical capacity, that corresponds to the provided soft logical capacity of the redo log (.
[in] | soft_logical_capacity | logical capacity for user threads, used in log_free_check() calls |
|
static |
Computes soft logical capacity, that corresponds to the provided maximum age of dirty pages up to which there is no sync flush enforced on page cleaners.
This is a larger value than the provided maximum age, because sync flush must be started earlier than log_free_check() calls begin to stop user threads.
[in] | adaptive_flush_max_age | maximum age of dirty page without sync flush started |
lsn_t Log_files_capacity::hard_logical_capacity | ( | ) | const |
Hard limit for logical capacity of the redo log.
This limitation includes "extra_writer_margin" that belongs to the log writer thread. The log writer does not to exceed this limit. If space isn't reclaimed after 1 sec wait, it writes only as much as possible or crashes the InnoDB.
|
static |
Computes hard logical capacity, that corresponds to the provided physical capacity of the redo log (.
[in] | physical_capacity | physical capacity for the redo log |
void Log_files_capacity::initialize | ( | const Log_files_dict & | files, |
lsn_t | current_logical_size, | ||
lsn_t | current_checkpoint_age | ||
) |
Initialize on discovered set of redo log files (empty set if new redo is being created).
[in] | files | in-memory dictionary of existing files |
[in] | current_logical_size | current logical size of data in redo, or 0 if new redo is being created |
[in] | current_checkpoint_age | current checkpoint age |
bool Log_files_capacity::is_resizing_down | ( | ) | const |
|
private |
Checks if target of the resize is reached, with regards to the criteria based on the current logical size of the redo.
[in] | current_logical_size | current logical size of the redo log |
|
private |
Checks if target of the resize is reached, with regards to the criteria based on the largest existing redo file.
[in] | files | in-memory dictionary of existing files |
|
private |
Checks if target of the resize is reached, with regards to the criteria based on the current physical size of existing log files (excludes unused).
[in] | current_physical_size | total size of existing redo log files, excluding unused (spare) files |
|
private |
Checks if target of the resize is reached.
[in] | files | in-memory dictionary of existing files |
[in] | current_logical_size | current logical size of the redo log |
lsn_t Log_files_capacity::next_file_earlier_margin | ( | ) | const |
Provides margin which might be used ahead of the newest lsn to create a next file earlier if needed (it will be created as unused redo file).
|
static |
Computes margin which might be used ahead of the newest lsn to create a next file earlier if needed (it will be created as unused redo file).
The computation is done for a given physical capacity.
[in] | physical_capacity | physical capacity assumed for computation |
os_offset_t Log_files_capacity::next_file_size | ( | ) | const |
Provides size of the next redo log file that will be created.
The initial value becomes set during a call to
|
static |
Computes size of a next redo log file that would be chosen for a given physical capacity.
[in] | physical_capacity | physical capacity assumed for computation |
lsn_t Log_files_capacity::soft_logical_capacity | ( | ) | const |
Soft limit for logical capacity of the redo log.
When the log writer exceeds this limitation, all user threads are paused during log_free_check() calls and message is emitted to the error log. The log writer can still continue to write until it reaches the hard limit for logical capacity (value returned by hard_logical_capacity()).
Computes soft logical capacity, that corresponds to the provided hard logical capacity of the redo log (.
[in] | hard_logical_capacity | logical capacity for the log writer |
|
static |
Computes maximum age of dirty pages up to which there is no sync flush enforced on page cleaners.
This is a smaller value than soft logical capacity, because sync flush must be started earlier than log_free_check() calls begin to stop user threads.
[in] | soft_logical_capacity | logical capacity for user threads, used in log_free_check() calls |
os_offset_t Log_files_capacity::target_physical_capacity | ( | ) | const |
If a redo downsize is in progress, it is the targeted value for the current_physical_capacity() (is equal if there is no resize in progress).
It is set to srv_redo_log_capacity_used when
void Log_files_capacity::update | ( | const Log_files_dict & | files, |
lsn_t | current_logical_size, | ||
lsn_t | current_checkpoint_age | ||
) |
Updates all internal limits according to the provided parameters.
If there are any values outside this class, on which computations of limits depend on, they should be explicitly provided here, except the server variables (srv_thread_concurrency, srv_redo_log_capacity_used).
[in] | files | in-memory dictionary of files |
[in] | current_logical_size | current logical size of data in the redo log; it depends directly on the oldest redo log consumer |
[in] | current_checkpoint_age | current checkpoint age |
|
private |
Updates cached and exposed values related to the logical redo capacity:
[in] | current_logical_size | current logical size of the redo log |
|
private |
Checks if target of the resize is reached with regards to all criteria and updates the m_resize_mode, m_current_physical_capacity when that happens (marking the resize operation as finished).
[in] | files | in-memory dictionary of existing files |
[in] | current_logical_size | current logical size of the redo log |
|
private |
Updates value of server status variable: innodb_redo_log_resize_status.
|
private |
Updates values of server status variables: innodb_redo_log_capacity_resized, innodb_redo_log_logical_size, innodb_redo_log_physical_size, innodb_redo_log_resize_status.
[in] | files | in-memory dictionary of existing files |
[in] | current_logical_size | current logical size of the redo log |
|
private |
Updates m_target_physical_capacity (reading srv_redo_log_capacity_used) and possibly starts a new downsize operation.
Might also update: m_resize_mode, m_current_physical_capacity.
|
private |
This is limitation for space on disk we are never allowed to exceed.
This is the guard of disk space - current size of all log files on disk is always not greater than this value.
|
private |
Cache for values returned by getters in this object, which otherwise would need to be computed on-demand.
These values do not have impact on state updates of this object.
|
private |
Current resize direction.
When user decides to resize down the redo log, it becomes Log_resize_mode::RESIZING_DOWN until the resize is finished or user decides to stop it (providing other capacity). Note, that resize is not started during startup (when srv_is_being_started is true).
|
private |
Goal we are trying to achieve for m_current_physical_capacity when resize operation is in progress, else: equal to m_current_physical_capacity.
During startup (when srv_is_being_started is true) it stays equal to the m_current_physical_capacity (which is then computed for discovered log files). After startup, it's set to srv_redo_log_capacity_used by calls to