MySQL 8.0.40
Source Code Documentation
|
Clone Handle for copying or applying data. More...
#include <clone0clone.h>
Public Member Functions | |
Clone_Handle (Clone_Handle_Type handle_type, uint clone_version, uint clone_index) | |
Construct clone handle. More... | |
~Clone_Handle () | |
Destructor: Detach from snapshot. More... | |
int | init (const byte *ref_loc, uint ref_len, Ha_clone_type type, const char *data_dir) |
Initialize clone handle. More... | |
void | attach () |
Attach to the clone handle. More... | |
uint | detach () |
Detach from the clone handle. More... | |
byte * | get_locator (uint &loc_len) |
Get locator for the clone handle. More... | |
const char * | get_datadir () const |
bool | replace_datadir () const |
void | build_descriptor (Clone_Desc_Locator *loc_desc) |
Build locator descriptor for the clone handle. More... | |
int | add_task (THD *thd, const byte *ref_loc, uint ref_len, uint &task_id) |
Add a task to clone handle. More... | |
bool | drop_task (THD *thd, uint task_id, bool &is_master) |
Drop task from clone handle. More... | |
void | save_error (int err) |
Save current error number. More... | |
int | check_error (THD *thd) |
Check for error from other tasks and DDL. More... | |
bool | is_interrupted () |
uint | get_index () |
Get clone handle index in clone array. More... | |
uint | get_version () |
Get clone data descriptor version. More... | |
Clone_Snapshot * | get_snapshot () |
bool | is_copy_clone () const |
Check if it is copy clone. More... | |
bool | match_hdl_type (Clone_Handle_Type other_handle_type) |
Check if clone type matches. More... | |
void | set_state (Clone_Handle_State state) |
Set current clone state. More... | |
void | set_abort () |
Set clone to ABORT state end any attached snapshot. More... | |
bool | is_active () |
Check if clone state is active. More... | |
bool | is_init () |
Check if clone is initialized. More... | |
bool | is_idle () |
Check if clone is idle waiting for restart. More... | |
bool | is_abort () |
Check if clone is aborted. More... | |
int | restart_copy (THD *thd, const byte *loc, uint loc_len) |
Restart copy after a network failure. More... | |
int | restart_apply (THD *thd, const byte *&loc, uint &loc_len) |
Build locator with current state and restart apply. More... | |
int | copy (uint task_id, Ha_clone_cbk *callback) |
Transfer snapshot data via callback. More... | |
int | apply (THD *thd, uint task_id, Ha_clone_cbk *callback) |
Apply snapshot data received via callback. More... | |
int | send_keep_alive (Clone_Task *task, Ha_clone_cbk *callback) |
Send keep alive while during long wait. More... | |
bool | abort_by_ddl () const |
void | set_ddl_abort () |
Allow concurrent DDL to abort clone. More... | |
void | close_master_file () |
Close master task file if open and unpin. More... | |
Private Types | |
using | File_init_cbk = std::function< dberr_t(pfs_os_file_t)> |
Private Member Functions | |
int | check_space (const Clone_Task *task) |
Check if enough space is there to clone. More... | |
int | create_clone_directory () |
Create clone data directory. More... | |
void | display_progress (uint32_t cur_chunk, uint32_t max_chunk, uint32_t &percent_done, std::chrono::steady_clock::time_point &disp_time) |
Display clone progress. More... | |
int | file_create_init (const Clone_file_ctx *file_ctx, ulint file_type, bool init) |
Create a tablespace file and initialize. More... | |
int | open_file (Clone_Task *task, const Clone_file_ctx *file_ctx, ulint file_type, bool create_file, File_init_cbk &init_cbk) |
Open file for the task. More... | |
int | close_file (Clone_Task *task) |
Close file for the task. More... | |
int | check_and_pin_file (Clone_Task *task, Clone_file_ctx *file_ctx, bool &handle_deleted) |
Check and pin a file context if not already pinned. More... | |
int | close_and_unpin_file (Clone_Task *task) |
Unpin and close currently pinned file. More... | |
std::tuple< bool, bool > | pins_file (const Clone_Task *task, const Clone_file_ctx *file_ctx) |
Check if the task pins a file context. More... | |
int | file_callback (Ha_clone_cbk *cbk, Clone_Task *task, uint len, bool buf_cbk, uint64_t offset, ut::Location location) |
Callback providing the file reference and data length to copy. More... | |
int | move_to_next_state (Clone_Task *task, Ha_clone_cbk *callback, Clone_Desc_State *state_desc) |
Move to next state. More... | |
int | send_state_metadata (Clone_Task *task, Ha_clone_cbk *callback, bool is_start) |
Send current state information via callback. More... | |
int | send_task_metadata (Clone_Task *task, Ha_clone_cbk *callback) |
Send current task information via callback. More... | |
int | send_all_ddl_metadata (Clone_Task *task, Ha_clone_cbk *callback) |
Send all DDL metadata generated. More... | |
int | send_all_file_metadata (Clone_Task *task, Ha_clone_cbk *callback) |
Send all file information via callback. More... | |
int | send_file_metadata (Clone_Task *task, const Clone_File_Meta *file_meta, bool is_redo, Ha_clone_cbk *callback) |
Send current file information via callback. More... | |
int | send_data (Clone_Task *task, const Clone_file_ctx *file_ctx, uint64_t offset, byte *buffer, uint32_t size, uint64_t new_file_size, Ha_clone_cbk *callback) |
Send cloned data via callback. More... | |
int | process_chunk (Clone_Task *task, uint32_t chunk_num, uint32_t block_num, Ha_clone_cbk *callback) |
Process a data chunk and send data blocks via callback. More... | |
int | apply_task_metadata (Clone_Task *task, Ha_clone_cbk *callback) |
Create apply task based on task metadata in callback. More... | |
int | ack_state_metadata (Clone_Task *task, Ha_clone_cbk *callback, Clone_Desc_State *state_desc) |
Move to next state based on state metadata and set state information. More... | |
void | notify_state_change (Clone_Task *task, Ha_clone_cbk *callback, Clone_Desc_State *state_desc) |
Notify state change via callback. More... | |
int | apply_state_metadata (Clone_Task *task, Ha_clone_cbk *callback) |
Move to next state based on state metadata and set state information. More... | |
int | apply_file_metadata (Clone_Task *task, Ha_clone_cbk *callback) |
Create file metadata based on callback. More... | |
int | apply_file_delete (Clone_Task *task, Clone_file_ctx *file_ctx, const Clone_File_Meta *new_meta) |
Apply DDL delete to existing file to update chunk and block information. More... | |
int | apply_ddl (const Clone_File_Meta *new_meta, Clone_file_ctx *file_ctx) |
Apply DDL changes to file at the end of FILE_COPY stage. More... | |
int | set_compression (Clone_file_ctx *file_ctx) |
Set compression type based on local capability. More... | |
int | fix_all_renamed (const Clone_Task *task) |
Fix the file name and meta information for all files that are renamed with DDL extension. More... | |
int | apply_data (Clone_Task *task, Ha_clone_cbk *callback) |
Apply data received via callback. More... | |
int | receive_data (Clone_Task *task, uint64_t offset, uint64_t file_size, uint32_t size, Ha_clone_cbk *callback) |
Receive data from callback and apply. More... | |
bool | read_compressed_len (unsigned char *buffer, uint32_t len, uint32_t block_size, uint32_t &compressed_len) |
Read compressed length from the page. More... | |
int | sparse_file_write (Clone_File_Meta *file_meta, unsigned char *buffer, uint32_t len, pfs_os_file_t file, uint64_t start_off) |
Write pages to file and punch holes. More... | |
int | modify_and_write (const Clone_Task *task, uint64_t offset, unsigned char *buffer, uint32_t buf_len) |
Modify page encryption attribute and/or punch hole. More... | |
Private Attributes | |
Clone_Handle_Type | m_clone_handle_type |
Clone handle type: Copy, Apply. More... | |
Clone_Handle_State | m_clone_handle_state |
Clone handle state. More... | |
byte | m_version_locator [CLONE_DESC_MAX_BASE_LEN] |
Fixed locator for version negotiation. More... | |
byte * | m_clone_locator |
Serialized locator. More... | |
uint | m_locator_length |
Locator length in bytes. More... | |
byte * | m_restart_loc |
Serialized Restart locator. More... | |
uint | m_restart_loc_len |
Restart locator length in bytes. More... | |
uint | m_clone_desc_version |
Clone descriptor version in use. More... | |
uint | m_clone_arr_index |
Index in global array. More... | |
uint64_t | m_clone_id |
Unique clone identifier. More... | |
uint | m_ref_count |
Reference count. More... | |
bool | m_allow_restart |
Allow restart of clone operation after network failure. More... | |
bool | m_abort_ddl |
If concurrent DDL should abort clone. More... | |
const char * | m_clone_dir |
Clone data directory. More... | |
Clone_Task_Manager | m_clone_task_manager |
Clone task manager. More... | |
Clone Handle for copying or applying data.
|
private |
Clone_Handle::Clone_Handle | ( | Clone_Handle_Type | handle_type, |
uint | clone_version, | ||
uint | clone_index | ||
) |
Construct clone handle.
[in] | handle_type | clone handle type |
[in] | clone_version | clone version |
[in] | clone_index | index in clone array |
Clone_Handle::~Clone_Handle | ( | ) |
Destructor: Detach from snapshot.
|
inline |
|
private |
Move to next state based on state metadata and set state information.
[in] | task | current task |
[in,out] | callback | callback interface |
[in,out] | state_desc | clone state descriptor |
Add a task to clone handle.
[in] | thd | server THD object |
[in] | ref_loc | reference locator from remote |
[in] | ref_len | reference locator length |
[out] | task_id | task identifier |
int Clone_Handle::apply | ( | THD * | thd, |
uint | task_id, | ||
Ha_clone_cbk * | callback | ||
) |
Apply snapshot data received via callback.
[in] | thd | server THD |
[in] | task_id | current task ID |
[in] | callback | user callback interface |
|
private |
Apply data received via callback.
[in] | task | current task |
[in] | callback | callback interface |
|
private |
Apply DDL changes to file at the end of FILE_COPY stage.
[in] | new_meta | new file metadata |
[in,out] | file_ctx | current file context |
|
private |
Apply DDL delete to existing file to update chunk and block information.
[in,out] | task | task performing the operation |
[in,out] | file_ctx | current file context |
[in] | new_meta | new file metadata |
|
private |
Create file metadata based on callback.
[in] | task | current task |
[in] | callback | callback interface |
|
private |
Move to next state based on state metadata and set state information.
[in] | task | current task |
[in] | callback | callback interface |
Notify state change via callback.
|
private |
Create apply task based on task metadata in callback.
[in] | task | current task |
[in] | callback | callback interface |
|
inline |
Attach to the clone handle.
void Clone_Handle::build_descriptor | ( | Clone_Desc_Locator * | loc_desc | ) |
Build locator descriptor for the clone handle.
[out] | loc_desc | locator descriptor |
|
private |
Check and pin a file context if not already pinned.
[in,out] | task | clone task |
[in,out] | file_ctx | snapshot file context |
[out] | handle_deleted | true, iff caller needs to handle deleted file state |
|
inline |
Check for error from other tasks and DDL.
[in,out] | thd | session THD |
|
private |
Check if enough space is there to clone.
[in] | task | current task |
|
private |
Unpin and close currently pinned file.
[in,out] | task | clone task |
|
private |
Close file for the task.
[in] | task | clone task |
void Clone_Handle::close_master_file | ( | ) |
Close master task file if open and unpin.
int Clone_Handle::copy | ( | uint | task_id, |
Ha_clone_cbk * | callback | ||
) |
Transfer snapshot data via callback.
[in] | task_id | current task ID |
[in] | callback | user callback interface |
|
private |
Create clone data directory.
|
inline |
Detach from the clone handle.
|
private |
Display clone progress.
[in] | cur_chunk | current chunk number |
[in] | max_chunk | total number of chunks |
[in,out] | percent_done | percentage completed |
[in,out] | disp_time | last displayed time |
Drop task from clone handle.
[in] | thd | server THD object |
[in] | task_id | current task ID |
[out] | is_master | true, if master task |
|
private |
Callback providing the file reference and data length to copy.
[in] | cbk | callback interface |
[in] | task | clone task |
[in] | len | data length |
[in] | buf_cbk | invoke buffer callback |
[in] | offset | file offset |
[in] | location | location where func invoked |
|
private |
Create a tablespace file and initialize.
[in] | file_ctx | file information |
[in] | file_type | file type (data, log etc.) |
[in] | init | true, if needs to write initial pages. |
|
private |
Fix the file name and meta information for all files that are renamed with DDL extension.
[in] | task | current task |
|
inline |
|
inline |
Get clone handle index in clone array.
Get locator for the clone handle.
[out] | loc_len | serialized locator length |
|
inline |
|
inline |
Get clone data descriptor version.
int Clone_Handle::init | ( | const byte * | ref_loc, |
uint | ref_len, | ||
Ha_clone_type | type, | ||
const char * | data_dir | ||
) |
Initialize clone handle.
[in] | ref_loc | reference locator |
[in] | ref_len | reference locator length |
[in] | type | clone type |
[in] | data_dir | data directory for apply |
|
inline |
Check if clone is aborted.
|
inline |
Check if clone state is active.
|
inline |
Check if it is copy clone.
|
inline |
Check if clone is idle waiting for restart.
|
inline |
Check if clone is initialized.
|
inline |
|
inline |
Check if clone type matches.
[in] | other_handle_type | type to match with |
|
private |
Modify page encryption attribute and/or punch hole.
[in] | task | task that is applying data |
[in] | offset | file offset for applying data |
[in,out] | buffer | data to apply |
[in] | buf_len | data buffer length |
|
private |
Move to next state.
[in] | task | clone task |
[in] | callback | callback interface |
[in] | state_desc | descriptor for next state to move to |
|
private |
Notify state change via callback.
[in] | task | current task |
[in,out] | callback | callback interface |
[in,out] | state_desc | clone state descriptor |
|
private |
Open file for the task.
[in] | task | clone task |
[in] | file_ctx | file information |
[in] | file_type | file type (data, log etc.) |
[in] | create_file | create if not present |
[in] | init_cbk | callback to fill initial data |
|
private |
Check if the task pins a file context.
[in] | task | clone task |
[in] | file_ctx | snapshot file context |
|
private |
Process a data chunk and send data blocks via callback.
[in] | task | task that is sending the information |
[in] | chunk_num | chunk number to process |
[in] | block_num | start block number |
[in] | callback | callback interface |
|
private |
Read compressed length from the page.
[in] | buffer | data buffer |
[in] | len | buffer length |
[in] | block_size | block size |
[out] | compressed_len | compressed length |
|
private |
Receive data from callback and apply.
[in] | task | task that is receiving the information |
[in] | offset | file offset for applying data |
[in] | file_size | updated file size |
[in] | size | data length in bytes |
[in] | callback | callback interface |
|
inline |
Build locator with current state and restart apply.
[in] | thd | server THD object |
[in,out] | loc | loctor with current state information |
[in,out] | loc_len | locator length in bytes |
Restart copy after a network failure.
[in] | thd | server THD object |
[in] | loc | locator with copy state from remote client |
[in] | loc_len | locator length in bytes |
|
inline |
Save current error number.
[in] | err | error number |
|
private |
Send all DDL metadata generated.
[in] | task | task that is sending the information |
[in] | callback | callback interface |
|
private |
Send all file information via callback.
[in] | task | task that is sending the information |
[in] | callback | callback interface |
|
private |
Send cloned data via callback.
[in] | task | task that is sending the information |
[in] | file_ctx | file information |
[in] | offset | file offset |
[in] | buffer | data buffer or NULL if send from file |
[in] | size | data buffer size |
[in] | new_file_size | updated file size from page 0 |
[in] | callback | callback interface |
|
private |
Send current file information via callback.
[in] | task | task that is sending the information |
[in] | file_meta | file meta information |
[in] | is_redo | true if redo file |
[in] | callback | callback interface |
int Clone_Handle::send_keep_alive | ( | Clone_Task * | task, |
Ha_clone_cbk * | callback | ||
) |
Send keep alive while during long wait.
[in] | task | task that is sending the information |
[in] | callback | callback interface |
|
private |
Send current state information via callback.
[in] | task | task that is sending the information |
[in] | callback | callback interface |
[in] | is_start | if it is the start of current state |
|
private |
Send current task information via callback.
[in] | task | task that is sending the information |
[in] | callback | callback interface |
void Clone_Handle::set_abort | ( | ) |
Set clone to ABORT state end any attached snapshot.
|
private |
Set compression type based on local capability.
[in,out] | file_ctx | file context |
|
inline |
Allow concurrent DDL to abort clone.
|
inline |
Set current clone state.
[in] | state | clone handle state |
|
private |
Write pages to file and punch holes.
[in] | file_meta | clone file metadata |
[in] | buffer | data buffer |
[in] | len | buffer length |
[in] | file | file descriptor |
[in] | start_off | starting offset in file |
|
private |
If concurrent DDL should abort clone.
|
private |
Allow restart of clone operation after network failure.
|
private |
Index in global array.
|
private |
Clone descriptor version in use.
|
private |
Clone data directory.
|
private |
Clone handle state.
|
private |
Clone handle type: Copy, Apply.
|
private |
Unique clone identifier.
|
private |
Serialized locator.
|
private |
Clone task manager.
|
private |
Locator length in bytes.
|
private |
Reference count.
|
private |
Serialized Restart locator.
|
private |
Restart locator length in bytes.
|
private |
Fixed locator for version negotiation.