MySQL 8.0.40
Source Code Documentation
arch0arch.h File Reference

Common interface for redo log and dirty page archiver system. More...

#include <mysql/components/services/page_track_service.h>
#include <list>
#include "buf0buf.h"
#include "ut0mem.h"
#include "ut0mutex.h"

Go to the source code of this file.

Classes

class  Arch_scope_guard
 Guard to release resources safely. More...
 
struct  Arch_Page_Pos
 Position in page ID archiving system. More...
 
struct  Arch_Point
 Structure which represents a point in a file. More...
 
struct  Arch_Reset_File
 
class  Arch_Block
 In memory data block in Page ID archiving system. More...
 
class  Arch_File_Ctx
 Archiver file context. More...
 
class  Arch_Group
 Contiguous archived data for redo log or page tracking. More...
 
class  Arch_log_consumer
 
class  Arch_Log_Sys
 Redo log archiving system. More...
 
struct  ArchPageData
 Page archiver in memory data. More...
 
class  Arch_Page_Sys
 Dirty page archive system. More...
 

Typedefs

using Arch_Reset = std::deque< Arch_Reset_File >
 
typedef uint32_t Arch_group_uuid
 Number which tries to uniquely identify the archived data (unless it is zero, which stands for unsupported identification). More...
 
using Arch_Grp_List = std::list< Arch_Group *, ut::allocator< Arch_Group * > >
 A list of archive groups. More...
 
using Arch_Grp_List_Iter = Arch_Grp_List::iterator
 An iterator for archive group. More...
 
using Arch_Block_Vec = std::vector< Arch_Block *, ut::allocator< Arch_Block * > >
 Vector of page archive in memory blocks. More...
 

Enumerations

enum  Arch_Client_State { ARCH_CLIENT_STATE_INIT = 0 , ARCH_CLIENT_STATE_STARTED , ARCH_CLIENT_STATE_STOPPED }
 Archiver client state. More...
 
enum  Arch_State {
  ARCH_STATE_INIT = 0 , ARCH_STATE_ACTIVE , ARCH_STATE_PREPARE_IDLE , ARCH_STATE_IDLE ,
  ARCH_STATE_READ_ONLY , ARCH_STATE_ABORT
}
 Archiver system state. More...
 
enum  Arch_Blk_State { ARCH_BLOCK_INIT = 0 , ARCH_BLOCK_ACTIVE , ARCH_BLOCK_READY_TO_FLUSH , ARCH_BLOCK_FLUSHED }
 Archived data block state. More...
 
enum  Arch_Blk_Type { ARCH_RESET_BLOCK = 0 , ARCH_DATA_BLOCK }
 Archiver block type. More...
 
enum  Arch_Blk_Flush_Type { ARCH_FLUSH_NORMAL = 0 , ARCH_FLUSH_PARTIAL }
 Archiver block flush type. More...
 
enum  Arch_Page_Dblwr_Offset { ARCH_PAGE_DBLWR_RESET_PAGE = 0 , ARCH_PAGE_DBLWR_FULL_FLUSH_PAGE , ARCH_PAGE_DBLWR_PARTIAL_FLUSH_PAGE }
 Page Archive doublewrite buffer block offsets. More...
 

Functions

void log_archiver_thread ()
 Log archiver background thread. More...
 
void arch_remove_file (const char *file_path, const char *file_name)
 Remove files related to page and log archiving. More...
 
void arch_remove_dir (const char *dir_path, const char *dir_name)
 Remove group directory and the files related to page and log archiving. More...
 
dberr_t arch_init ()
 Initialize Page and Log archiver system. More...
 
void arch_free ()
 Free Page and Log archiver system. More...
 
int start_log_archiver_background ()
 Start log archiver background thread. More...
 
int start_page_archiver_background ()
 Start page archiver background thread. More...
 
void page_archiver_thread ()
 Page archiver background thread. More...
 
bool arch_wake_threads ()
 Wakes up archiver threads. More...
 

Variables

constexpr char ARCH_PAGE_GROUP_DURABLE_FILE_NAME [] = "durable"
 File name for the durable file which indicates whether a group was made durable or not. More...
 
const uint MAX_LSN_DECIMAL_DIGIT = 32
 Byte length for printing LSN. More...
 
const uint MAX_ARCH_LOG_FILE_NAME_LEN
 Max string length for archive log file name. More...
 
const uint MAX_ARCH_PAGE_FILE_NAME_LEN
 Max string length for archive page file name. More...
 
const uint MAX_ARCH_DIR_NAME_LEN
 Max string length for archive group directory name. More...
 
os_event_t log_archiver_thread_event
 Archiver thread event to signal that data is available. More...
 
constexpr uint ARCH_PAGE_BLK_SIZE = UNIV_PAGE_SIZE_DEF
 Memory block size. More...
 
os_event_t page_archiver_thread_event
 Archiver thread event to signal that data is available. More...
 
Arch_Log_Sysarch_log_sys
 Redo log archiver system global. More...
 
Arch_Page_Sysarch_page_sys
 Dirty page ID archiver system global. More...
 
Archive file name prefix and constant length parameters.
const char ARCH_DIR [] = OS_FILE_PREFIX "ib_archive"
 Archive directory prefix. More...
 
const char ARCH_LOG_DIR [] = "log_group_"
 Archive Log group directory prefix. More...
 
const char ARCH_PAGE_DIR [] = "page_group_"
 Archive Page group directory prefix. More...
 
const char ARCH_LOG_FILE [] = "ib_log_"
 Archive log file prefix. More...
 
const char ARCH_PAGE_FILE [] = "ib_page_"
 Archive page file prefix. More...
 

Detailed Description

Common interface for redo log and dirty page archiver system.

Typedef Documentation

◆ Arch_Block_Vec

using Arch_Block_Vec = std::vector<Arch_Block *, ut::allocator<Arch_Block *> >

Vector of page archive in memory blocks.

◆ Arch_group_uuid

typedef uint32_t Arch_group_uuid

Number which tries to uniquely identify the archived data (unless it is zero, which stands for unsupported identification).

