![]() |
MySQL 26.7.0
Source Code Documentation
|
#include <log0chkp.h>
Public Member Functions | |
Last known checkpoint lsn value | |
| void | set_checkpoint (lsn_t checkpoint_lsn) |
| Updates the cached checkpoint_lsn. More... | |
| lsn_t | get_checkpoint () |
| bool | save_checkpoint_value (lsn_t checkpoint_lsn) |
| Save the checkpoint lsn to the persistent store. More... | |
| dberr_t | load_checkpoint_value () |
| Fetch the checkpoint lsn from the persistent store. More... | |
The log_free_check() mechanism | |
| void | update_limits () |
| Calls ib::redo::handler->do_not_need_smaller_than(get_checkpoint_lsn()). More... | |
Static Public Member Functions | |
| static void | init () |
| Allocates and constructs the global log_checkpointing object. More... | |
| static void | deinit () |
| Destructs and deallocates the global log_checkpointing object. More... | |
Public Attributes | |
| os_event_t | m_event |
| Event used by the log checkpointer thread to wait for requests. More... | |
| os_event_t | m_next_checkpoint_event |
| Event signaled by log checkpointer when it advances m_checkpoint_lsn. More... | |
| ib_mutex_t | checkpoint_mutex |
| Mutex which can be used to pause log checkpointer thread. More... | |
| ib_mutex_t | limits_mutex |
| Mutex which protects fields: m_available_for_checkpoint_lsn, m_requested_checkpoint_lsn. More... | |
Private Member Functions | |
| Log_checkpointing () | |
| ~Log_checkpointing () | |
Making checkpoints | |
| lsn_t | determine_checkpoint_lsn () |
| Figures out m_available_for_checkpoint_lsn. More... | |
| void | consider_sync_flush () |
| Considers requesting page cleaners to execute sync flush. More... | |
| bool | should_checkpoint () |
| Checks if checkpoint should be written. More... | |
| void | consider_checkpoint () |
| Considers writing next checkpoint. More... | |
| void | create_checkpoint () |
| Makes a checkpoint. More... | |
Private Attributes | |
| std::atomic_bool | m_thread_should_stop {} |
| atomic_lsn_t | m_checkpoint_lsn {} |
| Latest checkpoint lsn. More... | |
| Log_clock_point | m_last_checkpoint_time {} |
| Latest checkpoint wall time. More... | |
| bool | m_periodical_checkpoints_enabled {} |
| If should perform checkpoints every innodb_log_checkpoint_every ms, or when doing so would help reclaim oldest redo log file. More... | |
| THD * | m_checkpointer_thd |
| THD used by the log_checkpointer thread. More... | |
Fields protected by the log_limits_mutex. | |
Related to free space in the redo log. | |
| lsn_t | m_available_for_checkpoint_lsn {} |
| A new checkpoint could be written for this lsn value. More... | |
| atomic_lsn_t | m_requested_checkpoint_lsn {} |
| When this is larger than the latest checkpoint, the log checkpointer thread will be forced to write a new checkpoint (unless the new latest checkpoint lsn would still be smaller than this value). More... | |
Friends | |
| template<typename T > | |
| void | ut::aligned_delete (T *ptr) noexcept |
| template<typename T , typename... Args> | |
| T * | ut::aligned_new_withkey (ut::PSI_memory_key_t key, std::size_t alignment, Args &&...args) |
Coordination with buffer pool and oldest_lsn | |
| lsn_t | update_available_for_checkpoint_lsn () |
| Updates lsn available for checkpoint. More... | |
| lsn_t | get_available_for_checkpoint_lsn () const |
Requests to make checkpoint | |
| lsn_t | get_requested_checkpoint_lsn () |
| Returns highest requested checkpoint lsn. More... | |
| bool | request_checkpoint (lsn_t requested_lsn) |
| Requests a checkpoint written for lsn greater or equal to provided one. More... | |
| void | request_fuzzy_checkpoint (bool sync) |
| Requests a fuzzy checkpoint write (for currently available lsn). More... | |
| void | request_sharp_checkpoint () |
| Make a checkpoint at the current lsn. More... | |
Periodical updates | |
| bool | are_periodical_checkpoints_enabled () const |
| std::chrono::steady_clock::duration | time_since_checkpoint () |
| Calculates time that elapsed since last checkpoint. More... | |
| void | enable_periodical_checkpoints () |
The checkpointer thread | |
| void | do_work () |
| The actual non-static body of the static log_checkpointer() More... | |
| void | stop_thread_no_wait () |
| Informs the log checkpointer that it should stop, but does not wait for it to happen. More... | |
| void | stop_thread_and_wait () |
| Informs the log checkpointer that it should stop and waits for it to happen before returning to the caller. More... | |
| void | start_thread () |
| Starts the log checkpointer thread. More... | |
| static void | log_checkpointer () |
| The log checkpointer thread routine. More... | |
Dirty page flushing speed control | |
| void | get_limits (lsn_t &limit_for_free_check, lsn_t &limit_for_dirty_page_age) |
| Retrieves limitations determined by the current state of log.m_capacity. More... | |
| lsn_t | get_sync_flush_lsn () |
| Computes lsn up to which sync flush of pages should be done or returns 0 if there is no need to execute sync flush of dirty pages now. More... | |
| static lsn_t | adaptive_flush_min_age () |
| Once checkpoint age exceeds this value, the flushing of pages starts to be adaptive. More... | |
| static lsn_t | adaptive_flush_max_age () |
| Once checkpoint age exceeds that value, the flushing of pages is the most aggressive possible since then. More... | |
| static lsn_t | aggressive_checkpoint_min_age () |
| 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... | |
|
private |
|
private |
|
static |
Once checkpoint age exceeds that value, the flushing of pages is the most aggressive possible since then.
For more details
|
static |
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
|
static |
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
|
inlineprivate |
|
private |
Considers writing next checkpoint.
Checks if checkpoint should be written (using should_checkpoint()) and writes the checkpoint if that's the case.
|
private |
Considers requesting page cleaners to execute sync flush.
|
private |
Makes a checkpoint.
Note that this function does not flush dirty blocks from the buffer pool. It only checks what is lsn of the oldest modification in the buffer pool, and writes information about the lsn in log files.
|
static |
Destructs and deallocates the global log_checkpointing object.
|
private |
Figures out m_available_for_checkpoint_lsn.
|
private |
The actual non-static body of the static log_checkpointer()
|
inline |
|
inline |
|
inline |
| void Log_checkpointing::get_limits | ( | lsn_t & | limit_for_free_check, |
| lsn_t & | limit_for_dirty_page_age | ||
| ) |
Retrieves limitations determined by the current state of log.m_capacity.
These values are retrieved atomically (are consistent with each other).
| [out] | limit_for_free_check | soft capacity of the redo decreased by the current free check margin; this is limit for size of redo until which the log_free_check calls do not force waits |
| [out] | limit_for_dirty_page_age | limit for the oldest dirty page until which the async (adaptive) flushing is not forced to be started (it might be started if turned on explicitly by the innodb_adaptive_flushing); note that computation of this value include doing the subtraction of the current log free check margin |
|
inlineprivate |
Returns highest requested checkpoint lsn.
| lsn_t Log_checkpointing::get_sync_flush_lsn | ( | ) |
Computes lsn up to which sync flush of pages should be done or returns 0 if there is no need to execute sync flush of dirty pages now.
|
static |
Allocates and constructs the global log_checkpointing object.
| dberr_t Log_checkpointing::load_checkpoint_value | ( | ) |
Fetch the checkpoint lsn from the persistent store.
|
static |
The log checkpointer thread routine.
| bool Log_checkpointing::request_checkpoint | ( | lsn_t | requested_lsn | ) |
Requests a checkpoint written for lsn greater or equal to provided one.
Caller must hold log_limits_mutex
| [in] | requested_lsn | checkpoint should be not older than this |
| void Log_checkpointing::request_fuzzy_checkpoint | ( | bool | sync | ) |
Requests a fuzzy checkpoint write (for currently available lsn).
| [in] | sync | whether request is sync (function should wait) |
| void Log_checkpointing::request_sharp_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_checkpointing::save_checkpoint_value | ( | lsn_t | checkpoint_lsn | ) |
Save the checkpoint lsn to the persistent store.
| [in] | checkpoint_lsn | checkpoint lsn to be persisted |
|
inline |
Updates the cached checkpoint_lsn.
|
private |
Checks if checkpoint should be written.
Checks time elapsed since the last checkpoint, age of the last checkpoint and if there was any extra request to write the checkpoint (e.g. coming from log_checkpointing->request_sharp_checkpoint()).
| void Log_checkpointing::start_thread | ( | ) |
Starts the log checkpointer thread.
| void Log_checkpointing::stop_thread_and_wait | ( | ) |
Informs the log checkpointer that it should stop and waits for it to happen before returning to the caller.
| void Log_checkpointing::stop_thread_no_wait | ( | ) |
Informs the log checkpointer that it should stop, but does not wait for it to happen.
|
private |
Calculates time that elapsed since last checkpoint.
|
private |
Updates lsn available for checkpoint.
(Never decreases it)
| void Log_checkpointing::update_limits | ( | ) |
Calls ib::redo::handler->do_not_need_smaller_than(get_checkpoint_lsn()).
We prefer to have Log_checkpointing be the only place which calls do_not_need_smaller_than() so that it is easier to reason about, and to ensure that the argument passed is the checkpoint. We know that ib::redo::Handler::do_not_need_smaller_than() will recompute log_sys->m_free_check_limit_lsn used in wait_for_space(), based on things like checkpoint_lsn, log.m_capacity etc, so we call update_limits() whenever any of them changes.
|
friend |
|
friend |
|
mutable |
Mutex which can be used to pause log checkpointer thread.
This is used by log_position_lock() together with log_buffer_x_lock(), to pause any changes to current_lsn or last_checkpoint_lsn.
|
mutable |
Mutex which protects fields: m_available_for_checkpoint_lsn, m_requested_checkpoint_lsn.
It also synchronizes updates of log_sys_t::m_free_check_limit_lsn. It protects reads and writes of log_sys_t::m_writer_inside_extra_margin. It also protects the srv_checkpoint_disabled (together with the checkpoint_mutex).
|
private |
A new checkpoint could be written for this lsn value.
Up to this lsn value, all dirty pages have been added to flush lists and flushed. Updated in the log checkpointer thread by taking minimum oldest_modification out of the last dirty pages from each flush list minus Buf_flush_list_added_lsns::order_lag(). However, it will not be bigger than the current value of Buf_flush_list_added_lsns::smallest_not_added_lsn(). Read by: user threads when requesting fuzzy checkpoint Read by: log_print() (printing status of redo) Updated by: log_checkpointer Protected by: limits_mutex.
|
private |
Latest checkpoint lsn.
Read by: user threads, log_print (no protection) Read by: log_writer (under writer_mutex) Updated by: log_checkpointer (under both mutexes) Protected by (updates only): checkpoint_mutex + writer_mutex.
|
private |
THD used by the log_checkpointer thread.
| os_event_t Log_checkpointing::m_event |
Event used by the log checkpointer thread to wait for requests.
|
private |
Latest checkpoint wall time.
Used by (private): log_checkpointer. Protected by: checkpoint_mutex (although, its used only from one thread)
| os_event_t Log_checkpointing::m_next_checkpoint_event |
Event signaled by log checkpointer when it advances m_checkpoint_lsn.
|
private |
If should perform checkpoints every innodb_log_checkpoint_every ms, or when doing so would help reclaim oldest redo log file.
Disabled during startup. Enabled in srv_start_threads. Updated by: starting thread (srv_start_threads) Read by: log_checkpointer
|
private |
When this is larger than the latest checkpoint, the log checkpointer thread will be forced to write a new checkpoint (unless the new latest checkpoint lsn would still be smaller than this value).
Read by: log_checkpointer without and with limit_mutex Read by: buf_flush_page_coordinator_thread under limits_mutex Updated by: user threads (log_free_check() or for sharp checkpoint) Protected by: limits_mutex.
|
private |