MySQL 8.0.40
Source Code Documentation
Arch_Log_Sys Class Reference

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_Groupget_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_Sysoperator= (Arch_Log_Sys const &)=delete
 Disable assignment. 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_Groupm_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...
 

Detailed Description

Redo log archiving system.

Constructor & Destructor Documentation

◆ Arch_Log_Sys() [1/2]

Arch_Log_Sys::Arch_Log_Sys ( )
inline

Constructor: Initialize members.

◆ ~Arch_Log_Sys()

Arch_Log_Sys::~Arch_Log_Sys ( )
inline

Destructor: Free mutex.

◆ Arch_Log_Sys() [2/2]

Arch_Log_Sys::Arch_Log_Sys ( Arch_Log_Sys const &  )
delete

Disable copy construction.

Member Function Documentation

◆ arch_mutex_enter()

void Arch_Log_Sys::arch_mutex_enter ( )
inline

Acquire redo log archiver mutex.

It synchronizes concurrent start and stop operations by multiple clients.

◆ arch_mutex_exit()

void Arch_Log_Sys::arch_mutex_exit ( )
inline

Release redo log archiver mutex.

◆ archive()

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.

Parameters
[in,out]inittrue when called the first time; it will then be set to false
[in]curr_ctxsystem redo logs to copy data from
[out]arch_lsnLSN up to which archiving is completed
[out]waittrue, if no more redo to archive
Returns
true, if archiving is aborted

◆ check_set_state()

Arch_State Arch_Log_Sys::check_set_state ( bool  is_abort,
lsn_t archived_lsn,
uint to_archive 
)
private

Check and set log archive system state and output the amount of redo log available for archiving.

Parameters
[in]is_abortneed to abort
[in,out]archived_lsnLSN up to which redo log is archived
[out]to_archiveamount of redo log to be archived

◆ copy_log()

dberr_t Arch_Log_Sys::copy_log ( Arch_File_Ctx file_ctx,
lsn_t  start_lsn,
uint  length 
)
private

Copy redo log from file context to archiver files.

Parameters
[in]file_ctxfile context for system redo logs
[in]start_lsnlsn at which we start copying
[in]lengthdata to copy in bytes
Returns
error code

◆ force_abort()

void Arch_Log_Sys::force_abort ( )

Force to abort the archiver (state becomes ARCH_STATE_IDLE or ARCH_STATE_ABORT).

◆ get_arch_group()

Arch_Group * Arch_Log_Sys::get_arch_group ( )
inline

Get current redo log archive group.

Returns
current archive group

◆ get_archived_lsn()

lsn_t Arch_Log_Sys::get_archived_lsn ( ) const
inline

Get LSN up to which redo is archived.

Returns
last archived redo LSN

◆ get_recommended_file_size()

os_offset_t Arch_Log_Sys::get_recommended_file_size ( ) const

Get recommended archived redo file size.

Returns
size of file in bytes

◆ is_active()

bool Arch_Log_Sys::is_active ( ) const
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.

Returns
true, if archiving is active

◆ is_init()

bool Arch_Log_Sys::is_init ( ) const
inline

Check if archiver system is in initial state.

Returns
true, if redo log archiver state is ARCH_STATE_INIT

◆ operator=()

Arch_Log_Sys & Arch_Log_Sys::operator= ( Arch_Log_Sys const &  )
delete

Disable assignment.

◆ release()

void Arch_Log_Sys::release ( Arch_Group group,
bool  is_durable 
)

Release the current group from client.

Parameters
[in]groupgroup the client is attached to
[in]is_durableif client needs durable archiving

◆ start()

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.

Parameters
[out]grouplog archive group
[out]start_lsnstart lsn for client
[out]headerredo log header
[in]is_durableif client needs durable archiving
Returns
error code

◆ stop()

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.

Parameters
[out]grouplog archive group
[out]stop_lsnstop lsn for client
[out]log_blkredo log trailer block
[in,out]blk_lenlength in bytes
Returns
error code

◆ update_header()

void Arch_Log_Sys::update_header ( byte header,
lsn_t  file_start_lsn,
lsn_t  checkpoint_lsn 
)
private

Update checkpoint LSN and related information in redo log header block.

Parameters
[in,out]headerredo log header buffer
[in]file_start_lsnLSN of first data byte within file
[in]checkpoint_lsnLSN of the checkpoint within the file or 0

◆ update_state()

void Arch_Log_Sys::update_state ( Arch_State  state)
private

Acquires log_sys's m_files_mutex, writer_mutex and calls.

See also
update_state_low(state).
Parameters
[in]statestate to assign to m_state

◆ update_state_low()

void Arch_Log_Sys::update_state_low ( Arch_State  state)
private

Update m_state to the given state.

Then check if Arch_Log_Sys is active and accordingly register or unregister the

See also
m_log_consumer. It is caller that should acquire log_sys's: m_files_mutex and writer_mutex prior before calling this method.
Parameters
[in]statestate to assign to m_state

◆ wait_archive_complete()

int Arch_Log_Sys::wait_archive_complete ( lsn_t  target_lsn)
private

Wait for redo log archive up to the target LSN.

We need to wait till current log sys LSN during archive stop.

Parameters
[in]target_lsntarget archive LSN to wait for
Returns
error code

◆ wait_idle()

bool Arch_Log_Sys::wait_idle ( )
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.

Returns
true, if successful false, if needs to abort

Member Data Documentation

◆ m_archived_lsn

atomic_lsn_t Arch_Log_Sys::m_archived_lsn
private

System has archived log up to this LSN.

◆ m_chunk_size

uint Arch_Log_Sys::m_chunk_size
private

Chunk size to copy redo data.

◆ m_current_group

Arch_Group* Arch_Log_Sys::m_current_group
private

Current archive group.

◆ m_group_list

Arch_Grp_List Arch_Log_Sys::m_group_list
private

List of log archive groups.

◆ m_log_consumer

Arch_log_consumer Arch_Log_Sys::m_log_consumer
private

Redo log consumer that can be registered to prevent consumption of redo log files which still haven't been archived.

◆ m_mutex

ib_mutex_t Arch_Log_Sys::m_mutex
private

Mutex to protect concurrent start, stop operations.

◆ m_start_log_index

uint Arch_Log_Sys::m_start_log_index
private

System log file number where the archiving started.

◆ m_start_log_offset

uint64_t Arch_Log_Sys::m_start_log_offset
private

System log file offset where the archiving started.

◆ m_state

Arch_State Arch_Log_Sys::m_state
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.


The documentation for this class was generated from the following files: