MySQL 9.1.0
Source Code Documentation
|
Dynamic database snapshot: Holds metadata and handle to data. More...
#include <clone0snapshot.h>
Classes | |
class | State_transit |
RAII style guard for begin & end of snapshot state transition. More... | |
Public Types | |
using | File_Cbk_Func = std::function< int(Clone_file_ctx *)> |
Public Member Functions | |
Clone_Snapshot (Clone_Handle_Type hdl_type, Ha_clone_type clone_type, uint arr_idx, uint64_t snap_id) | |
Construct snapshot. More... | |
~Clone_Snapshot () | |
Release contexts and free heap. More... | |
bool | begin_ddl_state (Clone_notify::Type type, space_id_t space, bool no_wait, bool check_intr, int &error) |
DDL notification before the operation. More... | |
void | end_ddl_state (Clone_notify::Type type, space_id_t space) |
DDL notification after the operation. More... | |
int | pin_file (Clone_file_ctx *file_ctx, bool &handle_delete) |
Wait for concurrent DDL file operation and pin file. More... | |
void | unpin_file (Clone_file_ctx *file_ctx) |
Unpin a file. More... | |
bool | blocks_clone (const Clone_file_ctx *file_ctx) |
Check if DDL needs to block clone operation. More... | |
uint64_t | get_disk_estimate () const |
uint64_t | get_id () |
Get unique snapshot identifier. More... | |
uint | get_index () |
Get snapshot index in global array. More... | |
Clone_Monitor & | get_clone_monitor () |
Get performance schema accounting object used to monitor stage progress. More... | |
mem_heap_t * | lock_heap () |
Get snapshot heap used for allocation during clone. More... | |
void | release_heap (mem_heap_t *&heap) |
Snapshot_State | get_state () |
Get snapshot state. More... | |
uint64_t | get_redo_file_size () |
Get the redo file size for the snapshot. More... | |
uint | get_num_chunks () |
Get total number of chunks for current state. More... | |
size_t | get_max_file_name_length () |
Get maximum file length seen till now. More... | |
uint | get_dyn_buffer_length () |
Get maximum buffer size required for clone. More... | |
int | iterate_files (File_Cbk_Func &&func) |
Iterate through all files in current state. More... | |
int | iterate_data_files (File_Cbk_Func &&func) |
Iterate through all data files. More... | |
int | iterate_redo_files (File_Cbk_Func &&func) |
Iterate through all redo files. More... | |
void | get_state_info (bool do_estimate, Clone_Desc_State *state_desc) |
Fill state descriptor from snapshot. More... | |
void | set_state_info (Clone_Desc_State *state_desc) |
Set state information during apply. More... | |
Snapshot_State | get_next_state () |
Get next state based on snapshot type. More... | |
bool | attach (Clone_Handle_Type hdl_type, bool pfs_monitor) |
Try to attach to snapshot. More... | |
void | detach () |
Detach from snapshot. More... | |
void | set_abort () |
Set current snapshot aborted state. More... | |
bool | is_aborted () const |
int | change_state (Clone_Desc_State *state_desc, Snapshot_State new_state, byte *temp_buffer, uint temp_buffer_len, Clone_Alert_Func cbk) |
Start transition to new state. More... | |
int | get_file_from_desc (const Clone_File_Meta *file_meta, const char *data_dir, bool desc_create, bool &desc_exists, Clone_file_ctx *&file_ctx) |
Add file metadata entry at destination. More... | |
int | rename_desc (const Clone_File_Meta *file_meta, const char *data_dir, Clone_file_ctx *&file_ctx) |
Rename an existing file descriptor. More... | |
int | fix_ddl_extension (const char *data_dir, Clone_file_ctx *file_ctx) |
Fix files renamed with ddl extension. More... | |
bool | add_file_from_desc (Clone_file_ctx *&file_ctx, bool ddl_create) |
Add file descriptor to file list. More... | |
dberr_t | add_node (fil_node_t *node, bool by_ddl) |
Extract file information from node and add to snapshot. More... | |
int | add_page (uint32_t space_id, uint32_t page_num) |
Add page ID to to the set of pages in snapshot. More... | |
int | add_redo_file (char *file_name, uint64_t file_size, uint64_t file_offset) |
Add redo file to snapshot. More... | |
Clone_File_Meta * | get_file_by_index (uint index) |
Get file metadata by index for current state. More... | |
Clone_file_ctx * | get_file_ctx_by_index (uint index) |
Get clone file context by index for current state. More... | |
Clone_file_ctx * | get_file_ctx (uint32_t chunk_num, uint32_t block_num, uint32_t hint_index) |
Get clone file context by chunk and block number. More... | |
int | get_next_block (uint chunk_num, uint &block_num, const Clone_file_ctx *&file_ctx, uint64_t &data_offset, byte *&data_buf, uint32_t &data_size, uint64_t &file_size) |
Get next block of data to transfer. More... | |
void | update_block_size (uint buff_size) |
Update snapshot block size based on caller's buffer size. More... | |
uint32_t | get_chunk_size () const |
uint32_t | get_blocks_per_chunk () const |
bool | is_copy () const |
Check if copy snapshot. More... | |
void | update_file_size (uint32_t file_index, uint64_t file_size) |
Update file size when file is extended during page copy. More... | |
bool | encrypt_key_in_header (const page_size_t &page_size, byte *page_data) |
Encrypt tablespace key in header page with master key. More... | |
bool | encrypt_key_in_log_header (byte *log_header, uint32_t header_len) |
Encrypt tablespace key in header page with master key. More... | |
void | decrypt_key_in_header (const Clone_File_Meta *file_meta, const page_size_t &page_size, byte *&page_data) |
Decrypt tablespace key in header page with master key. More... | |
uint32_t | get_max_blocks_pin () const |
void | skip_deleted_blocks (uint32_t chunk_num, uint32_t &block_num) |
Skip all blocks belonging to currently deleted file context. More... | |
Private Types | |
enum class | Wait_type { STATE_TRANSIT_WAIT , STATE_TRANSIT , STATE_END_PAGE_COPY , STATE_BLOCKER , DATA_FILE_WAIT , DATA_FILE_CLOSE , DDL_FILE_OPERATION } |
Various wait types related to snapshot state. More... | |
Private Member Functions | |
void | debug_wait_state_transit () |
Debug sync Wait during state transition. More... | |
bool | update_deleted_state (Clone_file_ctx *file_ctx) |
Update deleted state of a file if not yet done. More... | |
Clone_file_ctx * | get_data_file_ctx (uint32_t chunk_num, uint32_t hint_index) |
Get clone data file context by chunk number. More... | |
Clone_file_ctx * | get_page_file_ctx (uint32_t chunk_num, uint32_t block_num) |
Get clone page file context by chunk number and block number. More... | |
Clone_file_ctx * | get_redo_file_ctx (uint32_t chunk_num, uint32_t hint_index) |
Get clone redo file context by chunk number. More... | |
const char * | wait_string (Wait_type wait_type) const |
Get wait information string based on wait type. More... | |
int | wait (Wait_type type, const Clone_file_ctx *ctx, bool no_wait, bool check_intr) |
Wait for various operations based on type. More... | |
void | get_wait_mesg (Wait_type wait_type, std::string &info, std::string &error) |
During wait get relevant message string for logging. More... | |
bool | block_state_change (Clone_notify::Type type, space_id_t space, bool no_wait, bool check_intr, int &error) |
Block clone state transition. More... | |
void | unblock_state_change () |
Unblock clone state transition. More... | |
Clone_file_ctx::State | get_target_file_state (Clone_notify::Type type, bool begin) |
Get next file state while being modified by ddl. More... | |
int | begin_ddl_file (Clone_notify::Type type, space_id_t space, bool no_wait, bool check_intr) |
Handle files for DDL begin notification. More... | |
void | end_ddl_file (Clone_notify::Type type, space_id_t space) |
Handle files for DDL end notification. More... | |
int | synchronize_binlog_gtid (Clone_Alert_Func cbk) |
Synchronize snapshot with binary log and GTID. More... | |
int | update_binlog_position () |
Make sure that the trx sys page binary log position correctly reflects all transactions committed to innodb. More... | |
int | wait_for_binlog_prepared_trx () |
Wait for already prepared binlog transactions to end. More... | |
int | wait_trx_end (THD *thd, trx_id_t trx_id) |
Wait for a transaction to end. More... | |
void | begin_transit_ddl_wait () |
Begin state transition before waiting for DDL. More... | |
void | begin_transit (Snapshot_State new_state) |
Begin state transition. More... | |
void | end_transit () |
End state transition. More... | |
bool | in_transit_state () const |
Check if state transition is in progress. More... | |
bool | in_transit_wait () const |
int | init_redo_archiving () |
Start redo archiving. More... | |
int | init_file_copy (Snapshot_State new_state) |
Initialize snapshot state for file copy. More... | |
void | init_disk_estimate () |
Initialize disk byte estimate. More... | |
int | init_page_copy (Snapshot_State new_state, byte *page_buffer, uint page_buffer_len) |
Initialize snapshot state for page copy. More... | |
int | init_redo_copy (Snapshot_State new_state, Clone_Alert_Func cbk) |
Initialize snapshot state for redo copy. More... | |
int | init_apply_state (Clone_Desc_State *state_desc) |
Initialize state while applying cloned data. More... | |
int | extend_and_flush_files (bool flush_redo) |
Extend and flush files after copying data. More... | |
int | create_desc (const char *data_dir, const Clone_File_Meta *file_meta, bool is_ddl, Clone_file_ctx *&file_ctx) |
Create file descriptor and add to current file list. More... | |
Clone_file_ctx * | get_file (Clone_File_Vec &file_vector, uint32_t chunk_num, uint32_t start_index) |
Get file context for current chunk. More... | |
int | get_next_page (uint chunk_num, uint &block_num, const Clone_file_ctx *&file_ctx, uint64_t &data_offset, byte *&data_buf, uint32_t &data_size, uint64_t &file_size) |
Get next page from buffer pool. More... | |
int | get_page_for_write (const page_id_t &page_id, const page_size_t &page_size, const Clone_file_ctx *file_ctx, byte *&page_data, uint &data_size) |
Get page from buffer pool and make ready for write. More... | |
void | page_update_for_flush (const page_size_t &page_size, lsn_t page_lsn, byte *&page_data) |
Clone_file_ctx * | build_file (const char *file_name, uint64_t file_size, uint64_t file_offset, uint &num_chunks) |
Build file metadata entry. More... | |
bool | build_file_name (Clone_File_Meta *file_meta, const char *file_name) |
Allocate and set clone file name. More... | |
int | add_buf_pool_file () |
Add buffer pool dump file to the file list. More... | |
int | add_file (const char *name, uint64_t size_bytes, uint64_t alloc_bytes, fil_node_t *node, bool by_ddl) |
Add file to snapshot. More... | |
bool | file_ctx_changed (const fil_node_t *node, Clone_file_ctx *&file_ctx) |
Check if file context has been changed by ddl. More... | |
uint32_t | chunk_size () const |
Get chunk size. More... | |
uint32_t | block_size () |
Get block size for file copy. More... | |
uint32_t | blocks_per_chunk () const |
Get number of blocks per chunk for file copy. More... | |
int | update_sys_file_name (bool replace, const Clone_File_Meta *file_meta, std::string &file_name) |
Update system file name from configuration. More... | |
int | build_file_path (const char *data_dir, const Clone_File_Meta *file_desc, std::string &file_path) |
Build file name along with path for cloned data files. More... | |
int | build_file_ctx (Clone_file_ctx::Extension extn, const Clone_File_Meta *file_meta, const std::string &file_path, Clone_file_ctx *&file_ctx) |
Build file context from file path. More... | |
int | handle_existing_file (bool replace, bool undo_file, bool redo_file, uint32_t data_file_index, const std::string &data_file, Clone_file_ctx::Extension &extn) |
Check for existing file and if clone extension is needed. More... | |
size_t | num_data_files () const |
size_t | num_redo_files () const |
Private Attributes | |
Snapshot type and ID | |
Clone_Handle_Type | m_snapshot_handle_type |
Snapshot handle type. More... | |
Ha_clone_type | m_snapshot_type |
Clone type. More... | |
uint64_t | m_snapshot_id |
Unique snapshot ID. More... | |
uint | m_snapshot_arr_idx |
Index in global snapshot array. More... | |
Snapshot State <br> | |
ib_mutex_t | m_snapshot_mutex |
Mutex to handle access by concurrent clones. More... | |
uint32_t | m_num_blockers |
Number of blockers for state change. More... | |
bool | m_aborted |
Set to true only if clone is aborted after error. More... | |
uint | m_num_clones |
Number of clones attached to this snapshot. More... | |
uint | m_num_clones_transit |
Number of clones in in state transition. More... | |
Snapshot_State | m_snapshot_state |
Current state. More... | |
Snapshot_State | m_snapshot_next_state |
Next state to move to. More... | |
Snapshot data block | |
mem_heap_t * | m_snapshot_heap |
Memory allocation heap. More... | |
uint | m_chunk_size_pow2 |
Chunk size in power of 2. More... | |
uint | m_block_size_pow2 |
Block size in power of 2. More... | |
uint | m_num_current_chunks |
Number of chunks in current state. More... | |
size_t | m_max_file_name_len |
Maximum file name length observed till now. More... | |
Snapshot file data | |
Clone_File_Vec | m_data_file_vector |
All data files for transfer. More... | |
Clone_File_Map | m_data_file_map |
Map space ID to file vector index. More... | |
uint | m_num_data_chunks |
Total number of data chunks. More... | |
uint64_t | m_data_bytes_disk |
Number of bytes on disk. More... | |
std::vector< int > | m_undo_file_indexes |
Index into m_data_file_vector for all undo files. More... | |
Snapshot page data | |
Page_Arch_Client_Ctx | m_page_ctx |
Page archiver client. More... | |
Clone_Page_Set | m_page_set |
Set of unique page IDs. More... | |
Clone_Page_Vec | m_page_vector |
Sorted page IDs to transfer. More... | |
uint | m_num_pages |
Number of pages to transfer. More... | |
uint | m_num_duplicate_pages |
Number of duplicate pages found. More... | |
Snapshot redo data | |
Log_Arch_Client_Ctx | m_redo_ctx |
redo log archiver client More... | |
Clone_File_Vec | m_redo_file_vector |
All archived redo files to transfer. More... | |
uint64_t | m_redo_start_offset |
Start offset in first redo file. More... | |
byte * | m_redo_header |
Redo header block. More... | |
uint | m_redo_header_size |
Redo header size. More... | |
byte * | m_redo_trailer |
Redo trailer block. More... | |
uint | m_redo_trailer_size |
Redo trailer size. More... | |
uint64_t | m_redo_trailer_offset |
Redo trailer block offset. More... | |
uint64_t | m_redo_file_size |
Archived redo file size. More... | |
uint | m_num_redo_chunks |
Total number of redo data chunks. More... | |
bool | m_enable_pfs |
Enable PFS monitoring. More... | |
Clone_Monitor | m_monitor |
Performance Schema accounting object to monitor stage progress. More... | |
Static Private Attributes | |
static const uint32_t | S_MAX_PAGES_PIN = 64 |
Allow DDL file operation after 64 pages. More... | |
static const uint32_t | S_MAX_BLOCKS_PIN = 1 |
Allow DDL file operation after every block (1M data by default) More... | |
static const size_t | S_FILE_NAME_BASE_LEN = 256 |
File name allocation size base. More... | |
Dynamic database snapshot: Holds metadata and handle to data.
using Clone_Snapshot::File_Cbk_Func = std::function<int(Clone_file_ctx *)> |
|
strongprivate |
Clone_Snapshot::Clone_Snapshot | ( | Clone_Handle_Type | hdl_type, |
Ha_clone_type | clone_type, | ||
uint | arr_idx, | ||
uint64_t | snap_id | ||
) |
Construct snapshot.
[in] | hdl_type | copy, apply |
[in] | clone_type | clone type |
[in] | arr_idx | index in global array |
[in] | snap_id | unique snapshot ID |
Clone_Snapshot::~Clone_Snapshot | ( | ) |
Release contexts and free heap.
|
private |
Add buffer pool dump file to the file list.
|
private |
Add file to snapshot.
[in] | name | file name |
[in] | size_bytes | file size in bytes |
[in] | alloc_bytes | allocation size on disk for sparse file |
[in] | node | file node |
[in] | by_ddl | node is added concurrently by DDL |
bool Clone_Snapshot::add_file_from_desc | ( | Clone_file_ctx *& | file_ctx, |
bool | ddl_create | ||
) |
Add file descriptor to file list.
[in,out] | file_ctx | current file context |
[in] | ddl_create | added by DDL concurrently |
Check if it the last file
dberr_t Clone_Snapshot::add_node | ( | fil_node_t * | node, |
bool | by_ddl | ||
) |
Extract file information from node and add to snapshot.
[in] | node | file node |
[in] | by_ddl | node is added concurrently by DDL |
int Clone_Snapshot::add_page | ( | uint32_t | space_id, |
uint32_t | page_num | ||
) |
Add page ID to to the set of pages in snapshot.
[in] | space_id | page tablespace |
[in] | page_num | page number within tablespace |
int Clone_Snapshot::add_redo_file | ( | char * | file_name, |
uint64_t | file_size, | ||
uint64_t | file_offset | ||
) |
Add redo file to snapshot.
[in] | file_name | file name |
[in] | file_size | file size in bytes |
[in] | file_offset | start offset |
bool Clone_Snapshot::attach | ( | Clone_Handle_Type | hdl_type, |
bool | pfs_monitor | ||
) |
Try to attach to snapshot.
[in] | hdl_type | copy, apply |
[in] | pfs_monitor | enable PFS monitoring |
|
private |
Handle files for DDL begin notification.
[in] | type | type of DDL notification |
[in] | space | space ID for the ddl operation |
[in] | no_wait | return with error if needs to wait |
[in] | check_intr | check for interrupt during wait |
bool Clone_Snapshot::begin_ddl_state | ( | Clone_notify::Type | type, |
space_id_t | space, | ||
bool | no_wait, | ||
bool | check_intr, | ||
int & | error | ||
) |
DDL notification before the operation.
[in] | type | type of DDL notification |
[in] | space | space ID for the ddl operation |
[in] | no_wait | return with error if needs to wait |
[in] | check_intr | check for interrupt during wait |
[out] | error | mysql error code |
|
inlineprivate |
Begin state transition.
[in] | new_state | state to transit to |
|
inlineprivate |
Begin state transition before waiting for DDL.
|
inlineprivate |
Get block size for file copy.
|
private |
Block clone state transition.
Clone must wait.
[in] | type | type of DDL notification |
[in] | space | space ID for the ddl operation |
[in] | no_wait | return with error if needs to wait |
[in] | check_intr | check for interrupt during wait` |
[out] | error | mysql error code |
bool Clone_Snapshot::blocks_clone | ( | const Clone_file_ctx * | file_ctx | ) |
Check if DDL needs to block clone operation.
[in] | file_ctx | file context |
|
inlineprivate |
Get number of blocks per chunk for file copy.
|
private |
Build file metadata entry.
[in] | file_name | name of the file |
[in] | file_size | file size in bytes |
[in] | file_offset | start offset |
[in] | num_chunks | total number of chunks in the file |
|
private |
Build file context from file path.
[in] | extn | file extension type |
[in] | file_meta | file descriptor |
[in] | file_path | data file along with path |
[out] | file_ctx | created file context |
|
private |
Allocate and set clone file name.
[in,out] | file_meta | file metadata |
[in] | file_name | file name |
|
private |
Build file name along with path for cloned data files.
[in] | data_dir | clone data directory |
[in] | file_desc | file descriptor |
[out] | file_path | built file path if returned 0 |
int Clone_Snapshot::change_state | ( | Clone_Desc_State * | state_desc, |
Snapshot_State | new_state, | ||
byte * | temp_buffer, | ||
uint | temp_buffer_len, | ||
Clone_Alert_Func | cbk | ||
) |
Start transition to new state.
[in] | state_desc | descriptor for next state |
[in] | new_state | state to move for apply |
[in] | temp_buffer | buffer used for collecting page IDs |
[in] | temp_buffer_len | buffer length |
[in] | cbk | alter callback for long wait |
|
inlineprivate |
Get chunk size.
|
private |
Create file descriptor and add to current file list.
[in] | data_dir | destination data directory |
[in] | file_meta | file metadata from donor |
[in] | is_ddl | if ddl temporary file |
[out] | file_ctx | file context |
|
private |
Debug sync Wait during state transition.
void Clone_Snapshot::decrypt_key_in_header | ( | const Clone_File_Meta * | file_meta, |
const page_size_t & | page_size, | ||
byte *& | page_data | ||
) |
Decrypt tablespace key in header page with master key.
[in] | file_meta | clone file metadata |
[in] | page_size | page size descriptor |
[in,out] | page_data | page data to update |
void Clone_Snapshot::detach | ( | ) |
Detach from snapshot.
bool Clone_Snapshot::encrypt_key_in_header | ( | const page_size_t & | page_size, |
byte * | page_data | ||
) |
Encrypt tablespace key in header page with master key.
[in] | page_size | page size descriptor |
[in,out] | page_data | page data to update |
bool Clone_Snapshot::encrypt_key_in_log_header | ( | byte * | log_header, |
uint32_t | header_len | ||
) |
Encrypt tablespace key in header page with master key.
[in,out] | log_header | page data to update |
[in] | header_len | length of log header |
|
private |
Handle files for DDL end notification.
[in] | type | type of DDL notification |
[in] | space | space ID for the ddl operation |
void Clone_Snapshot::end_ddl_state | ( | Clone_notify::Type | type, |
space_id_t | space | ||
) |
DDL notification after the operation.
[in] | type | type of DDL notification |
[in] | space | space ID for the ddl operation |
|
inlineprivate |
End state transition.
|
private |
Extend and flush files after copying data.
[in] | flush_redo | if true flush redo, otherwise data |
|
private |
Check if file context has been changed by ddl.
[in] | node | tablespace file node |
[out] | file_ctx | file context if exists |
int Clone_Snapshot::fix_ddl_extension | ( | const char * | data_dir, |
Clone_file_ctx * | file_ctx | ||
) |
Fix files renamed with ddl extension.
The file name is checked against existing file and added to appropriate status file.
[in] | data_dir | destination data directory |
[in,out] | file_ctx | Set to correct extension |
uint32_t Clone_Snapshot::get_blocks_per_chunk | ( | ) | const |
|
inline |
|
inline |
Get performance schema accounting object used to monitor stage progress.
|
private |
Get clone data file context by chunk number.
[in] | chunk_num | chunk number |
[in] | hint_index | hint file index number to start search. |
|
inline |
|
inline |
Get maximum buffer size required for clone.
|
private |
Get file context for current chunk.
[in] | file_vector | clone file vector |
[in] | chunk_num | current chunk number |
[in] | start_index | index for starting the search |
Clone_File_Meta * Clone_Snapshot::get_file_by_index | ( | uint | index | ) |
Get file metadata by index for current state.
[in] | index | file index |
Clone_file_ctx * Clone_Snapshot::get_file_ctx | ( | uint32_t | chunk_num, |
uint32_t | block_num, | ||
uint32_t | hint_index | ||
) |
Get clone file context by chunk and block number.
[in] | chunk_num | chunk number |
[in] | block_num | block number |
[in] | hint_index | hint file index number to start search. |
Clone_file_ctx * Clone_Snapshot::get_file_ctx_by_index | ( | uint | index | ) |
Get clone file context by index for current state.
[in] | index | file index |
int Clone_Snapshot::get_file_from_desc | ( | const Clone_File_Meta * | file_meta, |
const char * | data_dir, | ||
bool | desc_create, | ||
bool & | desc_exists, | ||
Clone_file_ctx *& | file_ctx | ||
) |
Add file metadata entry at destination.
[in] | file_meta | file metadata from donor |
[in] | data_dir | destination data directory |
[in] | desc_create | create if doesn't exist |
[out] | desc_exists | descriptor already exists |
[out] | file_ctx | if there, set to current file context |
|
inline |
Get unique snapshot identifier.
|
inline |
Get snapshot index in global array.
uint32_t Clone_Snapshot::get_max_blocks_pin | ( | ) | const |
|
inline |
Get maximum file length seen till now.
int Clone_Snapshot::get_next_block | ( | uint | chunk_num, |
uint & | block_num, | ||
const Clone_file_ctx *& | file_ctx, | ||
uint64_t & | data_offset, | ||
byte *& | data_buf, | ||
uint32_t & | data_size, | ||
uint64_t & | file_size | ||
) |
Get next block of data to transfer.
[in] | chunk_num | current chunk |
[in,out] | block_num | current/next block |
[in,out] | file_ctx | current/next block file context |
[out] | data_offset | block offset in file |
[out] | data_buf | data buffer or NULL if transfer from file |
[out] | data_size | size of data in bytes |
[out] | file_size | updated file size if extended |
|
private |
Get next page from buffer pool.
[in] | chunk_num | current chunk |
[in,out] | block_num | current, next block |
[in,out] | file_ctx | current, next block file context |
[out] | data_offset | offset in file |
[out] | data_buf | page data |
[out] | data_size | page data size |
[out] | file_size | updated file size if extended |
Snapshot_State Clone_Snapshot::get_next_state | ( | ) |
Get next state based on snapshot type.
|
inline |
Get total number of chunks for current state.
|
private |
Get clone page file context by chunk number and block number.
[in] | chunk_num | chunk number |
[in] | block_num | block number |
|
private |
Get page from buffer pool and make ready for write.
[in] | page_id | page ID chunk |
[in] | page_size | page size descriptor |
[in] | file_ctx | clone file context |
[out] | page_data | data page |
[out] | data_size | page size in bytes |
|
private |
Get clone redo file context by chunk number.
[in] | chunk_num | chunk number |
[in] | hint_index | hint file index number to start search. |
|
inline |
Get the redo file size for the snapshot.
|
inline |
Get snapshot state.
void Clone_Snapshot::get_state_info | ( | bool | do_estimate, |
Clone_Desc_State * | state_desc | ||
) |
Fill state descriptor from snapshot.
[in] | do_estimate | estimate data bytes to transfer |
[out] | state_desc | snapshot state descriptor |
|
private |
Get next file state while being modified by ddl.
[in] | type | ddl notification type |
[in] | begin | true, if DDL begin notification false, if DDL end notification |
|
private |
During wait get relevant message string for logging.
[in] | wait_type | wait type |
[out] | info | notification to log while waiting |
[out] | error | error message to log on timeout |
|
private |
Check for existing file and if clone extension is needed.
This function has the side effect to add undo file indexes.
[in] | replace | if data directory is replaced |
[in] | undo_file | if undo tablespace file |
[in] | redo_file | if redo file |
[in] | data_file_index | index of file |
[in] | data_file | data file name |
[out] | extn | file extension needs to be used |
|
inlineprivate |
Check if state transition is in progress.
|
inlineprivate |
|
private |
Initialize state while applying cloned data.
[in] | state_desc | snapshot state descriptor |
|
inlineprivate |
Initialize disk byte estimate.
|
private |
Initialize snapshot state for file copy.
[in] | new_state | state to move for apply |
|
private |
Initialize snapshot state for page copy.
[in] | new_state | state to move for apply |
[in] | page_buffer | temporary buffer to copy page IDs |
[in] | page_buffer_len | buffer length |
|
private |
Start redo archiving.
|
private |
Initialize snapshot state for redo copy.
[in] | new_state | state to move for apply |
[in] | cbk | alert callback for long wait |
bool Clone_Snapshot::is_aborted | ( | ) | const |
|
inline |
Check if copy snapshot.
int Clone_Snapshot::iterate_data_files | ( | File_Cbk_Func && | func | ) |
Iterate through all data files.
[in] | func | callback function |
int Clone_Snapshot::iterate_files | ( | File_Cbk_Func && | func | ) |
Iterate through all files in current state.
[in] | func | callback function |
int Clone_Snapshot::iterate_redo_files | ( | File_Cbk_Func && | func | ) |
Iterate through all redo files.
[in] | func | callback function |
|
inline |
Get snapshot heap used for allocation during clone.
|
inlineprivate |
|
inlineprivate |
|
private |
int Clone_Snapshot::pin_file | ( | Clone_file_ctx * | file_ctx, |
bool & | handle_delete | ||
) |
Wait for concurrent DDL file operation and pin file.
[in,out] | file_ctx | file context |
[out] | handle_delete | if caller needs to handle deleted state |
|
inline |
int Clone_Snapshot::rename_desc | ( | const Clone_File_Meta * | file_meta, |
const char * | data_dir, | ||
Clone_file_ctx *& | file_ctx | ||
) |
Rename an existing file descriptor.
[in] | file_meta | renamed file metadata from donor |
[in] | data_dir | destination data directory |
[out] | file_ctx | if there, set to current file context |
void Clone_Snapshot::set_abort | ( | ) |
Set current snapshot aborted state.
Used in error cases before exiting clone to make sure any DDL notifier exits waiting.
void Clone_Snapshot::set_state_info | ( | Clone_Desc_State * | state_desc | ) |
Set state information during apply.
[in] | state_desc | snapshot state descriptor |
void Clone_Snapshot::skip_deleted_blocks | ( | uint32_t | chunk_num, |
uint32_t & | block_num | ||
) |
Skip all blocks belonging to currently deleted file context.
[in] | chunk_num | current chunk |
[in,out] | block_num | current, next block |
|
private |
Synchronize snapshot with binary log and GTID.
[in] | cbk | alert callback for long wait |
|
inlineprivate |
Unblock clone state transition.
|
inline |
Unpin a file.
[in,out] | file_ctx | file context |
|
private |
Make sure that the trx sys page binary log position correctly reflects all transactions committed to innodb.
It updates binary log position in transaction sys page, if required. The caller must ensure that any new transaction is committed in order of binary log.
void Clone_Snapshot::update_block_size | ( | uint | buff_size | ) |
Update snapshot block size based on caller's buffer size.
[in] | buff_size | buffer size for clone transfer |
|
private |
Update deleted state of a file if not yet done.
[in,out] | file_ctx | file context |
void Clone_Snapshot::update_file_size | ( | uint32_t | file_index, |
uint64_t | file_size | ||
) |
Update file size when file is extended during page copy.
[in] | file_index | current file index |
[in] | file_size | new file size |
|
private |
Update system file name from configuration.
[in] | replace | if replacing current data directory |
[in] | file_meta | file descriptor |
[in,out] | file_name | file name to update |
|
private |
Wait for various operations based on type.
[in] | type | wait type |
[in] | ctx | file context when relevant |
[in] | no_wait | return with error if needs to wait |
[in] | check_intr | check for interrupt during wait |
|
private |
Wait for already prepared binlog transactions to end.
|
private |
Get wait information string based on wait type.
[in] | wait_type | wait type |
Wait for a transaction to end.
[in] | thd | current THD |
[in] | trx_id | transaction to wait for |
|
private |
Set to true only if clone is aborted after error.
|
private |
Block size in power of 2.
|
private |
Chunk size in power of 2.
|
private |
Number of bytes on disk.
|
private |
Map space ID to file vector index.
|
private |
All data files for transfer.
|
private |
Enable PFS monitoring.
|
private |
Maximum file name length observed till now.
|
private |
Performance Schema accounting object to monitor stage progress.
|
private |
Number of blockers for state change.
Usually DDLs for short duration.
|
private |
Number of clones attached to this snapshot.
|
private |
Number of clones in in state transition.
|
private |
Number of chunks in current state.
|
private |
Total number of data chunks.
|
private |
Number of duplicate pages found.
|
private |
Number of pages to transfer.
|
private |
Total number of redo data chunks.
|
private |
Page archiver client.
|
private |
Set of unique page IDs.
|
private |
Sorted page IDs to transfer.
|
private |
redo log archiver client
|
private |
Archived redo file size.
|
private |
All archived redo files to transfer.
|
private |
Redo header block.
|
private |
Redo header size.
|
private |
Start offset in first redo file.
|
private |
Redo trailer block.
|
private |
Redo trailer block offset.
|
private |
Redo trailer size.
|
private |
Index in global snapshot array.
|
private |
Snapshot handle type.
|
private |
Memory allocation heap.
|
private |
Unique snapshot ID.
|
mutableprivate |
Mutex to handle access by concurrent clones.
|
private |
Next state to move to.
Set only during state transfer.
|
private |
Current state.
|
private |
Clone type.
|
private |
Index into m_data_file_vector for all undo files.
|
staticprivate |
File name allocation size base.
|
staticprivate |
Allow DDL file operation after every block (1M data by default)
|
staticprivate |
Allow DDL file operation after 64 pages.