MySQL 8.0.40
Source Code Documentation
|
Archiver file context. More...
#include <arch0arch.h>
Classes | |
class | Recovery |
Recovery system data structure for the archiver. More... | |
Public Member Functions | |
Arch_File_Ctx () | |
Constructor: Initialize members. More... | |
~Arch_File_Ctx () | |
Destructor: Close open file and free resources. More... | |
dberr_t | init (const char *path, const char *base_dir, const char *base_file, uint num_files) |
Initializes archiver file context. More... | |
dberr_t | open (bool read_only, lsn_t start_lsn, uint file_index, uint64_t file_offset, uint64_t file_size) |
Open a file at specific index. More... | |
dberr_t | open_new (lsn_t start_lsn, uint64_t new_file_size, uint64_t initial_file_size) |
Add a new file and open. More... | |
dberr_t | open_next (lsn_t start_lsn, uint64_t file_offset, uint64_t file_size) |
Open next file for read. More... | |
dberr_t | read (byte *to_buffer, const uint64_t offset, uint size) |
Read data from the current file that is open. More... | |
dberr_t | resize_and_overwrite_with_zeros (uint64_t file_size) |
Resize file to provided size and overwrite the whole file with 0x00. More... | |
dberr_t | write (Arch_File_Ctx *from_file, byte *from_buffer, uint offset, uint size) |
Write data to this file context from the given file offset. More... | |
dberr_t | write (Arch_File_Ctx *from_file, byte *from_buffer, uint size) |
Write data to this file context from the current offset. More... | |
void | flush () |
Flush file. More... | |
void | close () |
Close file, if open. More... | |
bool | is_closed () const |
Check if file is closed. More... | |
uint64_t | bytes_left () const |
Check how much is left in current file. More... | |
void | build_name (uint idx, lsn_t dir_lsn, char *buffer, uint length) |
Construct file name at specific index. More... | |
void | build_dir_name (lsn_t dir_lsn, char *buffer, uint length) |
Construct group directory name. More... | |
uint64_t | get_size () const |
Get the logical size of a file. More... | |
uint64_t | get_offset () const |
uint | get_index () const |
Get current file index. More... | |
uint | get_count () const |
Get number of files. More... | |
uint64_t | get_phy_size () const |
Get the physical size of a file that is open in this context. More... | |
void | update_stop_point (uint file_index, lsn_t stop_lsn) |
Update stop lsn of a file in the group. More... | |
bool | validate (Arch_Group *group, uint file_index, lsn_t start_lsn, uint &reset_count) |
Check if the information maintained in the memory is the same as the information maintained in the files. 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... | |
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 (Arch_Group *group, lsn_t check_lsn, Arch_Point &stop_point, Arch_Page_Pos last_pos) |
Find the first stop LSN that is greater than the given LSN and fetch the stop point. More... | |
bool | delete_file (uint file_index, lsn_t begin_lsn) |
Delete a single file belonging to the specified file index. More... | |
void | delete_files (lsn_t begin_lsn) |
Delete all files for this archive group. More... | |
lsn_t | purge (lsn_t begin_lsn, lsn_t end_lsn, lsn_t purge_lsn) |
Purge archived files until the specified purge LSN. More... | |
void | get_status (std::vector< std::pair< lsn_t, bool > > &status) |
Fetch the status of the page tracking system. More... | |
Private Member Functions | |
bool | validate_reset_block_in_file (pfs_os_file_t file, uint file_index, uint &reset_count) |
Check if the reset information maintained in the memory is the same as the information maintained in the given file. More... | |
bool | validate_stop_point_in_file (Arch_Group *group, pfs_os_file_t file, uint file_index) |
Check if the stop LSN maintained in the memory is the same as the information maintained in the files. More... | |
lsn_t | fetch_reset_lsn (uint64_t block_num) |
Fetch reset lsn of a particular reset point pertaining to a file. More... | |
Private Attributes | |
char * | m_name_buf {nullptr} |
File name buffer. More... | |
uint | m_name_len {} |
File name buffer length. More... | |
uint | m_base_len {} |
Fixed length part of the file. More... | |
const char * | m_path_name {nullptr} |
Fixed part of the path to file. More... | |
const char * | m_dir_name {nullptr} |
Directory name prefix. More... | |
const char * | m_file_name {nullptr} |
File name prefix. More... | |
pfs_os_file_t | m_file |
Current file descriptor. More... | |
uint | m_index {} |
File index within the archive group. More... | |
uint | m_count {} |
Current number of files in the archive group. More... | |
uint64_t | m_offset {} |
Current file offset. More... | |
uint64_t | m_size {} |
File size limit in bytes. More... | |
Arch_Reset | m_reset |
Queue of file structure holding reset information pertaining to their respective files in a group. More... | |
std::vector< lsn_t > | m_stop_points |
Vector of stop points corresponding to a file. More... | |
Archiver file context.
Represents a set of fixed size files within a group
|
inline |
Constructor: Initialize members.
|
inline |
Destructor: Close open file and free resources.
Construct group directory name.
[in] | dir_lsn | lsn of the group |
[out] | buffer | directory name. The buffer is allocated by caller. |
[in] | length | buffer length |
Construct file name at specific index.
[in] | idx | file index |
[in] | dir_lsn | lsn of the group |
[out] | buffer | file name including path. The buffer is allocated by caller. |
[in] | length | buffer length |
|
inline |
Check how much is left in current file.
|
inline |
Close file, if open.
Delete a single file belonging to the specified file index.
[in] | file_index | file index of the file which needs to be deleted |
[in] | begin_lsn | group's start lsn |
void Arch_File_Ctx::delete_files | ( | lsn_t | begin_lsn | ) |
Delete all files for this archive group.
[in] | begin_lsn | group's start lsn |
|
private |
Fetch reset lsn of a particular reset point pertaining to a file.
[in] | block_num | block number where the reset occurred. |
bool Arch_File_Ctx::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.
[in] | check_lsn | LSN to be searched against |
[out] | reset_point | reset position of the fetched reset point |
bool Arch_File_Ctx::find_stop_point | ( | Arch_Group * | group, |
lsn_t | check_lsn, | ||
Arch_Point & | stop_point, | ||
Arch_Page_Pos | last_pos | ||
) |
Find the first stop LSN that is greater than the given LSN and fetch the stop point.
[in] | group | the group whose stop_point we're interested in |
[in] | check_lsn | LSN to be searched against |
[out] | stop_point | stop point |
[in] | last_pos | position of the last block in the group; m_write_pos if group is active and m_stop_pos if not |
|
inline |
Flush file.
|
inline |
Get number of files.
|
inline |
Get current file index.
|
inline |
|
inline |
Get the physical size of a file that is open in this context.
|
inline |
Get the logical size of a file.
|
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 |
dberr_t Arch_File_Ctx::init | ( | const char * | path, |
const char * | base_dir, | ||
const char * | base_file, | ||
uint | num_files | ||
) |
Initializes archiver file context.
[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 |
|
inline |
Check if file is closed.
dberr_t Arch_File_Ctx::open | ( | bool | read_only, |
lsn_t | start_lsn, | ||
uint | file_index, | ||
uint64_t | file_offset, | ||
uint64_t | file_size | ||
) |
Open a file at specific index.
[in] | read_only | open in read only mode |
[in] | start_lsn | start lsn for the group |
[in] | file_index | index of the file within the group which needs to be opened |
[in] | file_offset | start offset |
[in] | file_size | maximum allowed file size or 0 to use its current real size on disk as the limitation (file is full) |
dberr_t Arch_File_Ctx::open_new | ( | lsn_t | start_lsn, |
uint64_t | new_file_size, | ||
uint64_t | initial_file_size | ||
) |
Add a new file and open.
[in] | start_lsn | start lsn for the group |
[in] | new_file_size | size limit for the new file |
[in] | initial_file_size | initial size of file to create |
Open next file for read.
[in] | start_lsn | start lsn for the group |
[in] | file_offset | start offset |
[in] | file_size | maximum allowed file size or 0 to use its current real size on disk as the limitation (file is full) |
Purge archived files until the specified purge LSN.
[in] | begin_lsn | start LSN of the group |
[in] | end_lsn | end LSN of the group |
[in] | purge_lsn | purge LSN until which files needs to be purged |
LSN_MAX | if there was no purging done. |
Removes the deleted file from reset info, thereby incrementing the iterator.
Only files which have a reset would be purged in the above loop. We want to purge all the files preceding reset_file_it regardless of whether it has a reset or not.
Read data from the current file that is open.
Caller must ensure that the size is within the limits of current file context.
[in,out] | to_buffer | read data into this buffer |
[in] | offset | file offset from where to read |
[in] | size | size of data to read in bytes |
dberr_t Arch_File_Ctx::resize_and_overwrite_with_zeros | ( | uint64_t | file_size | ) |
Resize file to provided size and overwrite the whole file with 0x00.
[in] | file_size | new file size |
void Arch_File_Ctx::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.
[in] | lsn | lsn at the time of reset |
[in] | pos | pos at the time of reset |
Update stop lsn of a file in the group.
[in] | file_index | file_index the current write_pos belongs to |
[in] | stop_lsn | stop point |
bool Arch_File_Ctx::validate | ( | Arch_Group * | group, |
uint | file_index, | ||
lsn_t | start_lsn, | ||
uint & | reset_count | ||
) |
Check if the information maintained in the memory is the same as the information maintained in the files.
[in] | group | group whose file is being validated |
[in] | file_index | index of the file which is being validated |
[in] | start_lsn | |
[in,out] | reset_count | count of files which has been validated |
|
private |
Check if the reset information maintained in the memory is the same as the information maintained in the given file.
[in] | file | file descriptor |
[in] | file_index | index of the file |
[in,out] | reset_count | number of files processed containing reset data |
|
private |
Check if the stop LSN maintained in the memory is the same as the information maintained in the files.
[in] | group | group whose file is being validated |
[in] | file | file descriptor |
[in] | file_index | index of the file for which the validation is happening |
dberr_t Arch_File_Ctx::write | ( | Arch_File_Ctx * | from_file, |
byte * | from_buffer, | ||
uint | offset, | ||
uint | size | ||
) |
Write data to this file context from the given file offset.
Data source is another file context or buffer. If buffer is NULL, data is copied from input file context. Caller must ensure that the size is within the limits of current file for both source and destination file context.
[in] | from_file | file context to copy data from |
[in] | from_buffer | buffer to copy data or NULL |
[in] | offset | file offset from where to write |
[in] | size | size of data to copy in bytes |
dberr_t Arch_File_Ctx::write | ( | Arch_File_Ctx * | from_file, |
byte * | from_buffer, | ||
uint | size | ||
) |
Write data to this file context from the current offset.
Data source is another file context or buffer. If buffer is NULL, data is copied from input file context. Caller must ensure that the size is within the limits of current file for both source and destination file context.
[in] | from_file | file context to copy data from |
[in] | from_buffer | buffer to copy data or NULL |
[in] | size | size of data to copy in bytes |
|
private |
Fixed length part of the file.
Path ended with directory separator.
|
private |
Current number of files in the archive group.
|
private |
Directory name prefix.
|
private |
Current file descriptor.
|
private |
File name prefix.
|
private |
File index within the archive group.
|
private |
File name buffer.
Used if caller doesn't allocate buffer.
|
private |
File name buffer length.
|
private |
Current file offset.
|
private |
Fixed part of the path to file.
|
private |
Queue of file structure holding reset information pertaining to their respective files in a group.
Protected by Arch_Page_Sys::m_mutex and Arch_Page_Sys::m_oper_mutex.
|
private |
File size limit in bytes.
|
private |
Vector of stop points corresponding to a file.
Stop point refers to the stop lsn (checkpoint lsn) until which the pages are guaranteed to be tracked in a file. Each block in a file maintains this information. Protected by Arch_Page_Sys::m_oper_mutex.