MySQL 9.0.0
Source Code Documentation
|
Contiguous archived data for redo log or page tracking. More...
#include <arch0arch.h>
Classes | |
class | Recovery |
Recovery system data structure for the archiver. More... | |
Public Types | |
typedef std::function< dberr_t(uint64_t start_offset, byte *header)> | Get_file_header_callback |
Function responsible to format the header of a new file which is created, when the stream of data is written to a sequence of new files. More... | |
Public Member Functions | |
Arch_Group (lsn_t start_lsn, uint header_len, ib_mutex_t *mutex) | |
Constructor: Initialize members. More... | |
~Arch_Group () | |
Destructor: Delete all files for non-durable archiving. More... | |
dberr_t | init_file_ctx (const char *path, const char *base_dir, const char *base_file, uint num_files, uint64_t file_size, Arch_group_uuid uuid) |
Initialize the file context for the archive group. More... | |
void | close_file_ctxs () |
void | disable (lsn_t end_lsn) |
Mark archive group inactive. More... | |
void | attach (bool is_durable) |
Attach a client to the archive group. More... | |
uint | detach (lsn_t stop_lsn, Arch_Page_Pos *stop_pos) |
Detach a client when archiving is stopped by the client. More... | |
void | release (bool is_durable) |
Release the archive group from a client. More... | |
dberr_t | build_active_file_name () |
Construct file name for the active file which indicates whether a group is active or not. More... | |
dberr_t | build_durable_file_name () |
Construct file name for the durable file which indicates whether a group was made durable or not. More... | |
int | mark_active () |
Mark the group active by creating a file in the respective group directory. More... | |
int | mark_durable () |
Mark the group durable by creating a file in the respective group directory. More... | |
int | mark_inactive () |
Mark the group inactive by deleting the 'active' file. More... | |
bool | is_active () const |
Check if archiving is going on for this group. More... | |
dberr_t | write_file_header (byte *from_buffer, uint length) |
Write the header (RESET page) to an archived file. More... | |
dberr_t | write_to_file (Arch_File_Ctx *from_file, byte *from_buffer, uint length, bool partial_write, bool do_persist, Get_file_header_callback new_file) |
Archive data to one or more files. More... | |
bool | find_reset_point (lsn_t check_lsn, Arch_Point &reset_point) |
Find the appropriate reset LSN that is less than or equal to the given lsn and fetch the reset point. More... | |
bool | find_stop_point (lsn_t check_lsn, Arch_Point &stop_point, Arch_Page_Pos write_pos) |
Find the first stop LSN that is greater than the given LSN and fetch the stop point. More... | |
void | adjust_end_lsn (lsn_t &stop_lsn, uint32_t &blk_len) |
Adjust end LSN to end of file. More... | |
void | adjust_copy_length (lsn_t arch_lsn, uint32_t ©_len) |
Adjust redo copy length to end of file. More... | |
bool | validate_info_in_files () |
Check if the information maintained in the memory is the same as the information maintained in the files. More... | |
uint | get_file_count () const |
Get the total number of archived files belonging to this group. More... | |
bool | is_referenced () const |
Check if any client (durable or not) is attached to the archiver. More... | |
bool | is_durable_client_active () const |
Check if any client requiring durable archiving is active. More... | |
bool | is_durable () const |
Check if any client requires durable archiving. More... | |
uint | purge (lsn_t purge_lsn, lsn_t &purged_lsn) |
Purge archived files until the specified purge LSN. More... | |
void | save_reset_point_in_mem (lsn_t lsn, Arch_Page_Pos pos) |
Update the reset information in the in-memory structure that we maintain for faster access. More... | |
void | update_stop_point (Arch_Page_Pos pos, lsn_t stop_lsn) |
Update stop lsn of a file in the group. More... | |
dberr_t | recover (Arch_Recv_Group_Info &group_info, Arch_Dblwr_Ctx *dblwr_ctx) |
Recover the information belonging to this group from the archived files. More... | |
int | read_data (Arch_Page_Pos cur_pos, byte *buff, uint buff_len) |
Parse block for block info (header/data). More... | |
void | get_file_name (uint idx, char *name_buf, uint buf_len) |
Get archived file name at specific index in this group. More... | |
uint64_t | get_file_size () const |
Get the current file size for this group. More... | |
lsn_t | get_begin_lsn () const |
Get start LSN for this group. More... | |
lsn_t | get_end_lsn () const |
Arch_Page_Pos | get_stop_pos () const |
Arch_group_uuid | get_uuid () const |
void | get_status (std::vector< std::pair< lsn_t, bool > > &status) |
Fetch the status of the page tracking system. More... | |
dberr_t | open_file (Arch_Page_Pos write_pos, bool create_new) |
Open the file which was open at the time of a crash, during crash recovery, and set the file offset to the last written offset. More... | |
Arch_Group (Arch_Group const &)=delete | |
Disable copy construction. More... | |
Arch_Group & | operator= (Arch_Group const &)=delete |
Disable assignment. More... | |
Static Public Member Functions | |
static dberr_t | init_dblwr_file_ctx (const char *path, const char *base_file, uint num_files, uint64_t file_size) |
Initialize the doublewrite buffer file context for the archive group. More... | |
static dberr_t | write_to_doublewrite_file (Arch_File_Ctx *from_file, byte *from_buffer, uint write_size, Arch_Page_Dblwr_Offset offset) |
Write to the doublewrite buffer before writing archived data to a file. More... | |
static void | shutdown () |
Operations to be done at the time of shutdown. More... | |
Private Member Functions | |
int | read_from_file (Arch_Page_Pos *read_pos, uint read_len, byte *read_buff) |
Get page IDs from archived file. More... | |
void | get_dir_name (char *name_buf, uint buf_len) |
Get the directory name for this archive group. More... | |
dberr_t | prepare_file_with_header (uint64_t start_offset, Get_file_header_callback &get_header) |
Create a new file and write the header. More... | |
Private Attributes | |
bool | m_is_active {true} |
If the group is active. More... | |
char * | m_active_file_name {nullptr} |
To know which group was active at the time of a crash/shutdown during recovery we create an empty file in the group directory. More... | |
pfs_os_file_t | m_active_file |
File descriptor for a file required to indicate that the group was active at the time of crash during recovery . More... | |
char * | m_durable_file_name {nullptr} |
File name for the durable file which indicates whether a group was made durable or not. More... | |
pfs_os_file_t | m_durable_file |
File descriptor for a file to indicate that the group was made durable or not. More... | |
uint | m_ref_count {} |
Number of clients referencing the group. More... | |
uint | m_dur_ref_count {} |
Number of clients referencing for durable archiving. More... | |
uint | m_num_active {} |
Number of clients for which archiving is in progress. More... | |
lsn_t | m_begin_lsn {LSN_MAX} |
Start LSN for the archive group. More... | |
lsn_t | m_end_lsn {LSN_MAX} |
End lsn for this archive group. More... | |
Arch_Page_Pos | m_stop_pos {} |
Stop position of the group, if it's not active. More... | |
uint | m_header_len {} |
Header length for the archived files. More... | |
uint64_t | m_file_size |
Size of file used when a new file is being created. More... | |
Arch_group_uuid | m_uuid {} |
UUID generated for this arch group. More... | |
Arch_File_Ctx | m_file_ctx |
Archive file context. More... | |
ib_mutex_t * | m_arch_mutex |
Mutex protecting concurrent operations by multiple clients. More... | |
Static Private Attributes | |
static Arch_File_Ctx | s_dblwr_file_ctx |
Doublewrite buffer file context. More... | |
Contiguous archived data for redo log or page tracking.
If there is a gap, that is if archiving is stopped and started, a new group is created.
typedef std::function<dberr_t(uint64_t start_offset, byte *header)> Arch_Group::Get_file_header_callback |
Function responsible to format the header of a new file which is created, when the stream of data is written to a sequence of new files.
[in] | start_offset | offset at which a new file starts, expressed in bytes from the beginning of the stream |
[in] | header | header to format |
|
inline |
Constructor: Initialize members.
[in] | start_lsn | start LSN for the group |
[in] | header_len | length of header for archived files |
[in] | mutex | archive system mutex from caller |
Arch_Group::~Arch_Group | ( | ) |
Destructor: Delete all files for non-durable archiving.
|
delete |
Disable copy construction.
void Arch_Group::adjust_copy_length | ( | lsn_t | arch_lsn, |
uint32_t & | copy_len | ||
) |
Adjust redo copy length to end of file.
This is used in debug mode to archive only till end of file.
[in] | arch_lsn | LSN up to which data is already archived |
[in,out] | copy_len | length of data to copy in bytes |
void Arch_Group::adjust_end_lsn | ( | lsn_t & | stop_lsn, |
uint32_t & | blk_len | ||
) |
Adjust end LSN to end of file.
This is used in debug mode to test the case when LSN is at file boundary.
[in,out] | stop_lsn | stop lsn for client |
[out] | blk_len | last block length |
|
inline |
Attach a client to the archive group.
[in] | is_durable | true, if durable tracking is requested |
dberr_t Arch_Group::build_active_file_name | ( | ) |
Construct file name for the active file which indicates whether a group is active or not.
dberr_t Arch_Group::build_durable_file_name | ( | ) |
Construct file name for the durable file which indicates whether a group was made durable or not.
|
inline |
|
inline |
Detach a client when archiving is stopped by the client.
The client still has reference to the group so that the group is not destroyed when it retrieves the archived data. The reference is removed later by Arch_Group::release.
[in] | stop_lsn | archive stop lsn for client |
[in] | stop_pos | archive stop position for client. Used only by the page_archiver. |
|
inline |
Mark archive group inactive.
A group is marked inactive by archiver background before entering into idle state ARCH_STATE_IDLE.
[in] | end_lsn | lsn where redo archiving is stopped |
|
inline |
Find the appropriate reset LSN that is less than or equal to the given lsn and fetch the reset point.
[in] | check_lsn | LSN to be searched against |
[out] | reset_point | reset position of the fetched reset point |
|
inline |
Find the first stop LSN that is greater than the given LSN and fetch the stop point.
[in] | check_lsn | LSN to be searched against |
[out] | stop_point | stop point |
[in] | write_pos | latest write_pos |
|
inline |
Get start LSN for this group.
|
inlineprivate |
Get the directory name for this archive group.
It is used for cleaning up the archive directory.
[out] | name_buf | directory name and path. Caller must allocate the buffer. |
[in] | buf_len | buffer length |
|
inline |
|
inline |
Get the total number of archived files belonging to this group.
|
inline |
Get archived file name at specific index in this group.
Caller would use it to open and copy data from archived files.
[in] | idx | file index in the group |
[out] | name_buf | file name and path. Caller must allocate the buffer. |
[in] | buf_len | allocated buffer length |
|
inline |
Get the current file size for this group.
Fixed size files are used for archiving data in a group.
|
inline |
Fetch the status of the page tracking system.
[out] | status | vector of a pair of (ID, bool) where ID is the start/stop point and bool is true if the ID is a start point else false |
|
inline |
|
inline |
|
static |
Initialize the doublewrite buffer file context for the archive group.
[in] | path | path to the file |
[in] | base_file | file name prefix |
[in] | num_files | initial number of files |
[in] | file_size | file size in bytes |
|
inline |
Initialize the file context for the archive group.
File context keeps the archived data in files on disk. There is one file context for a archive group.
[in] | path | path to the file |
[in] | base_dir | directory name prefix |
[in] | base_file | file name prefix |
[in] | num_files | initial number of files |
[in] | file_size | size of file used when a new file is created |
[in] | uuid | uuid of this arch group or 0 if unknown |
|
inline |
Check if archiving is going on for this group.
|
inline |
Check if any client requires durable archiving.
|
inline |
Check if any client requiring durable archiving is active.
|
inline |
Check if any client (durable or not) is attached to the archiver.
int Arch_Group::mark_active | ( | ) |
Mark the group active by creating a file in the respective group directory.
This is required at the time of recovery to know whether a group was active or not in case of a crash.
int Arch_Group::mark_durable | ( | ) |
Mark the group durable by creating a file in the respective group directory.
This is required at the time of recovery to differentiate durable group from group left over by crash during clone operation.
int Arch_Group::mark_inactive | ( | ) |
Mark the group inactive by deleting the 'active' file.
This is required at the time of crash recovery to know whether a group was active or not in case of a crash.
dberr_t Arch_Group::open_file | ( | Arch_Page_Pos | write_pos, |
bool | create_new | ||
) |
Open the file which was open at the time of a crash, during crash recovery, and set the file offset to the last written offset.
[in] | write_pos | latest write position at the time of crash/shutdown |
[in] | create_new | create new file if file not present |
|
delete |
Disable assignment.
|
private |
Create a new file and write the header.
[in] | start_offset | start offste |
[in] | get_header | callback which prepares a header |
Purge archived files until the specified purge LSN.
[in] | purge_lsn | LSN until which archived files needs to be purged |
[out] | purged_lsn | LSN until which purging is successful; LSN_MAX if there was no purging done |
For a group (active or non-active) if there are any non-durable clients attached then we don't purge the group at all.
int Arch_Group::read_data | ( | Arch_Page_Pos | cur_pos, |
byte * | buff, | ||
uint | buff_len | ||
) |
Parse block for block info (header/data).
[in] | cur_pos | position to read |
[in,out] | buff | buffer into which to write the parsed data |
[in] | buff_len | length of the buffer |
|
private |
Get page IDs from archived file.
[in] | read_pos | position to read from |
[in] | read_len | length of data to read |
[in] | read_buff | buffer to read page IDs |
dberr_t Arch_Group::recover | ( | Arch_Recv_Group_Info & | group_info, |
Arch_Dblwr_Ctx * | dblwr_ctx | ||
) |
Recover the information belonging to this group from the archived files.
[in,out] | group_info | structure containing information of a group obtained during recovery by scanning files |
[in] | dblwr_ctx | file context related to doublewrite buffer |
|
inline |
Release the archive group from a client.
Reduce the reference count. When all clients release the group, the reference count falls down to zero. The function would then return zero and the caller can remove the group.
[in] | is_durable | the client needs durable archiving |
|
inline |
Update the reset information in the in-memory structure that we maintain for faster access.
[in] | lsn | lsn at the time of reset |
[in] | pos | pos at the time of reset |
|
inlinestatic |
Operations to be done at the time of shutdown.
|
inline |
Update stop lsn of a file in the group.
[in] | pos | stop position |
[in] | stop_lsn | stop point |
bool Arch_Group::validate_info_in_files | ( | ) |
Check if the information maintained in the memory is the same as the information maintained in the files.
Write the header (RESET page) to an archived file.
[in] | from_buffer | buffer to copy data |
[in] | length | size of data to copy in bytes |
|
static |
Write to the doublewrite buffer before writing archived data to a file.
The source is either a file context or buffer. Caller must ensure that data is in single file in source file context.
[in] | from_file | file context to copy data from |
[in] | from_buffer | buffer to copy data or NULL |
[in] | write_size | size of data to write in bytes |
[in] | offset | offset from where to write |
dberr_t Arch_Group::write_to_file | ( | Arch_File_Ctx * | from_file, |
byte * | from_buffer, | ||
uint | length, | ||
bool | partial_write, | ||
bool | do_persist, | ||
Get_file_header_callback | new_file | ||
) |
Archive data to one or more files.
The source is either a file context or buffer. Caller must ensure that data is in single file in source file context.
[in] | from_file | file context to copy data from |
[in] | from_buffer | buffer to copy data or NULL |
[in] | length | size of data to copy in bytes |
[in] | partial_write | true if the operation is part of partial flush |
[in] | do_persist | doublewrite to ensure persistence |
[in] | new_file | callback called for each new file being created |
|
private |
File descriptor for a file required to indicate that the group was active at the time of crash during recovery .
|
private |
To know which group was active at the time of a crash/shutdown during recovery we create an empty file in the group directory.
This holds the name of the file.
|
private |
Mutex protecting concurrent operations by multiple clients.
This is either the redo log or page archive system mutex. Currently used for assert checks.
|
private |
Number of clients referencing for durable archiving.
|
private |
File descriptor for a file to indicate that the group was made durable or not.
Required to differentiate durable group from group left over by crash during clone operation.
|
private |
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.
|
private |
Archive file context.
|
private |
Size of file used when a new file is being created.
|
private |
Header length for the archived files.
|
private |
If the group is active.
|
private |
Number of clients for which archiving is in progress.
|
private |
Number of clients referencing the group.
|
private |
Stop position of the group, if it's not active.
|
private |
UUID generated for this arch group.
|
staticprivate |
Doublewrite buffer file context.
Note - Used only in the case of page archiver.