Currently only redo log files are identified (by Log_uuid's value).

◆ Arch_Grp_List

using Arch_Grp_List = std::list<Arch_Group *, ut::allocator<Arch_Group *> >

A list of archive groups.

◆ Arch_Grp_List_Iter

using Arch_Grp_List_Iter = Arch_Grp_List::iterator

An iterator for archive group.

◆ Arch_Reset

using Arch_Reset = std::deque<Arch_Reset_File>

Enumeration Type Documentation

◆ Arch_Blk_Flush_Type

Archiver block flush type.

Enumerator
ARCH_FLUSH_NORMAL 

Flush when block is full.

ARCH_FLUSH_PARTIAL 

Flush partial block.

Needed for persistent page tracking.

◆ Arch_Blk_State

Archived data block state.

A data block is a block in memory that holds dirty page IDs before persisting into disk. Shown below is the state transfer diagram for a data block.

Enumerator
ARCH_BLOCK_INIT 

Data block is initialized.

ARCH_BLOCK_ACTIVE 

Data block is active and having data.

ARCH_BLOCK_READY_TO_FLUSH 

Data block is full but not flushed to disk.

ARCH_BLOCK_FLUSHED 

Data block is flushed and can be reused.

◆ Arch_Blk_Type

Archiver block type.

Enumerator
ARCH_RESET_BLOCK 
ARCH_DATA_BLOCK 

◆ Arch_Client_State

Archiver client state.

Archiver clients request archiving for specific interval using the start and stop interfaces. During this time the client is attached to global Archiver system. A client copies archived data for the interval after calling stop. System keeps the data till the time client object is destroyed.

Enumerator
ARCH_CLIENT_STATE_INIT 

Client is initialized.

ARCH_CLIENT_STATE_STARTED 

Archiving started by client.

ARCH_CLIENT_STATE_STOPPED 

Archiving stopped by client.

◆ Arch_Page_Dblwr_Offset

Page Archive doublewrite buffer block offsets.

Enumerator
ARCH_PAGE_DBLWR_RESET_PAGE 

Archive doublewrite buffer page offset for RESET page.

ARCH_PAGE_DBLWR_FULL_FLUSH_PAGE 
ARCH_PAGE_DBLWR_PARTIAL_FLUSH_PAGE 

◆ Arch_State

enum Arch_State

Archiver system state.

Archiver state changes are triggered by client request to start or stop archiving and system wide events like shutdown fatal error etc. Following diagram shows the state transfer.

Enumerator
ARCH_STATE_INIT 

Archiver is initialized.

ARCH_STATE_ACTIVE 

Archiver is active and archiving data.

ARCH_STATE_PREPARE_IDLE 

Archiver is processing last data chunks before idle state.

ARCH_STATE_IDLE 

Archiver is idle.

ARCH_STATE_READ_ONLY 

Server is in read only mode, and hence the archiver.

ARCH_STATE_ABORT 

Archiver is aborted.

Function Documentation

◆ arch_free()

void arch_free ( )

Free Page and Log archiver system.

◆ arch_init()

dberr_t arch_init ( )

Initialize Page and Log archiver system.

Returns
error code

◆ arch_remove_dir()

void arch_remove_dir ( const char *  dir_path,
const char *  dir_name 
)

Remove group directory and the files related to page and log archiving.

Parameters
[in]dir_pathpath to the directory
[in]dir_namedirectory name

◆ arch_remove_file()

void arch_remove_file ( const char *  file_path,
const char *  file_name 
)

Remove files related to page and log archiving.

Parameters
[in]file_pathpath to the file
[in]file_namename of the file

◆ arch_wake_threads()

bool arch_wake_threads ( )

Wakes up archiver threads.

Returns
true iff any thread was still alive

◆ log_archiver_thread()

void log_archiver_thread ( )

Log archiver background thread.

Log archiver background thread.

◆ page_archiver_thread()

void page_archiver_thread ( )

Page archiver background thread.

Page archiver background thread.

◆ start_log_archiver_background()

int start_log_archiver_background ( )

Start log archiver background thread.

Returns
error code

◆ start_page_archiver_background()

int start_page_archiver_background ( )

Start page archiver background thread.

Returns
error code

Variable Documentation

◆ ARCH_DIR

const char ARCH_DIR[] = OS_FILE_PREFIX "ib_archive"

Archive directory prefix.

◆ ARCH_LOG_DIR

const char ARCH_LOG_DIR[] = "log_group_"

Archive Log group directory prefix.

◆ ARCH_LOG_FILE

const char ARCH_LOG_FILE[] = "ib_log_"

Archive log file prefix.

◆ arch_log_sys

Arch_Log_Sys* arch_log_sys
extern

Redo log archiver system global.

Redo log archiver system global.

◆ ARCH_PAGE_BLK_SIZE

constexpr uint ARCH_PAGE_BLK_SIZE = UNIV_PAGE_SIZE_DEF
constexpr

Memory block size.

◆ ARCH_PAGE_DIR

const char ARCH_PAGE_DIR[] = "page_group_"

Archive Page group directory prefix.

◆ ARCH_PAGE_FILE

const char ARCH_PAGE_FILE[] = "ib_page_"

Archive page file prefix.

◆ ARCH_PAGE_GROUP_DURABLE_FILE_NAME

constexpr char ARCH_PAGE_GROUP_DURABLE_FILE_NAME[] = "durable"
constexpr

File name for the durable file which indicates whether a group was made durable or not.

Required to differentiate durable group from group left over by crash during clone operation.

◆ arch_page_sys

Arch_Page_Sys* arch_page_sys
extern

Dirty page ID archiver system global.

Dirty page ID archiver system global.

◆ log_archiver_thread_event

os_event_t log_archiver_thread_event
extern

Archiver thread event to signal that data is available.

Archiver thread event to signal that data is available.

◆ MAX_ARCH_DIR_NAME_LEN

const uint MAX_ARCH_DIR_NAME_LEN
Initial value:
=
sizeof(ARCH_DIR) + 1 + sizeof(ARCH_PAGE_DIR) + MAX_LSN_DECIMAL_DIGIT + 1
const char ARCH_PAGE_DIR[]
Archive Page group directory prefix.
Definition: arch0arch.h:51
const uint MAX_LSN_DECIMAL_DIGIT
Byte length for printing LSN.
Definition: arch0arch.h:68
const char ARCH_DIR[]
Archive directory prefix.
Definition: arch0arch.h:45

Max string length for archive group directory name.

◆ MAX_ARCH_LOG_FILE_NAME_LEN

const uint MAX_ARCH_LOG_FILE_NAME_LEN
Initial value:
=
sizeof(ARCH_DIR) + 1 + sizeof(ARCH_LOG_DIR) + MAX_LSN_DECIMAL_DIGIT + 1 +
const char ARCH_LOG_DIR[]
Archive Log group directory prefix.
Definition: arch0arch.h:48
const char ARCH_LOG_FILE[]
Archive log file prefix.
Definition: arch0arch.h:54

Max string length for archive log file name.

◆ MAX_ARCH_PAGE_FILE_NAME_LEN

const uint MAX_ARCH_PAGE_FILE_NAME_LEN
Initial value:
=
sizeof(ARCH_DIR) + 1 + sizeof(ARCH_PAGE_DIR) + MAX_LSN_DECIMAL_DIGIT + 1 +
const char ARCH_PAGE_FILE[]
Archive page file prefix.
Definition: arch0arch.h:57

Max string length for archive page file name.

◆ MAX_LSN_DECIMAL_DIGIT

const uint MAX_LSN_DECIMAL_DIGIT = 32

Byte length for printing LSN.

Each archive group name is appended with start LSN

◆ page_archiver_thread_event

os_event_t page_archiver_thread_event
extern

Archiver thread event to signal that data is available.

Archiver thread event to signal that data is available.