33#ifndef ARCH_ARCH_INCLUDE
34#define ARCH_ARCH_INCLUDE
412 bool set_data(uint read_len,
byte *read_buff, uint read_offset);
553 dberr_t init(
const char *
path,
const char *base_dir,
const char *base_file,
566 uint64_t file_offset, uint64_t
file_size);
574 uint64_t initial_file_size);
749 for (
auto reset_file :
m_reset) {
750 for (
auto reset_point : reset_file.m_start_point) {
751 status.push_back(std::make_pair(reset_point.lsn,
true));
888 const char *base_file, uint num_files,
948 if (stop_pos !=
nullptr) {
1035 byte *from_buffer, uint write_size,
1049 uint
length,
bool partial_write,
bool do_persist,
1161 ut_ad(name_buf !=
nullptr);
1307 const std::string &
get_name()
const override;
1356 return archived_lsn;
1572 bool is_durable,
bool restart,
bool recovery);
1681 uint64_t &num_pages);
1809 bool partial_reset_block_flush);
void arch_free()
Free Page and Log archiver system.
Definition: arch0arch.cc:152
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:76
Arch_Page_Dblwr_Offset
Page Archive doublewrite buffer block offsets.
Definition: arch0arch.h:232
@ ARCH_PAGE_DBLWR_PARTIAL_FLUSH_PAGE
Definition: arch0arch.h:240
@ ARCH_PAGE_DBLWR_RESET_PAGE
Archive doublewrite buffer page offset for RESET page.
Definition: arch0arch.h:234
@ ARCH_PAGE_DBLWR_FULL_FLUSH_PAGE
Definition: arch0arch.h:237
Arch_State
Archiver system state.
Definition: arch0arch.h:159
@ ARCH_STATE_INIT
Archiver is initialized.
Definition: arch0arch.h:161
@ ARCH_STATE_PREPARE_IDLE
Archiver is processing last data chunks before idle state.
Definition: arch0arch.h:167
@ ARCH_STATE_ACTIVE
Archiver is active and archiving data.
Definition: arch0arch.h:164
@ ARCH_STATE_ABORT
Archiver is aborted.
Definition: arch0arch.h:176
@ ARCH_STATE_READ_ONLY
Server is in read only mode, and hence the archiver.
Definition: arch0arch.h:173
@ ARCH_STATE_IDLE
Archiver is idle.
Definition: arch0arch.h:170
Arch_Blk_Flush_Type
Archiver block flush type.
Definition: arch0arch.h:222
@ ARCH_FLUSH_NORMAL
Flush when block is full.
Definition: arch0arch.h:224
@ ARCH_FLUSH_PARTIAL
Flush partial block.
Definition: arch0arch.h:228
Arch_Blk_Type
Archiver block type.
Definition: arch0arch.h:213
@ ARCH_DATA_BLOCK
Definition: arch0arch.h:218
@ ARCH_RESET_BLOCK
Definition: arch0arch.h:215
const char ARCH_PAGE_DIR[]
Archive Page group directory prefix.
Definition: arch0arch.h:51
Arch_Page_Sys * arch_page_sys
Dirty page ID archiver system global.
Definition: arch0arch.cc:40
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:90
os_event_t page_archiver_thread_event
Archiver thread event to signal that data is available.
Definition: arch0page.cc:51
const char ARCH_PAGE_FILE[]
Archive page file prefix.
Definition: arch0arch.h:57
void arch_remove_file(const char *file_path, const char *file_name)
Remove files related to page and log archiving.
Definition: arch0arch.cc:60
constexpr uint ARCH_PAGE_BLK_SIZE
Memory block size.
Definition: arch0arch.h:91
Arch_Client_State
Archiver client state.
Definition: arch0arch.h:114
@ ARCH_CLIENT_STATE_STOPPED
Archiving stopped by client.
Definition: arch0arch.h:122
@ ARCH_CLIENT_STATE_INIT
Client is initialized.
Definition: arch0arch.h:116
@ ARCH_CLIENT_STATE_STARTED
Archiving started by client.
Definition: arch0arch.h:119
std::deque< Arch_Reset_File > Arch_Reset
Definition: arch0arch.h:347
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:838
const uint MAX_ARCH_DIR_NAME_LEN
Max string length for archive group directory name.
Definition: arch0arch.h:81
void page_archiver_thread()
Page archiver background thread.
Definition: arch0page.cc:54
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:64
const uint MAX_ARCH_LOG_FILE_NAME_LEN
Max string length for archive log file name.
Definition: arch0arch.h:71
Arch_Grp_List::iterator Arch_Grp_List_Iter
An iterator for archive group.
Definition: arch0arch.h:1303
Arch_Log_Sys * arch_log_sys
Redo log archiver system global.
Definition: arch0arch.cc:37
os_event_t log_archiver_thread_event
Archiver thread event to signal that data is available.
Definition: arch0arch.cc:43
const char ARCH_LOG_DIR[]
Archive Log group directory prefix.
Definition: arch0arch.h:48
dberr_t arch_init()
Initialize Page and Log archiver system.
Definition: arch0arch.cc:118
std::list< Arch_Group *, ut::allocator< Arch_Group * > > Arch_Grp_List
A list of archive groups.
Definition: arch0arch.h:1300
std::vector< Arch_Block *, ut::allocator< Arch_Block * > > Arch_Block_Vec
Vector of page archive in memory blocks.
Definition: arch0arch.h:1505
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
bool arch_wake_threads()
Wakes up archiver threads.
Definition: arch0arch.cc:47
Arch_Blk_State
Archived data block state.
Definition: arch0arch.h:198
@ ARCH_BLOCK_READY_TO_FLUSH
Data block is full but not flushed to disk.
Definition: arch0arch.h:206
@ ARCH_BLOCK_INIT
Data block is initialized.
Definition: arch0arch.h:200
@ ARCH_BLOCK_ACTIVE
Data block is active and having data.
Definition: arch0arch.h:203
@ ARCH_BLOCK_FLUSHED
Data block is flushed and can be reused.
Definition: arch0arch.h:209
const char ARCH_LOG_FILE[]
Archive log file prefix.
Definition: arch0arch.h:54
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
#define MYSQL_THD
Definition: backup_page_tracker.h:38
The database buffer pool high-level routines.
In memory data block in Page ID archiving system.
Definition: arch0arch.h:350
uint m_size
Total block size in bytes.
Definition: arch0arch.h:506
static uint64_t get_block_number(byte *block)
Get the block number from the block header.
Definition: arch0page.cc:1196
bool add_page(buf_page_t *page, Arch_Page_Pos *pos)
Add page ID to current block.
Definition: arch0page.cc:1290
Arch_Block(byte *blk_buf, uint size, Arch_Blk_Type type)
Constructor: Initialize elements.
Definition: arch0arch.h:356
uint get_data_len() const
Definition: arch0arch.h:426
uint64_t get_number() const
Definition: arch0arch.h:437
static bool validate(byte *block)
Check if the block data is valid.
Definition: arch0page.cc:1229
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:1208
uint64_t m_number
Unique block number.
Definition: arch0arch.h:512
byte * m_data
Block data buffer.
Definition: arch0arch.h:500
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:1326
static uint32_t get_checksum(byte *block)
Get the checksum stored in the block header.
Definition: arch0page.cc:1204
lsn_t m_oldest_lsn
Oldest LSN of all the page IDs added to the block since the last checkpoint.
Definition: arch0arch.h:523
Arch_Blk_Type m_type
Type of block.
Definition: arch0arch.h:515
bool is_init() const
Check if block is initialised or not.
Definition: arch0arch.h:374
lsn_t get_oldest_lsn() const
Get oldest LSN among the pages that are added to this block.
Definition: arch0arch.h:444
dberr_t flush(Arch_Group *file_group, Arch_Blk_Flush_Type type)
Flush this block to the file group.
Definition: arch0page.cc:1359
bool is_active() const
Definition: arch0arch.h:376
bool is_flushable() const
Check if the block can be flushed or not.
Definition: arch0arch.h:379
Arch_Blk_State m_state
State of the block.
Definition: arch0arch.h:509
bool set_data(uint read_len, byte *read_buff, uint read_offset)
Copy page Ids from a buffer to this block.
Definition: arch0page.cc:1342
lsn_t get_stop_lsn() const
Definition: arch0arch.h:440
void set_reset_lsn(lsn_t reset_lsn)
Set the reset length of the block.
Definition: arch0arch.h:434
void update_block_header(lsn_t stop_lsn, lsn_t reset_lsn)
Definition: arch0page.cc:1246
void add_reset(lsn_t reset_lsn, Arch_Page_Pos reset_pos)
Definition: arch0page.cc:1404
static lsn_t get_reset_lsn(byte *block)
Get the reset lsn stored in the block header.
Definition: arch0page.cc:1200
Arch_Blk_State get_state() const
Get current state of the block.
Definition: arch0arch.h:448
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:1164
lsn_t m_stop_lsn
Checkpoint lsn at the time the last page ID was added to the block.
Definition: arch0arch.h:519
lsn_t m_reset_lsn
Start LSN or the last reset LSN of the group.
Definition: arch0arch.h:526
void begin_write(Arch_Page_Pos pos)
Set the block ready to begin writing page ID.
Definition: arch0page.cc:1263
static Arch_Blk_Type get_type(byte *block)
Get block type from the block header.
Definition: arch0page.cc:1183
void end_write()
End writing to a block.
Definition: arch0page.cc:1283
uint m_data_len
Block data length in bytes.
Definition: arch0arch.h:503
void set_data_len(uint data_len)
Set the data length of the block.
Definition: arch0arch.h:430
void copy_data(const Arch_Block *block)
Do a deep copy of the members of the block passed as the parameter.
Definition: arch0page.cc:1428
void set_flushed()
Set current block flushed.
Definition: arch0arch.h:383
Doublewrite buffer context.
Definition: arch0recv.h:135
Recovery system data structure for the archiver.
Definition: arch0recv.h:303
Archiver file context.
Definition: arch0arch.h:531
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:368
bool is_closed() const
Check if file is closed.
Definition: arch0arch.h:637
char * m_name_buf
File name buffer.
Definition: arch0arch.h:787
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:397
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:737
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:474
uint64_t m_offset
Current file offset.
Definition: arch0arch.h:815
pfs_os_file_t m_file
Current file descriptor.
Definition: arch0arch.h:806
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:786
const char * m_file_name
File name prefix.
Definition: arch0arch.h:803
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:671
std::vector< lsn_t > m_stop_points
Vector of stop points corresponding to a file.
Definition: arch0arch.h:832
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:569
uint64_t m_size
File size limit in bytes.
Definition: arch0arch.h:818
dberr_t init(const char *path, const char *base_dir, const char *base_file, uint num_files)
Initializes archiver file context.
Definition: arch0arch.cc:315
uint64_t bytes_left() const
Check how much is left in current file.
Definition: arch0arch.h:641
uint64_t get_phy_size() const
Get the physical size of a file that is open in this context.
Definition: arch0arch.h:679
void close()
Close file, if open.
Definition: arch0arch.h:628
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:620
Arch_File_Ctx()
Constructor: Initialize members.
Definition: arch0arch.h:536
bool delete_file(uint file_index, lsn_t begin_lsn)
Delete a single file belonging to the specified file index.
Definition: arch0arch.cc:279
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:301
uint m_count
Current number of files in the archive group.
Definition: arch0arch.h:812
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:450
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:740
uint64_t get_size() const
Get the logical size of a file.
Definition: arch0arch.h:663
uint m_base_len
Fixed length part of the file.
Definition: arch0arch.h:794
const char * m_path_name
Fixed part of the path to file.
Definition: arch0arch.h:797
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:369
void flush()
Flush file.
Definition: arch0arch.h:621
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:748
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:675
~Arch_File_Ctx()
Destructor: Close open file and free resources.
Definition: arch0arch.h:539
uint m_name_len
File name buffer length.
Definition: arch0arch.h:790
const char * m_dir_name
Directory name prefix.
Definition: arch0arch.h:800
uint m_index
File index within the archive group.
Definition: arch0arch.h:809
void update_stop_point(uint file_index, lsn_t stop_lsn)
Update stop lsn of a file in the group.
Definition: arch0page.cc:359
Arch_Reset m_reset
Queue of file structure holding reset information pertaining to their respective files in a group.
Definition: arch0arch.h:824
uint64_t get_offset() const
Definition: arch0arch.h:667
Recovery system data structure for the archiver.
Definition: arch0recv.h:258
Contiguous archived data for redo log or page tracking.
Definition: arch0arch.h:843
uint m_ref_count
Number of clients referencing the group.
Definition: arch0arch.h:1258
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:851
int read_from_file(Arch_Page_Pos *read_pos, uint read_len, byte *read_buff)
Get page IDs from archived file.
Definition: arch0page.cc:2906
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:168
void adjust_end_lsn(lsn_t &stop_lsn, uint32_t &blk_len)
Adjust end LSN to end of file.
Definition: arch0log.cc:398
uint get_file_count() const
Get the total number of archived files belonging to this group.
Definition: arch0arch.h:1095
char * m_durable_file_name
File name for the durable file which indicates whether a group was made durable or not.
Definition: arch0arch.h:1250
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:1160
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:336
bool is_active() const
Check if archiving is going on for this group.
Definition: arch0arch.h:1015
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:1241
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:1057
int mark_active()
Mark the group active by creating a file in the respective group directory.
Definition: arch0page.cc:211
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:1255
void update_stop_point(Arch_Page_Pos pos, lsn_t stop_lsn)
Update stop lsn of a file in the group.
Definition: arch0arch.h:1135
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:473
bool is_referenced() const
Check if any client (durable or not) is attached to the archiver.
Definition: arch0arch.h:1099
uint64_t get_file_size() const
Get the current file size for this group.
Definition: arch0arch.h:1170
uint m_num_active
Number of clients for which archiving is in progress.
Definition: arch0arch.h:1264
int read_data(Arch_Page_Pos cur_pos, byte *buff, uint buff_len)
Parse block for block info (header/data).
Definition: arch0page.cc:2956
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:165
Arch_group_uuid m_uuid
UUID generated for this arch group.
Definition: arch0arch.h:1282
Arch_File_Ctx m_file_ctx
Archive file context.
Definition: arch0arch.h:1285
~Arch_Group()
Destructor: Delete all files for non-durable archiving.
Definition: arch0page.cc:86
uint64_t m_file_size
Size of file used when a new file is being created.
Definition: arch0arch.h:1279
uint detach(lsn_t stop_lsn, Arch_Page_Pos *stop_pos)
Detach a client when archiving is stopped by the client.
Definition: arch0arch.h:941
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:112
void close_file_ctxs()
Definition: arch0arch.h:896
Arch_Page_Pos get_stop_pos() const
Definition: arch0arch.h:1180
uint m_header_len
Header length for the archived files.
Definition: arch0arch.h:1276
ib_mutex_t * m_arch_mutex
Mutex protecting concurrent operations by multiple clients.
Definition: arch0arch.h:1295
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:887
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:1245
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:1128
bool is_durable_client_active() const
Check if any client requiring durable archiving is active.
Definition: arch0arch.h:1105
Arch_group_uuid get_uuid() const
Definition: arch0arch.h:1183
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:1188
void release(bool is_durable)
Release the archive group from a client.
Definition: arch0arch.h:961
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:1067
dberr_t write_file_header(byte *from_buffer, uint length)
Write the header (RESET page) to an archived file.
Definition: arch0page.cc:314
static Arch_File_Ctx s_dblwr_file_ctx
Doublewrite buffer file context.
Definition: arch0arch.h:1289
void attach(bool is_durable)
Attach a client to the archive group.
Definition: arch0arch.h:919
lsn_t m_begin_lsn
Start LSN for the archive group.
Definition: arch0arch.h:1267
bool m_is_active
If the group is active.
Definition: arch0arch.h:1236
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:187
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:710
Arch_Group(lsn_t start_lsn, uint header_len, ib_mutex_t *mutex)
Constructor: Initialize members.
Definition: arch0arch.h:857
uint purge(lsn_t purge_lsn, lsn_t &purged_lsn)
Purge archived files until the specified purge LSN.
Definition: arch0page.cc:848
Arch_Page_Pos m_stop_pos
Stop position of the group, if it's not active.
Definition: arch0arch.h:1273
lsn_t get_end_lsn() const
Definition: arch0arch.h:1177
void get_dir_name(char *name_buf, uint buf_len)
Get the directory name for this archive group.
Definition: arch0arch.h:1224
void adjust_copy_length(lsn_t arch_lsn, uint32_t ©_len)
Adjust redo copy length to end of file.
Definition: arch0log.cc:411
static void shutdown()
Operations to be done at the time of shutdown.
Definition: arch0arch.h:1122
void disable(lsn_t end_lsn)
Mark archive group inactive.
Definition: arch0arch.h:909
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:147
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:188
lsn_t get_begin_lsn() const
Get start LSN for this group.
Definition: arch0arch.h:1174
int mark_inactive()
Mark the group inactive by deleting the 'active' file.
Definition: arch0page.cc:278
lsn_t m_end_lsn
End lsn for this archive group.
Definition: arch0arch.h:1270
bool is_durable() const
Check if any client requires durable archiving.
Definition: arch0arch.h:1111
uint m_dur_ref_count
Number of clients referencing for durable archiving.
Definition: arch0arch.h:1261
Redo log archiving system.
Definition: arch0arch.h:1315
os_offset_t get_recommended_file_size() const
Get recommended archived redo file size.
Definition: arch0log.cc:204
Arch_Log_Sys(Arch_Log_Sys const &)=delete
Disable copy construction.
Arch_Log_Sys()
Constructor: Initialize members.
Definition: arch0arch.h:1318
void arch_mutex_exit()
Release redo log archiver mutex.
Definition: arch0arch.h:1415
void force_abort()
Force to abort the archiver (state becomes ARCH_STATE_IDLE or ARCH_STATE_ABORT).
Definition: arch0log.cc:489
void update_state_low(Arch_State state)
Update m_state to the given state.
Definition: arch0log.cc:925
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:532
void arch_mutex_enter()
Acquire redo log archiver mutex.
Definition: arch0arch.h:1412
int stop(Arch_Group *group, lsn_t &stop_lsn, byte *log_blk, uint32_t &blk_len)
Stop redo log archiving.
Definition: arch0log.cc:440
lsn_t get_archived_lsn() const
Get LSN up to which redo is archived.
Definition: arch0arch.h:1349
uint m_chunk_size
Chunk size to copy redo data.
Definition: arch0arch.h:1491
Arch_Group * get_arch_group()
Get current redo log archive group.
Definition: arch0arch.h:1365
Arch_Grp_List m_group_list
List of log archive groups.
Definition: arch0arch.h:1485
int wait_archive_complete(lsn_t target_lsn)
Wait for redo log archive up to the target LSN.
Definition: arch0log.cc:764
uint64_t m_start_log_offset
System log file offset where the archiving started.
Definition: arch0arch.h:1497
void release(Arch_Group *group, bool is_durable)
Release the current group from client.
Definition: arch0log.cc:505
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:1501
ib_mutex_t m_mutex
Mutex to protect concurrent start, stop operations.
Definition: arch0arch.h:1473
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:627
void update_state(Arch_State state)
Acquires log_sys's m_files_mutex, writer_mutex and calls.
Definition: arch0log.cc:918
bool is_active() const
Check if archiving is in progress.
Definition: arch0arch.h:1339
~Arch_Log_Sys()
Destructor: Free mutex.
Definition: arch0arch.h:1327
bool is_init() const
Check if archiver system is in initial state.
Definition: arch0arch.h:1345
Arch_State m_state
Archiver system state.
Definition: arch0arch.h:1479
bool wait_idle()
Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE.
Definition: arch0log.cc:715
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:251
Arch_Group * m_current_group
Current archive group.
Definition: arch0arch.h:1488
atomic_lsn_t m_archived_lsn
System has archived log up to this LSN.
Definition: arch0arch.h:1482
uint m_start_log_index
System log file number where the archiving started.
Definition: arch0arch.h:1494
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:215
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:845
Recovery system data structure for the archiver.
Definition: arch0recv.h:189
Dirty page archive system.
Definition: arch0arch.h:1553
ArchPageData m_data
In memory data buffer.
Definition: arch0arch.h:1840
dberr_t flush_blocks(bool *wait)
Flush the blocks to disk.
Definition: arch0page.cc:2769
void arch_oper_mutex_enter()
Acquire dirty page ID archive operation mutex.
Definition: arch0arch.h:1627
Arch_Grp_List m_group_list
List of log archive groups.
Definition: arch0arch.h:1819
lsn_t get_latest_stop_lsn() const
Definition: arch0arch.h:1760
void get_status(std::vector< std::pair< lsn_t, bool > > &status)
Fetch the status of the page tracking system.
Definition: arch0arch.h:1668
Page_Arch_Client_Ctx * m_ctx
System client.
Definition: arch0arch.h:1875
void arch_mutex_enter()
Acquire dirty page ID archiver mutex.
Definition: arch0arch.h:1620
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:1864
ib_mutex_t m_oper_mutex
Mutex protecting concurrent operation on data.
Definition: arch0arch.h:1834
Arch_Page_Pos m_reset_pos
Position to add new reset element.
Definition: arch0arch.h:1846
Arch_Page_Pos m_flush_pos
Position for start flushing.
Definition: arch0arch.h:1869
uint m_last_reset_file_index
The index of the file the last reset belonged to.
Definition: arch0arch.h:1872
Page_Arch_Client_Ctx * get_sys_client() const
Fetch the system client context.
Definition: arch0arch.h:1757
ib_mutex_t m_mutex
Mutex protecting concurrent start, stop operations.
Definition: arch0arch.h:1813
void post_recovery_init()
Set the latest stop LSN to the checkpoint LSN at the time it's called.
Definition: arch0page.cc:1597
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:2579
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:2719
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:1791
bool is_gap_small()
Check if the gap from last reset is short.
Definition: arch0page.cc:2144
int recovery_load_and_start(const Arch_Recv_Group_Info &info)
Start dirty page ID archiving during recovery.
Definition: arch0page.cc:2266
void update_stop_info(Arch_Block *cur_blk)
Update the stop point in all the required structures.
Definition: arch0page.cc:3162
bool save_reset_point(bool is_durable)
Definition: arch0page.cc:2970
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:1687
bool is_active() const
Check if archiver system is active.
Definition: arch0arch.h:1740
Arch_Page_Sys()
Constructor: Initialize elements and create mutex.
Definition: arch0page.cc:1566
void flush_at_checkpoint(lsn_t checkpoint_lsn)
Flush all the unflushed inactive blocks and flush the active block if required.
Definition: arch0page.cc:1609
void set_tracking_buf_pool(lsn_t tracking_lsn)
Enable tracking pages in all buffer pools.
Definition: arch0page.cc:2248
void set_read_only_mode()
Set the state of the archiver system to read only.
Definition: arch0arch.h:1731
Arch_Group * m_current_group
Current archive group.
Definition: arch0arch.h:1837
~Arch_Page_Sys()
Destructor: Free memory buffer and mutexes.
Definition: arch0page.cc:1579
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:2326
Arch_Page_Pos m_last_pos
Position where last client started archiving.
Definition: arch0arch.h:1822
ib_mutex_t * get_oper_mutex()
Definition: arch0arch.h:1753
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:1858
void track_initial_pages()
Track pages for which IO is already started.
Definition: arch0page.cc:2167
bool wait_idle()
Wait for archive system to come out of ARCH_STATE_PREPARE_IDLE.
Definition: arch0page.cc:2095
Arch_Page_Pos m_request_flush_pos
Position set to explicitly request the flush archiver to flush until this position.
Definition: arch0arch.h:1852
dberr_t recover()
Recover the archiver system at the time of startup.
Definition: arch0recv.cc:37
void release(Arch_Group *group, bool is_durable, Arch_Page_Pos start_pos)
Release the current group from client.
Definition: arch0page.cc:2665
void arch_oper_mutex_exit()
Release page ID archiver operatiion mutex.
Definition: arch0arch.h:1630
lsn_t m_latest_purged_lsn
LSN until where the groups are purged.
Definition: arch0arch.h:1831
void arch_mutex_exit()
Release page ID archiver mutex.
Definition: arch0arch.h:1623
bool is_abort() const
Definition: arch0arch.h:1745
void print()
Print information related to the archiver for debugging purposes.
Definition: arch0page.cc:3175
uint purge(lsn_t *purge_lsn)
Purge the archived files until the specified purge LSN.
Definition: arch0page.cc:3101
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:2689
Arch_Page_Pos m_write_pos
Position to add new page ID.
Definition: arch0arch.h:1843
lsn_t m_latest_stop_lsn
Latest LSN until where the tracked pages have been flushed.
Definition: arch0arch.h:1828
bool is_init() const
Check if archiver system is in initial state.
Definition: arch0arch.h:1735
Arch_State m_state
Archiver system state.
Definition: arch0arch.h:1816
bool archive(bool *wait)
Archive dirty page IDs in current group.
Definition: arch0page.cc:2829
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:3048
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:3027
ib_mutex_t * get_mutex()
Get the mutex protecting concurrent start, stop operations required for initialising group during rec...
Definition: arch0arch.h:1750
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:1973
lsn_t m_last_lsn
LSN when last client started archiving.
Definition: arch0arch.h:1825
Info related to each group parsed at different stages of page archive recovery.
Definition: arch0recv.h:42
Definition: arch0arch.h:1305
lsn_t get_consumed_lsn() const override
Definition: arch0log.cc:948
const std::string & get_name() const override
Definition: arch0log.cc:943
void consumption_requested() override
Request the log consumer to consume faster.
Definition: arch0log.cc:958
Guard to release resources safely.
Definition: arch0arch.h:275
std::function< void()> m_cleanup
Function to release the resource.
Definition: arch0arch.h:295
void cleanup()
Manually release the resource.
Definition: arch0arch.h:288
Arch_scope_guard(std::function< void()> function)
Attach a function to the guard which releases some resource.
Definition: arch0arch.h:278
~Arch_scope_guard()
Release the resources automatically at the time of destruction.
Definition: arch0arch.h:281
Definition: log0consumer.h:40
Dirty page archiver client context.
Definition: arch0page.h:170
Definition: buf0buf.h:1153
int page
Definition: ctype-mb.cc:1224
dberr_t
Definition: db0err.h:39
constexpr lsn_t LSN_MAX
Maximum possible lsn value is slightly higher than the maximum sn value, because lsn sequence enumera...
Definition: log0constants.h:159
std::atomic< lsn_t > atomic_lsn_t
Alias for atomic based on lsn_t.
Definition: log0types.h:82
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
static my_off_t start_offset
Definition: myisamlog.cc:101
static size_t file_size
Definition: mysql_config_editor.cc:72
static char * path
Definition: mysqldump.cc:149
Definition: buf0block_hint.cc:30
constexpr value_type read_only
Definition: classic_protocol_constants.h:213
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:76
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:94
static int wait(mysql_cond_t *that, mysql_mutex_t *mutex_arg, const char *, unsigned int)
Definition: mysql_cond_v1_native.cc:63
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
void free(void *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::malloc*(),...
Definition: ut0new.h:719
#define OS_FILE_PREFIX
Prefix all files and directory created under data directory with special string so that it never conf...
Definition: os0file.h:68
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:192
#define os_file_close(file)
Definition: os0file.h:1308
os_file_size_t os_file_get_size(const char *filename)
Gets a file size.
Definition: os0file.cc:3413
#define os_file_flush(file)
Definition: os0file.h:1330
static constexpr os_fd_t OS_FILE_CLOSED
Definition: os0file.h:151
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
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:66
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
required string type
Definition: replication_group_member_actions.proto:34
Page archiver in memory data.
Definition: arch0arch.h:1508
Arch_Block * m_partial_flush_block
Temporary block used to copy active block for partial flush.
Definition: arch0arch.h:1537
uint m_block_size
Block size in bytes.
Definition: arch0arch.h:1540
Arch_Block * get_block(Arch_Page_Pos *pos, Arch_Blk_Type type)
Get the block for a position.
Definition: arch0page.cc:1546
bool init()
Allocate buffer and initialize blocks.
Definition: arch0page.cc:1454
uint m_num_data_blocks
Total number of blocks.
Definition: arch0arch.h:1543
Arch_Block * get_partial_flush_block() const
Definition: arch0arch.h:1526
byte * m_buffer
In memory buffer.
Definition: arch0arch.h:1546
Arch_Block * m_reset_block
Reset block.
Definition: arch0arch.h:1534
Arch_Block_Vec m_data_blocks
Vector of data blocks.
Definition: arch0arch.h:1531
void clean()
Delete blocks and buffer.
Definition: arch0page.cc:1523
ArchPageData()=default
Constructor.
Position in page ID archiving system.
Definition: arch0arch.h:299
bool operator<(Arch_Page_Pos pos)
Definition: arch0arch.h:312
uint64_t m_block_num
Unique block number.
Definition: arch0arch.h:307
void set_next()
Position in the beginning of next block.
Definition: arch0page.cc:1447
void init()
Initialize a position.
Definition: arch0page.cc:1441
uint m_offset
Offset within a block.
Definition: arch0arch.h:310
Structure which represents a point in a file.
Definition: arch0arch.h:322
Arch_Page_Pos pos
Position of the point.
Definition: arch0arch.h:327
lsn_t lsn
LSN of the point.
Definition: arch0arch.h:324
Definition: arch0arch.h:331
lsn_t m_lsn
Definition: arch0arch.h:340
uint m_file_index
Definition: arch0arch.h:336
void init()
Definition: arch0page.cc:78
std::vector< Arch_Point > m_start_point
Definition: arch0arch.h:343
InnoDB condition variable.
Definition: os0event.cc:63
Sparse file size information.
Definition: os0file.h:580
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:172
os_file_t m_file
Definition: os0file.h:182
@ LATCH_ID_LOG_ARCH
Definition: sync0types.h:393
constexpr uint32_t UNIV_PAGE_SIZE_DEF
Default page size for InnoDB tablespaces.
Definition: univ.i:325
#define IF_DEBUG(...)
Definition: univ.i:674
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:105
#define mutex_own(M)
Checks that the current thread owns the mutex.
Definition: ut0mutex.h:165
#define mutex_exit(M)
Definition: ut0mutex.h:123
#define mutex_free(M)
Definition: ut0mutex.h:125
#define mutex_enter(M)
Definition: ut0mutex.h:117
#define mutex_create(I, M)
Definition: ut0mutex.h:110
static uint64_t lsn
Definition: xcom_base.cc:446