![]() |
MySQL 8.0.43
Source Code Documentation
|
Redo log archiving system. More...
#include <arch0arch.h>
Public Member Functions | |
| Arch_Log_Sys () | |
| Constructor: Initialize members. More... | |
| ~Arch_Log_Sys () | |
| Destructor: Free mutex. More... | |
| bool | is_active () const |
| Check if archiving is in progress. More... | |
| bool | is_init () const |
| Check if archiver system is in initial state. More... | |
| lsn_t | get_archived_lsn () const |
| Get LSN up to which redo is archived. More... | |
| os_offset_t | get_recommended_file_size () const |
| Get recommended archived redo file size. More... | |
| Arch_Group * | get_arch_group () |
| Get current redo log archive group. More... | |
| int | start (Arch_Group *&group, lsn_t &start_lsn, byte *header, bool is_durable) |
| Start redo log archiving. More... | |
| int | stop (Arch_Group *group, lsn_t &stop_lsn, byte *log_blk, uint32_t &blk_len) |
| Stop redo log archiving. More... | |
| void | force_abort () |
| Force to abort the archiver (state becomes ARCH_STATE_IDLE or ARCH_STATE_ABORT). More... | |
| void | release (Arch_Group *group, bool is_durable) |
| Release the current group from client. More... | |
| bool | archive (bool init, Arch_File_Ctx *curr_ctx, lsn_t *arch_lsn, bool *wait) |
| Archive accumulated redo log in current group. More... | |
| void | arch_mutex_enter () |
| Acquire redo log archiver mutex. More... | |
| void | arch_mutex_exit () |
| Release redo log archiver mutex. More... | |
| Arch_Log_Sys (Arch_Log_Sys const &)=delete | |
| Disable copy construction. More... | |
| Arch_Log_Sys & | operator= (Arch_Log_Sys const &)=delete |
| Disable assignment. More... | |
| void | async_abort_if_below (lsn_t requested_lsn) |
| Abort the archiver if it is lagging behind and unable to advance. More... | |
Private Member Functions | |
| bool | wait_idle () |
| Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE. More... | |
| int | wait_archive_complete (lsn_t target_lsn) |
| Wait for redo log archive up to the target LSN. More... | |
| void | update_header (byte *header, lsn_t file_start_lsn, lsn_t checkpoint_lsn) |
| Update checkpoint LSN and related information in redo log header block. More... | |
| Arch_State | check_set_state (bool is_abort, lsn_t *archived_lsn, uint *to_archive) |
| Check and set log archive system state and output the amount of redo log available for archiving. More... | |
| dberr_t | copy_log (Arch_File_Ctx *file_ctx, lsn_t start_lsn, uint length) |
| Copy redo log from file context to archiver files. More... | |
| void | update_state_low (Arch_State state) |
| Update m_state to the given state. More... | |
| void | update_state (Arch_State state) |
| Acquires log_sys's m_files_mutex, writer_mutex and calls. More... | |
Private Attributes | |
| ib_mutex_t | m_mutex |
| Mutex to protect concurrent start, stop operations. More... | |
| Arch_State | m_state |
| Archiver system state. More... | |
| atomic_lsn_t | m_archived_lsn |
| System has archived log up to this LSN. More... | |
| Arch_Grp_List | m_group_list |
| List of log archive groups. More... | |
| Arch_Group * | m_current_group |
| Current archive group. More... | |
| uint | m_chunk_size |
| Chunk size to copy redo data. More... | |
| uint | m_start_log_index |
| System log file number where the archiving started. More... | |
| uint64_t | m_start_log_offset |
| System log file offset where the archiving started. More... | |
| Arch_log_consumer | m_log_consumer |
| Redo log consumer that can be registered to prevent consumption of redo log files which still haven't been archived. More... | |
| std::atomic< lsn_t > | m_abort_if_below_lsn {0} |
| Non-zero if async_abort_if_below(request_lsn) was called, which sets it to request_lsn. More... | |
Redo log archiving system.
|
inline |
Constructor: Initialize members.
|
inline |
Destructor: Free mutex.
|
delete |
Disable copy construction.
|
inline |
Acquire redo log archiver mutex.
It synchronizes concurrent start and stop operations by multiple clients.
|
inline |
Release redo log archiver mutex.
| bool Arch_Log_Sys::archive | ( | bool | init, |
| Arch_File_Ctx * | curr_ctx, | ||
| lsn_t * | arch_lsn, | ||
| bool * | wait | ||
| ) |
Archive accumulated redo log in current group.
This interface is for archiver background task to archive redo log data by calling it repeatedly over time.
| [in,out] | init | true when called the first time; it will then be set to false |
| [in] | curr_ctx | system redo logs to copy data from |
| [out] | arch_lsn | LSN up to which archiving is completed |
| [out] | wait | true, if no more redo to archive |
| void Arch_Log_Sys::async_abort_if_below | ( | lsn_t | requested_lsn | ) |
Abort the archiver if it is lagging behind and unable to advance.
|
private |
Check and set log archive system state and output the amount of redo log available for archiving.
| [in] | is_abort | need to abort |
| [in,out] | archived_lsn | LSN up to which redo log is archived |
| [out] | to_archive | amount of redo log to be archived |
|
private |
Copy redo log from file context to archiver files.
| [in] | file_ctx | file context for system redo logs |
| [in] | start_lsn | lsn at which we start copying |
| [in] | length | data to copy in bytes |
| void Arch_Log_Sys::force_abort | ( | ) |
Force to abort the archiver (state becomes ARCH_STATE_IDLE or ARCH_STATE_ABORT).
|
inline |
Get current redo log archive group.
|
inline |
Get LSN up to which redo is archived.
| os_offset_t Arch_Log_Sys::get_recommended_file_size | ( | ) | const |
Get recommended archived redo file size.
|
inline |
Check if archiving is in progress.
In ARCH_STATE_PREPARE_IDLE state, all clients have already detached but archiver background task is yet to finish.
|
inline |
Check if archiver system is in initial state.
|
delete |
Disable assignment.
| void Arch_Log_Sys::release | ( | Arch_Group * | group, |
| bool | is_durable | ||
| ) |
Release the current group from client.
| [in] | group | group the client is attached to |
| [in] | is_durable | if client needs durable archiving |
| int Arch_Log_Sys::start | ( | Arch_Group *& | group, |
| lsn_t & | start_lsn, | ||
| byte * | header, | ||
| bool | is_durable | ||
| ) |
Start redo log archiving.
If archiving is already in progress, the client is attached to current group.
| [out] | group | log archive group |
| [out] | start_lsn | start lsn for client |
| [out] | header | redo log header |
| [in] | is_durable | if client needs durable archiving |
| int Arch_Log_Sys::stop | ( | Arch_Group * | group, |
| lsn_t & | stop_lsn, | ||
| byte * | log_blk, | ||
| uint32_t & | blk_len | ||
| ) |
Stop redo log archiving.
If other clients are there, the client is detached from the current group.
| [out] | group | log archive group |
| [out] | stop_lsn | stop lsn for client |
| [out] | log_blk | redo log trailer block |
| [in,out] | blk_len | length in bytes |
|
private |
Update checkpoint LSN and related information in redo log header block.
| [in,out] | header | redo log header buffer |
| [in] | file_start_lsn | LSN of first data byte within file |
| [in] | checkpoint_lsn | LSN of the checkpoint within the file or 0 |
|
private |
Acquires log_sys's m_files_mutex, writer_mutex and calls.
| [in] | state | state to assign to m_state |
|
private |
Update m_state to the given state.
Then check if Arch_Log_Sys is active and accordingly register or unregister the
| [in] | state | state to assign to m_state |
|
private |
Wait for redo log archive up to the target LSN.
We need to wait till current log sys LSN during archive stop.
| [in] | target_lsn | target archive LSN to wait for |
|
private |
Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE.
If the system is preparing to idle, start needs to wait for it to come to idle state.
|
private |
Non-zero if async_abort_if_below(request_lsn) was called, which sets it to request_lsn.
Used to notify the thread calling Arch_Log_Sys::archive(..) that it should abort. Because this field is not cleared, and we don't want to prevent future CLONE operations, the operation should only be aborted if arch_lsn is below the value of this field
|
private |
System has archived log up to this LSN.
|
private |
Chunk size to copy redo data.
|
private |
Current archive group.
|
private |
List of log archive groups.
|
private |
Redo log consumer that can be registered to prevent consumption of redo log files which still haven't been archived.
|
private |
Mutex to protect concurrent start, stop operations.
|
private |
System log file number where the archiving started.
|
private |
System log file offset where the archiving started.
|
private |
Archiver system state.
m_state is protected by m_mutex and log_t::writer_mutex. For changing the state both needs to be acquired. For reading, hold any of the two mutexes. Same is true for m_archived_lsn.