32#ifndef ARCH_ARCH_INCLUDE
33#define ARCH_ARCH_INCLUDE
411 bool set_data(uint read_len,
byte *read_buff, uint read_offset);
452 static bool is_zeroes(
const byte *block);
557 dberr_t init(
const char *
path,
const char *base_dir,
const char *base_file,
570 uint64_t file_offset, uint64_t
file_size);
578 uint64_t initial_file_size);
595 dberr_t read(
byte *to_buffer,
const uint64_t offset, uint size);
753 for (
auto reset_file :
m_reset) {
754 for (
auto reset_point : reset_file.m_start_point) {
755 status.push_back(std::make_pair(reset_point.lsn,
true));
892 const char *base_file, uint num_files,
952 if (stop_pos !=
nullptr) {
1039 byte *from_buffer, uint write_size,
1053 uint
length,
bool partial_write,
bool do_persist,
1165 ut_ad(name_buf !=
nullptr);
1311 const std::string &
get_name()
const override;
1360 return archived_lsn;
1576 bool is_durable,
bool restart,
bool recovery);
1685 uint64_t &num_pages);
1813 bool partial_reset_block_flush);
void arch_free()
Free Page and Log archiver system.
Definition: arch0arch.cc:151
int start_page_archiver_background()
Start page archiver background thread.
Definition: arch0arch.cc:592
const uint MAX_ARCH_PAGE_FILE_NAME_LEN
Max string length for archive page file name.
Definition: arch0arch.h:75
Arch_Page_Dblwr_Offset
Page Archive doublewrite buffer block offsets.
Definition: arch0arch.h:231
@ ARCH_PAGE_DBLWR_PARTIAL_FLUSH_PAGE
Definition: arch0arch.h:239
@ ARCH_PAGE_DBLWR_RESET_PAGE
Archive doublewrite buffer page offset for RESET page.
Definition: arch0arch.h:233
@ ARCH_PAGE_DBLWR_FULL_FLUSH_PAGE
Definition: arch0arch.h:236
Arch_State
Archiver system state.
Definition: arch0arch.h:158
@ ARCH_STATE_INIT
Archiver is initialized.
Definition: arch0arch.h:160
@ ARCH_STATE_PREPARE_IDLE
Archiver is processing last data chunks before idle state.
Definition: arch0arch.h:166
@ ARCH_STATE_ACTIVE
Archiver is active and archiving data.
Definition: arch0arch.h:163
@ ARCH_STATE_ABORT
Archiver is aborted.
Definition: arch0arch.h:175
@ ARCH_STATE_READ_ONLY
Server is in read only mode, and hence the archiver.
Definition: arch0arch.h:172
@ ARCH_STATE_IDLE
Archiver is idle.
Definition: arch0arch.h:169
Arch_Blk_Flush_Type
Archiver block flush type.
Definition: arch0arch.h:221
@ ARCH_FLUSH_NORMAL
Flush when block is full.
Definition: arch0arch.h:223
@ ARCH_FLUSH_PARTIAL
Flush partial block.
Definition: arch0arch.h:227
Arch_Blk_Type
Archiver block type.
Definition: arch0arch.h:212
@ ARCH_DATA_BLOCK
Definition: arch0arch.h:217
@ ARCH_RESET_BLOCK
Definition: arch0arch.h:214
const char ARCH_PAGE_DIR[]
Archive Page group directory prefix.
Definition: arch0arch.h:50
Arch_Page_Sys * arch_page_sys
Dirty page ID archiver system global.
Definition: arch0arch.cc:39
void log_archiver_thread()
Log archiver background thread.
Definition: arch0arch.cc:615
int start_log_archiver_background()
Start log archiver background thread.
Definition: arch0arch.cc:570
void arch_remove_dir(const char *dir_path, const char *dir_name)
Remove group directory and the files related to page and log archiving.
Definition: arch0arch.cc:89
os_event_t page_archiver_thread_event
Archiver thread event to signal that data is available.
Definition: arch0page.cc:50
const char ARCH_PAGE_FILE[]
Archive page file prefix.
Definition: arch0arch.h:56
void arch_remove_file(const char *file_path, const char *file_name)
Remove files related to page and log archiving.
Definition: arch0arch.cc:59
constexpr uint ARCH_PAGE_BLK_SIZE
Memory block size.
Definition: arch0arch.h:90
Arch_Client_State
Archiver client state.
Definition: arch0arch.h:113
@ ARCH_CLIENT_STATE_STOPPED
Archiving stopped by client.
Definition: arch0arch.h:121
@ ARCH_CLIENT_STATE_INIT
Client is initialized.
Definition: arch0arch.h:115
@ ARCH_CLIENT_STATE_STARTED
Archiving started by client.
Definition: arch0arch.h:118
std::deque< Arch_Reset_File > Arch_Reset
Definition: arch0arch.h:346
uint32_t Arch_group_uuid
Number which tries to uniquely identify the archived data (unless it is zero, which stands for unsupp...
Definition: arch0arch.h:842
const uint MAX_ARCH_DIR_NAME_LEN
Max string length for archive group directory name.
Definition: arch0arch.h:80
void page_archiver_thread()
Page archiver background thread.
Definition: arch0page.cc:53
constexpr char ARCH_PAGE_GROUP_DURABLE_FILE_NAME[]
File name for the durable file which indicates whether a group was made durable or not.
Definition: arch0arch.h:63
const uint MAX_ARCH_LOG_FILE_NAME_LEN
Max string length for archive log file name.
Definition: arch0arch.h:70
Arch_Grp_List::iterator Arch_Grp_List_Iter
An iterator for archive group.
Definition: arch0arch.h:1307
Arch_Log_Sys * arch_log_sys
Redo log archiver system global.
Definition: arch0arch.cc:36
os_event_t log_archiver_thread_event
Archiver thread event to signal that data is available.
Definition: arch0arch.cc:42
const char ARCH_LOG_DIR[]
Archive Log group directory prefix.
Definition: arch0arch.h:47
dberr_t arch_init()
Initialize Page and Log archiver system.
Definition: arch0arch.cc:117
std::list< Arch_Group *, ut::allocator< Arch_Group * > > Arch_Grp_List
A list of archive groups.
Definition: arch0arch.h:1304
std::vector< Arch_Block *, ut::allocator< Arch_Block * > > Arch_Block_Vec
Vector of page archive in memory blocks.
Definition: arch0arch.h:1509
const uint MAX_LSN_DECIMAL_DIGIT
Byte length for printing LSN.
Definition: arch0arch.h:67
const char ARCH_DIR[]
Archive directory prefix.
Definition: arch0arch.h:44
bool arch_wake_threads()
Wakes up archiver threads.
Definition: arch0arch.cc:46
Arch_Blk_State
Archived data block state.
Definition: arch0arch.h:197
@ ARCH_BLOCK_READY_TO_FLUSH
Data block is full but not flushed to disk.
Definition: arch0arch.h:205
@ ARCH_BLOCK_INIT
Data block is initialized.
Definition: arch0arch.h:199
@ ARCH_BLOCK_ACTIVE
Data block is active and having data.
Definition: arch0arch.h:202
@ ARCH_BLOCK_FLUSHED
Data block is flushed and can be reused.
Definition: arch0arch.h:208
const char ARCH_LOG_FILE[]
Archive log file prefix.
Definition: arch0arch.h:53
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:570
#define MYSQL_THD
Definition: backup_page_tracker.h:37
The database buffer pool high-level routines.
In memory data block in Page ID archiving system.
Definition: arch0arch.h:349
uint m_size
Total block size in bytes.
Definition: arch0arch.h:510
static uint64_t get_block_number(byte *block)
Get the block number from the block header.
Definition: arch0page.cc:1197
bool add_page(buf_page_t *page, Arch_Page_Pos *pos)
Add page ID to current block.
Definition: arch0page.cc:1300
Arch_Block(byte *blk_buf, uint size, Arch_Blk_Type type)
Constructor: Initialize elements.
Definition: arch0arch.h:355
static bool is_zeroes(const byte *block)
Check if the block contains only zeroes.
Definition: arch0page.cc:1230
uint get_data_len() const
Definition: arch0arch.h:425
uint64_t get_number() const
Definition: arch0arch.h:436
static bool validate(byte *block)
Check if the block data is valid.
Definition: arch0page.cc:1239
static uint64_t get_file_offset(uint64_t block_num, Arch_Blk_Type type)
Fetch the offset for a block in the archive file.
Definition: arch0page.cc:1209
uint64_t m_number
Unique block number.
Definition: arch0arch.h:516
byte * m_data
Block data buffer.
Definition: arch0arch.h:504
bool get_data(Arch_Page_Pos *read_pos, uint read_len, byte *read_buff)
Copy page Ids from this block at read position to a buffer.
Definition: arch0page.cc:1336
static uint32_t get_checksum(byte *block)
Get the checksum stored in the block header.
Definition: arch0page.cc:1205
lsn_t m_oldest_lsn
Oldest LSN of all the page IDs added to the block since the last checkpoint.
Definition: arch0arch.h:527
Arch_Blk_Type m_type
Type of block.
Definition: arch0arch.h:519
bool is_init() const
Check if block is initialised or not.
Definition: arch0arch.h:373
lsn_t get_oldest_lsn() const
Get oldest LSN among the pages that are added to this block.
Definition: arch0arch.h:443
dberr_t flush(Arch_Group *file_group, Arch_Blk_Flush_Type type)
Flush this block to the file group.
Definition: arch0page.cc:1369
bool is_active() const
Definition: arch0arch.h:375
bool is_flushable() const
Check if the block can be flushed or not.
Definition: arch0arch.h:378
Arch_Blk_State m_state
State of the block.
Definition: arch0arch.h:513
bool set_data(uint read_len, byte *read_buff, uint read_offset)
Copy page Ids from a buffer to this block.
Definition: arch0page.cc:1352
lsn_t get_stop_lsn() const
Definition: arch0arch.h:439
void set_reset_lsn(lsn_t reset_lsn)
Set the reset length of the block.
Definition: arch0arch.h:433
void update_block_header(lsn_t stop_lsn, lsn_t reset_lsn)
Definition: arch0page.cc:1256
void add_reset(lsn_t reset_lsn, Arch_Page_Pos reset_pos)
Definition: arch0page.cc:1414
static lsn_t get_reset_lsn(byte *block)
Get the reset lsn stored in the block header.
Definition: arch0page.cc:1201
Arch_Blk_State get_state() const
Get current state of the block.
Definition: arch0arch.h:447
static uint get_file_index(uint64_t block_num, Arch_Blk_Type type)
Get file index of the file the block belongs to.
Definition: arch0page.cc:1165
lsn_t m_stop_lsn
Checkpoint lsn at the time the last page ID was added to the block.
Definition: arch0arch.h:523
lsn_t m_reset_lsn
Start LSN or the last reset LSN of the group.
Definition: arch0arch.h:530
void begin_write(Arch_Page_Pos pos)
Set the block ready to begin writing page ID.
Definition: arch0page.cc:1273
static Arch_Blk_Type get_type(byte *block)
Get block type from the block header.
Definition: arch0page.cc:1184
void end_write()
End writing to a block.
Definition: arch0page.cc:1293
uint m_data_len
Block data length in bytes.
Definition: arch0arch.h:507
void set_data_len(uint data_len)
Set the data length of the block.
Definition: arch0arch.h:429
void copy_data(const Arch_Block *block)
Do a deep copy of the members of the block passed as the parameter.
Definition: arch0page.cc:1438
void set_flushed()
Set current block flushed.
Definition: arch0arch.h:382
Doublewrite buffer context.
Definition: arch0recv.h:134
Recovery system data structure for the archiver.
Definition: arch0recv.h:302
Archiver file context.
Definition: arch0arch.h:535
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.
Definition: arch0arch.cc:367
bool is_closed() const
Check if file is closed.
Definition: arch0arch.h:641
char * m_name_buf
File name buffer.
Definition: arch0arch.h:791
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.
Definition: arch0page.cc:398
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 fi...
Definition: arch0page.cc:738
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.
Definition: arch0page.cc:475
uint64_t m_offset
Current file offset.
Definition: arch0arch.h:819
pfs_os_file_t m_file
Current file descriptor.
Definition: arch0arch.h:810
lsn_t purge(lsn_t begin_lsn, lsn_t end_lsn, lsn_t purge_lsn)
Purge archived files until the specified purge LSN.
Definition: arch0page.cc:787
const char * m_file_name
File name prefix.
Definition: arch0arch.h:807
void build_dir_name(lsn_t dir_lsn, char *buffer, uint length)
Construct group directory name.
Definition: arch0arch.cc:559
uint get_index() const
Get current file index.
Definition: arch0arch.h:675
std::vector< lsn_t > m_stop_points
Vector of stop points corresponding to a file.
Definition: arch0arch.h:836
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...
Definition: arch0page.cc:570
uint64_t m_size
File size limit in bytes.
Definition: arch0arch.h:822
dberr_t init(const char *path, const char *base_dir, const char *base_file, uint num_files)
Initializes archiver file context.
Definition: arch0arch.cc:314
uint64_t bytes_left() const
Check how much is left in current file.
Definition: arch0arch.h:645
uint64_t get_phy_size() const
Get the physical size of a file that is open in this context.
Definition: arch0arch.h:683
void close()
Close file, if open.
Definition: arch0arch.h:632
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 ...
Definition: arch0page.cc:621
Arch_File_Ctx()
Constructor: Initialize members.
Definition: arch0arch.h:540
bool delete_file(uint file_index, lsn_t begin_lsn)
Delete a single file belonging to the specified file index.
Definition: arch0arch.cc:278
void build_name(uint idx, lsn_t dir_lsn, char *buffer, uint length)
Construct file name at specific index.
Definition: arch0arch.cc:527
void delete_files(lsn_t begin_lsn)
Delete all files for this archive group.
Definition: arch0arch.cc:300
uint m_count
Current number of files in the archive group.
Definition: arch0arch.h:816
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.
Definition: arch0page.cc:451
dberr_t open_new(lsn_t start_lsn, uint64_t new_file_size, uint64_t initial_file_size)
Add a new file and open.
Definition: arch0arch.cc:433
lsn_t fetch_reset_lsn(uint64_t block_num)
Fetch reset lsn of a particular reset point pertaining to a file.
Definition: arch0recv.cc:739
uint64_t get_size() const
Get the logical size of a file.
Definition: arch0arch.h:667
uint m_base_len
Fixed length part of the file.
Definition: arch0arch.h:798
const char * m_path_name
Fixed part of the path to file.
Definition: arch0arch.h:801
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.
Definition: arch0page.cc:370
void flush()
Flush file.
Definition: arch0arch.h:625
dberr_t open_next(lsn_t start_lsn, uint64_t file_offset, uint64_t file_size)
Open next file for read.
Definition: arch0arch.cc:443
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:752
dberr_t resize_and_overwrite_with_zeros(uint64_t file_size)
Resize file to provided size and overwrite the whole file with 0x00.
Definition: arch0arch.cc:470
dberr_t read(byte *to_buffer, const uint64_t offset, uint size)
Read data from the current file that is open.
Definition: arch0arch.cc:456
uint get_count() const
Get number of files.
Definition: arch0arch.h:679
~Arch_File_Ctx()
Destructor: Close open file and free resources.
Definition: arch0arch.h:543
uint m_name_len
File name buffer length.
Definition: arch0arch.h:794
const char * m_dir_name
Directory name prefix.
Definition: arch0arch.h:804
uint m_index
File index within the archive group.
Definition: arch0arch.h:813
void update_stop_point(uint file_index, lsn_t stop_lsn)
Update stop lsn of a file in the group.
Definition: arch0page.cc:360
Arch_Reset m_reset
Queue of file structure holding reset information pertaining to their respective files in a group.
Definition: arch0arch.h:828
uint64_t get_offset() const
Definition: arch0arch.h:671
Recovery system data structure for the archiver.
Definition: arch0recv.h:257
Contiguous archived data for redo log or page tracking.
Definition: arch0arch.h:847
uint m_ref_count
Number of clients referencing the group.
Definition: arch0arch.h:1262
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 ...
Definition: arch0arch.h:855
int read_from_file(Arch_Page_Pos *read_pos, uint read_len, byte *read_buff)
Get page IDs from archived file.
Definition: arch0page.cc:2915
dberr_t prepare_file_with_header(uint64_t start_offset, Get_file_header_callback &get_header)
Create a new file and write the header.
Definition: arch0arch.cc:167
void adjust_end_lsn(lsn_t &stop_lsn, uint32_t &blk_len)
Adjust end LSN to end of file.
Definition: arch0log.cc:397
uint get_file_count() const
Get the total number of archived files belonging to this group.
Definition: arch0arch.h:1099
char * m_durable_file_name
File name for the durable file which indicates whether a group was made durable or not.
Definition: arch0arch.h:1254
void get_file_name(uint idx, char *name_buf, uint buf_len)
Get archived file name at specific index in this group.
Definition: arch0arch.h:1164
int mark_durable()
Mark the group durable by creating a file in the respective group directory.
Definition: arch0page.cc:243
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 t...
Definition: arch0page.cc:337
bool is_active() const
Check if archiving is going on for this group.
Definition: arch0arch.h:1019
Arch_Group & operator=(Arch_Group const &)=delete
Disable assignment.
char * m_active_file_name
To know which group was active at the time of a crash/shutdown during recovery we create an empty fil...
Definition: arch0arch.h:1245
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.
Definition: arch0arch.h:1061
int mark_active()
Mark the group active by creating a file in the respective group directory.
Definition: arch0page.cc:210
pfs_os_file_t m_durable_file
File descriptor for a file to indicate that the group was made durable or not.
Definition: arch0arch.h:1259
void update_stop_point(Arch_Page_Pos pos, lsn_t stop_lsn)
Update stop lsn of a file in the group.
Definition: arch0arch.h:1139
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.
Definition: arch0recv.cc:472
bool is_referenced() const
Check if any client (durable or not) is attached to the archiver.
Definition: arch0arch.h:1103
uint64_t get_file_size() const
Get the current file size for this group.
Definition: arch0arch.h:1174
uint m_num_active
Number of clients for which archiving is in progress.
Definition: arch0arch.h:1268
int read_data(Arch_Page_Pos cur_pos, byte *buff, uint buff_len)
Parse block for block info (header/data).
Definition: arch0page.cc:2965
dberr_t build_active_file_name()
Construct file name for the active file which indicates whether a group is active or not.
Definition: arch0page.cc:164
Arch_group_uuid m_uuid
UUID generated for this arch group.
Definition: arch0arch.h:1286
Arch_File_Ctx m_file_ctx
Archive file context.
Definition: arch0arch.h:1289
~Arch_Group()
Destructor: Delete all files for non-durable archiving.
Definition: arch0page.cc:85
uint64_t m_file_size
Size of file used when a new file is being created.
Definition: arch0arch.h:1283
uint detach(lsn_t stop_lsn, Arch_Page_Pos *stop_pos)
Detach a client when archiving is stopped by the client.
Definition: arch0arch.h:945
Arch_Group(Arch_Group const &)=delete
Disable copy construction.
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.
Definition: arch0page.cc:111
void close_file_ctxs()
Definition: arch0arch.h:900
Arch_Page_Pos get_stop_pos() const
Definition: arch0arch.h:1184
uint m_header_len
Header length for the archived files.
Definition: arch0arch.h:1280
ib_mutex_t * m_arch_mutex
Mutex protecting concurrent operations by multiple clients.
Definition: arch0arch.h:1299
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.
Definition: arch0arch.h:891
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...
Definition: arch0arch.h:1249
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.
Definition: arch0arch.h:1132
bool is_durable_client_active() const
Check if any client requiring durable archiving is active.
Definition: arch0arch.h:1109
Arch_group_uuid get_uuid() const
Definition: arch0arch.h:1187
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:1192
void release(bool is_durable)
Release the archive group from a client.
Definition: arch0arch.h:965
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.
Definition: arch0arch.h:1071
dberr_t write_file_header(byte *from_buffer, uint length)
Write the header (RESET page) to an archived file.
Definition: arch0page.cc:315
static Arch_File_Ctx s_dblwr_file_ctx
Doublewrite buffer file context.
Definition: arch0arch.h:1293
void attach(bool is_durable)
Attach a client to the archive group.
Definition: arch0arch.h:923
lsn_t m_begin_lsn
Start LSN for the archive group.
Definition: arch0arch.h:1271
bool m_is_active
If the group is active.
Definition: arch0arch.h:1240
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.
Definition: arch0arch.cc:186
bool validate_info_in_files()
Check if the information maintained in the memory is the same as the information maintained in the fi...
Definition: arch0page.cc:711
Arch_Group(lsn_t start_lsn, uint header_len, ib_mutex_t *mutex)
Constructor: Initialize members.
Definition: arch0arch.h:861
uint purge(lsn_t purge_lsn, lsn_t &purged_lsn)
Purge archived files until the specified purge LSN.
Definition: arch0page.cc:849
Arch_Page_Pos m_stop_pos
Stop position of the group, if it's not active.
Definition: arch0arch.h:1277
lsn_t get_end_lsn() const
Definition: arch0arch.h:1181
void get_dir_name(char *name_buf, uint buf_len)
Get the directory name for this archive group.
Definition: arch0arch.h:1228
void adjust_copy_length(lsn_t arch_lsn, uint32_t ©_len)
Adjust redo copy length to end of file.
Definition: arch0log.cc:410
static void shutdown()
Operations to be done at the time of shutdown.
Definition: arch0arch.h:1126
void disable(lsn_t end_lsn)
Mark archive group inactive.
Definition: arch0arch.h:913
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.
Definition: arch0page.cc:146
dberr_t build_durable_file_name()
Construct file name for the durable file which indicates whether a group was made durable or not.
Definition: arch0page.cc:187
lsn_t get_begin_lsn() const
Get start LSN for this group.
Definition: arch0arch.h:1178
int mark_inactive()
Mark the group inactive by deleting the 'active' file.
Definition: arch0page.cc:279
lsn_t m_end_lsn
End lsn for this archive group.
Definition: arch0arch.h:1274
bool is_durable() const
Check if any client requires durable archiving.
Definition: arch0arch.h:1115
uint m_dur_ref_count
Number of clients referencing for durable archiving.
Definition: arch0arch.h:1265
Redo log archiving system.
Definition: arch0arch.h:1319
os_offset_t get_recommended_file_size() const
Get recommended archived redo file size.
Definition: arch0log.cc:203
Arch_Log_Sys(Arch_Log_Sys const &)=delete
Disable copy construction.
Arch_Log_Sys()
Constructor: Initialize members.
Definition: arch0arch.h:1322
void arch_mutex_exit()
Release redo log archiver mutex.
Definition: arch0arch.h:1419
void force_abort()
Force to abort the archiver (state becomes ARCH_STATE_IDLE or ARCH_STATE_ABORT).
Definition: arch0log.cc:488
void update_state_low(Arch_State state)
Update m_state to the given state.
Definition: arch0log.cc:924
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.
Definition: arch0log.cc:531
void arch_mutex_enter()
Acquire redo log archiver mutex.
Definition: arch0arch.h:1416
int stop(Arch_Group *group, lsn_t &stop_lsn, byte *log_blk, uint32_t &blk_len)
Stop redo log archiving.
Definition: arch0log.cc:439
lsn_t get_archived_lsn() const
Get LSN up to which redo is archived.
Definition: arch0arch.h:1353
uint m_chunk_size
Chunk size to copy redo data.
Definition: arch0arch.h:1495
Arch_Group * get_arch_group()
Get current redo log archive group.
Definition: arch0arch.h:1369
Arch_Grp_List m_group_list
List of log archive groups.
Definition: arch0arch.h:1489
int wait_archive_complete(lsn_t target_lsn)
Wait for redo log archive up to the target LSN.
Definition: arch0log.cc:763
uint64_t m_start_log_offset
System log file offset where the archiving started.
Definition: arch0arch.h:1501
void release(Arch_Group *group, bool is_durable)
Release the current group from client.
Definition: arch0log.cc:504
Arch_log_consumer m_log_consumer
Redo log consumer that can be registered to prevent consumption of redo log files which still haven't...
Definition: arch0arch.h:1505
ib_mutex_t m_mutex
Mutex to protect concurrent start, stop operations.
Definition: arch0arch.h:1477
dberr_t copy_log(Arch_File_Ctx *file_ctx, lsn_t start_lsn, uint length)
Copy redo log from file context to archiver files.
Definition: arch0log.cc:626
void update_state(Arch_State state)
Acquires log_sys's m_files_mutex, writer_mutex and calls.
Definition: arch0log.cc:917
bool is_active() const
Check if archiving is in progress.
Definition: arch0arch.h:1343
~Arch_Log_Sys()
Destructor: Free mutex.
Definition: arch0arch.h:1331
bool is_init() const
Check if archiver system is in initial state.
Definition: arch0arch.h:1349
Arch_State m_state
Archiver system state.
Definition: arch0arch.h:1483
bool wait_idle()
Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE.
Definition: arch0log.cc:714
Arch_Log_Sys & operator=(Arch_Log_Sys const &)=delete
Disable assignment.
int start(Arch_Group *&group, lsn_t &start_lsn, byte *header, bool is_durable)
Start redo log archiving.
Definition: arch0log.cc:250
Arch_Group * m_current_group
Current archive group.
Definition: arch0arch.h:1492
atomic_lsn_t m_archived_lsn
System has archived log up to this LSN.
Definition: arch0arch.h:1486
uint m_start_log_index
System log file number where the archiving started.
Definition: arch0arch.h:1498
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.
Definition: arch0log.cc:214
bool archive(bool init, Arch_File_Ctx *curr_ctx, lsn_t *arch_lsn, bool *wait)
Archive accumulated redo log in current group.
Definition: arch0log.cc:844
Recovery system data structure for the archiver.
Definition: arch0recv.h:188
Dirty page archive system.
Definition: arch0arch.h:1557
ArchPageData m_data
In memory data buffer.
Definition: arch0arch.h:1844
dberr_t flush_blocks(bool *wait)
Flush the blocks to disk.
Definition: arch0page.cc:2778
void arch_oper_mutex_enter()
Acquire dirty page ID archive operation mutex.
Definition: arch0arch.h:1631
Arch_Grp_List m_group_list
List of log archive groups.
Definition: arch0arch.h:1823
lsn_t get_latest_stop_lsn() const
Definition: arch0arch.h:1764
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:1672
Page_Arch_Client_Ctx * m_ctx
System client.
Definition: arch0arch.h:1879
void arch_mutex_enter()
Acquire dirty page ID archiver mutex.
Definition: arch0arch.h:1624
Arch_Page_Sys & operator=(Arch_Page_Sys const &)=delete
Disable assignment.
uint64_t m_flush_blk_num_with_lsn
Block number set once the flush archiver partially flushes the current active block with reset LSN.
Definition: arch0arch.h:1868
ib_mutex_t m_oper_mutex
Mutex protecting concurrent operation on data.
Definition: arch0arch.h:1838
Arch_Page_Pos m_reset_pos
Position to add new reset element.
Definition: arch0arch.h:1850
Arch_Page_Pos m_flush_pos
Position for start flushing.
Definition: arch0arch.h:1873
uint m_last_reset_file_index
The index of the file the last reset belonged to.
Definition: arch0arch.h:1876
Page_Arch_Client_Ctx * get_sys_client() const
Fetch the system client context.
Definition: arch0arch.h:1761
ib_mutex_t m_mutex
Mutex protecting concurrent start, stop operations.
Definition: arch0arch.h:1817
void post_recovery_init()
Set the latest stop LSN to the checkpoint LSN at the time it's called.
Definition: arch0page.cc:1607
int stop(Arch_Group *group, lsn_t *stop_lsn, Arch_Page_Pos *stop_pos, bool is_durable)
Stop dirty page ID archiving.
Definition: arch0page.cc:2588
dberr_t flush_active_block(Arch_Page_Pos cur_pos, bool partial_reset_block_flush)
Do a partial flush of the current active block.
Definition: arch0page.cc:2728
bool get_pages(Arch_Group *group, Arch_Page_Pos *read_pos, uint read_len, byte *read_buff)
Get page IDs from a specific position.
Definition: arch0page.cc:1801
bool is_gap_small()
Check if the gap from last reset is short.
Definition: arch0page.cc:2154
int recovery_load_and_start(const Arch_Recv_Group_Info &info)
Start dirty page ID archiving during recovery.
Definition: arch0page.cc:2275
void update_stop_info(Arch_Block *cur_blk)
Update the stop point in all the required structures.
Definition: arch0page.cc:3171
bool save_reset_point(bool is_durable)
Definition: arch0page.cc:2979
void track_page(buf_page_t *bpage, lsn_t track_lsn, lsn_t frame_lsn, bool force)
Check and add page ID to archived data.
Definition: arch0page.cc:1697
bool is_active() const
Check if archiver system is active.
Definition: arch0arch.h:1744
Arch_Page_Sys()
Constructor: Initialize elements and create mutex.
Definition: arch0page.cc:1576
void flush_at_checkpoint(lsn_t checkpoint_lsn)
Flush all the unflushed inactive blocks and flush the active block if required.
Definition: arch0page.cc:1619
void set_tracking_buf_pool(lsn_t tracking_lsn)
Enable tracking pages in all buffer pools.
Definition: arch0page.cc:2257
void set_read_only_mode()
Set the state of the archiver system to read only.
Definition: arch0arch.h:1735
Arch_Group * m_current_group
Current archive group.
Definition: arch0arch.h:1841
~Arch_Page_Sys()
Destructor: Free memory buffer and mutexes.
Definition: arch0page.cc:1589
int start(Arch_Group **group, lsn_t *start_lsn, Arch_Page_Pos *start_pos, bool is_durable, bool restart, bool recovery)
Start dirty page ID archiving.
Definition: arch0page.cc:2335
Arch_Page_Pos m_last_pos
Position where last client started archiving.
Definition: arch0arch.h:1826
ib_mutex_t * get_oper_mutex()
Definition: arch0arch.h:1757
uint64_t m_request_blk_num_with_lsn
Block number set to explicitly request the flush archiver to partially flush the current active block...
Definition: arch0arch.h:1862
void track_initial_pages()
Track pages for which IO is already started.
Definition: arch0page.cc:2177
bool wait_idle()
Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE.
Definition: arch0page.cc:2105
Arch_Page_Pos m_request_flush_pos
Position set to explicitly request the flush archiver to flush until this position.
Definition: arch0arch.h:1856
dberr_t recover()
Recover the archiver system at the time of startup.
Definition: arch0recv.cc:36
void release(Arch_Group *group, bool is_durable, Arch_Page_Pos start_pos)
Release the current group from client.
Definition: arch0page.cc:2674
void arch_oper_mutex_exit()
Release page ID archiver operatiion mutex.
Definition: arch0arch.h:1634
lsn_t m_latest_purged_lsn
LSN until where the groups are purged.
Definition: arch0arch.h:1835
void arch_mutex_exit()
Release page ID archiver mutex.
Definition: arch0arch.h:1627
bool is_abort() const
Definition: arch0arch.h:1749
void print()
Print information related to the archiver for debugging purposes.
Definition: arch0page.cc:3184
uint purge(lsn_t *purge_lsn)
Purge the archived files until the specified purge LSN.
Definition: arch0page.cc:3110
dberr_t flush_inactive_blocks(Arch_Page_Pos &cur_pos, Arch_Page_Pos end_pos)
Flush all the blocks which are ready to be flushed but not flushed.
Definition: arch0page.cc:2698
Arch_Page_Pos m_write_pos
Position to add new page ID.
Definition: arch0arch.h:1847
lsn_t m_latest_stop_lsn
Latest LSN until where the tracked pages have been flushed.
Definition: arch0arch.h:1832
bool is_init() const
Check if archiver system is in initial state.
Definition: arch0arch.h:1739
Arch_State m_state
Archiver system state.
Definition: arch0arch.h:1820
bool archive(bool *wait)
Archive dirty page IDs in current group.
Definition: arch0page.cc:2838
int fetch_group_within_lsn_range(lsn_t &start_id, lsn_t &stop_id, Arch_Group **group)
Get the group which has tracked pages between the start_id and stop_id.
Definition: arch0page.cc:3057
Arch_Page_Sys(Arch_Page_Sys const &)=delete
Disable copy construction.
bool wait_for_reset_info_flush(uint64_t request_block)
Wait for reset info to be flushed to disk.
Definition: arch0page.cc:3036
ib_mutex_t * get_mutex()
Get the mutex protecting concurrent start, stop operations required for initialising group during rec...
Definition: arch0arch.h:1754
bool get_num_pages(Arch_Page_Pos start_pos, Arch_Page_Pos stop_pos, uint64_t &num_pages)
Given start and stop position find number of pages tracked between them.
Definition: arch0page.cc:1983
lsn_t m_last_lsn
LSN when last client started archiving.
Definition: arch0arch.h:1829
Info related to each group parsed at different stages of page archive recovery.
Definition: arch0recv.h:41
Definition: arch0arch.h:1309
lsn_t get_consumed_lsn() const override
Definition: arch0log.cc:947
const std::string & get_name() const override
Definition: arch0log.cc:942
void consumption_requested() override
Request the log consumer to consume faster.
Definition: arch0log.cc:957
Guard to release resources safely.
Definition: arch0arch.h:274
std::function< void()> m_cleanup
Function to release the resource.
Definition: arch0arch.h:294
void cleanup()
Manually release the resource.
Definition: arch0arch.h:287
Arch_scope_guard(std::function< void()> function)
Attach a function to the guard which releases some resource.
Definition: arch0arch.h:277
~Arch_scope_guard()
Release the resources automatically at the time of destruction.
Definition: arch0arch.h:280
Definition: log0consumer.h:39
Dirty page archiver client context.
Definition: arch0page.h:169
Definition: buf0buf.h:1152
int page
Definition: ctype-mb.cc:1233
dberr_t
Definition: db0err.h:38
constexpr lsn_t LSN_MAX
Maximum possible lsn value is slightly higher than the maximum sn value, because lsn sequence enumera...
Definition: log0constants.h:155
std::atomic< lsn_t > atomic_lsn_t
Alias for atomic based on lsn_t.
Definition: log0types.h:81
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:62
static my_off_t start_offset
Definition: myisamlog.cc:100
static size_t file_size
Definition: mysql_config_editor.cc:71
static char * path
Definition: mysqldump.cc:148
Definition: buf0block_hint.cc:29
constexpr value_type read_only
Definition: classic_protocol_constants.h:212
bool restart(THD *thd)
Initialize the dictionary while restarting the server.
Definition: bootstrapper.cc:927
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:93
static int wait(mysql_cond_t *that, mysql_mutex_t *mutex_arg, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:62
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:417
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2873
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:716
#define OS_FILE_PREFIX
Prefix all files and directory created under data directory with special string so that it never conf...
Definition: os0file.h:67
constexpr uint32_t OS_FILE_LOG_BLOCK_SIZE
The next value should be smaller or equal to the smallest sector size used on any disk.
Definition: os0file.h:195
#define os_file_close(file)
Definition: os0file.h:1317
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3463
#define os_file_flush(file)
Definition: os0file.h:1339
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:154
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:86
int(* Page_Track_Callback)(MYSQL_THD thd, const unsigned char *buffer, size_t buf_len, int num_pages, void *user_ctx)
Page tracking callback function.
Definition: page_track_service.h:58
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:60
required string type
Definition: replication_group_member_actions.proto:33
Page archiver in memory data.
Definition: arch0arch.h:1512
Arch_Block * m_partial_flush_block
Temporary block used to copy active block for partial flush.
Definition: arch0arch.h:1541
uint m_block_size
Block size in bytes.
Definition: arch0arch.h:1544
Arch_Block * get_block(Arch_Page_Pos *pos, Arch_Blk_Type type)
Get the block for a position.
Definition: arch0page.cc:1556
bool init()
Allocate buffer and initialize blocks.
Definition: arch0page.cc:1464
uint m_num_data_blocks
Total number of blocks.
Definition: arch0arch.h:1547
Arch_Block * get_partial_flush_block() const
Definition: arch0arch.h:1530
byte * m_buffer
In memory buffer.
Definition: arch0arch.h:1550
Arch_Block * m_reset_block
Reset block.
Definition: arch0arch.h:1538
Arch_Block_Vec m_data_blocks
Vector of data blocks.
Definition: arch0arch.h:1535
void clean()
Delete blocks and buffer.
Definition: arch0page.cc:1533
ArchPageData()=default
Constructor.
Position in page ID archiving system.
Definition: arch0arch.h:298
bool operator<(Arch_Page_Pos pos)
Definition: arch0arch.h:311
uint64_t m_block_num
Unique block number.
Definition: arch0arch.h:306
void set_next()
Position in the beginning of next block.
Definition: arch0page.cc:1457
void init()
Initialize a position.
Definition: arch0page.cc:1451
uint m_offset
Offset within a block.
Definition: arch0arch.h:309
Structure which represents a point in a file.
Definition: arch0arch.h:321
Arch_Page_Pos pos
Position of the point.
Definition: arch0arch.h:326
lsn_t lsn
LSN of the point.
Definition: arch0arch.h:323
Definition: arch0arch.h:330
lsn_t m_lsn
Definition: arch0arch.h:339
uint m_file_index
Definition: arch0arch.h:335
void init()
Definition: arch0page.cc:77
std::vector< Arch_Point > m_start_point
Definition: arch0arch.h:342
InnoDB condition variable.
Definition: os0event.cc:62
Sparse file size information.
Definition: os0file.h:592
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:175
os_file_t m_file
Definition: os0file.h:185
@ LATCH_ID_LOG_ARCH
Definition: sync0types.h:389
constexpr uint32_t UNIV_PAGE_SIZE_DEF
Default page size for InnoDB tablespaces.
Definition: univ.i:324
#define IF_DEBUG(...)
Definition: univ.i:673
static uint64_t ut_uint64_align_down(uint64_t n, ulint align_no)
Rounds a 64-bit integer downward to a multiple of a power of 2.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
#define mutex_own(M)
Checks that the current thread owns the mutex.
Definition: ut0mutex.h:164
#define mutex_exit(M)
Definition: ut0mutex.h:122
#define mutex_free(M)
Definition: ut0mutex.h:124
#define mutex_enter(M)
Definition: ut0mutex.h:116
#define mutex_create(I, M)
Definition: ut0mutex.h:109
static uint64_t lsn
Definition: xcom_base.cc:445