MySQL 8.4.2
Source Code Documentation
|
Task manager for manging the tasks for a clone operation. More...
#include <clone0clone.h>
Public Member Functions | |
void | init (Clone_Snapshot *snapshot) |
Initialize task manager for clone handle. More... | |
ib_mutex_t * | get_mutex () |
Get task state mutex. More... | |
int | handle_error_other_task (bool raise_error) |
Handle any error raised by concurrent tasks. More... | |
void | set_error (int err, const char *file_name) |
Set error number. More... | |
int | add_task (THD *thd, const byte *ref_loc, uint loc_len, uint &task_id) |
Add a task to task manager. More... | |
bool | drop_task (THD *thd, uint task_id, bool &is_master) |
Drop task from task manager. More... | |
bool | is_chunk_reserved (uint32_t chunk_num) |
Check if chunk is already reserved. More... | |
void | reset_chunk (Clone_Task *task) |
Reset chunk information for task. More... | |
Clone_Task * | get_task_by_index (uint index) |
Get task by index. More... | |
int | reserve_next_chunk (Clone_Task *task, uint32_t &ret_chunk, uint32_t &ret_block) |
Reserve next chunk from task manager. More... | |
int | set_chunk (Clone_Task *task, Clone_Task_Meta *new_meta) |
Set current chunk and block information. More... | |
void | add_incomplete_chunk (Clone_Task *task) |
Track any incomplete chunks handled by the task. More... | |
void | init_state () |
Initialize task manager for current state. More... | |
void | reinit_copy_state (const byte *loc, uint loc_len) |
Reinitialize state using locator. More... | |
void | reinit_apply_state (const byte *ref_loc, uint ref_len, byte *&new_loc, uint &new_len, uint &alloc_len) |
Reinitialize state using locator. More... | |
void | reset_transition () |
Reset state transition information. More... | |
void | reset_error () |
Reset error information. More... | |
Snapshot_State | get_state () |
Get current clone state. More... | |
bool | in_transit_state () |
Check if in state transition. More... | |
Clone_Snapshot * | get_snapshot () |
Get attached snapshot. More... | |
int | change_state (Clone_Task *task, Clone_Desc_State *state_desc, Snapshot_State new_state, Clone_Alert_Func cbk, uint &num_wait) |
Move to next snapshot state. More... | |
int | check_state (Clone_Task *task, Snapshot_State new_state, bool exit_on_wait, int in_err, uint32_t &num_wait) |
Check if state transition is over and all tasks moved to next state. More... | |
bool | is_restart_metadata (Clone_Task *task) |
Check if needs to send state metadata once. More... | |
bool | is_file_metadata_transferred () const |
void | set_file_meta_transferred () |
Set sub-state: all file metadata is transferred. More... | |
int | finish_state (Clone_Task *task) |
Mark state finished for current task. More... | |
void | ack_state (const Clone_Desc_State *state_desc) |
Set acknowledged state. More... | |
int | wait_ack (Clone_Handle *clone, Clone_Task *task, Ha_clone_cbk *callback) |
Wait for acknowledgement. More... | |
bool | check_ack (const Clone_Desc_State *state_desc) |
Check if state ACK is needed. More... | |
bool | is_restarted () |
Check if clone is restarted after failure. More... | |
int | alloc_buffer (Clone_Task *task) |
Allocate buffers for current task. More... | |
bool | debug_sync_check (uint32_t chunk_num, Clone_Task *task) |
Check if needs to wait for debug sync point. More... | |
void | debug_wait (uint chunk_num, Clone_Task *task) |
Wait during clone operation. More... | |
void | debug_wait_ddl_meta () |
Wait before sending DDL metadata. More... | |
int | debug_restart (Clone_Task *task, int in_err, int restart_count) |
Force restart clone operation by raising network error. More... | |
Clone_Task * | find_master_task () |
Private Member Functions | |
bool | wait_before_add (const byte *ref_loc, uint loc_len) |
Check if we need to wait before adding current task. More... | |
bool | is_network_error (int err) |
Check if network error. More... | |
void | reserve_task (THD *thd, uint &task_id) |
Reserve free task from task manager and initialize. More... | |
bool | process_inclomplete_chunk () |
Check if we should process incomplete chunk next. More... | |
uint32_t | get_next_incomplete_chunk (uint32_t &block_num) |
Get next in complete chunk if any. More... | |
uint32_t | get_next_chunk () |
Get next unreserved chunk. More... | |
Private Attributes | |
ib_mutex_t | m_state_mutex |
Mutex synchronizing access by concurrent tasks. More... | |
Chunk_Info | m_chunk_info |
Finished and incomplete chunk information. More... | |
Clone_Task | m_clone_tasks [CLONE_MAX_TASKS] |
Clone task array. More... | |
uint | m_num_tasks |
Current number of tasks. More... | |
uint | m_num_tasks_finished |
Number of tasks finished current state. More... | |
uint | m_num_tasks_transit |
Number of tasks in transit state. More... | |
uint | m_restart_count |
Number of times clone is restarted. More... | |
Snapshot_State | m_ack_state |
Acknowledged state from client. More... | |
Snapshot_State | m_current_state |
Current state for clone. More... | |
Snapshot_State | m_next_state |
Next state: used during state transfer. More... | |
bool | m_transferred_file_meta |
bool | m_send_state_meta |
Send state metadata before starting: Used for restart. More... | |
int | m_saved_error |
Save any error raised by a task. More... | |
std::string | m_err_file_name |
File name related to the saved error. More... | |
Clone_Snapshot * | m_clone_snapshot |
Attached snapshot handle. More... | |
Task manager for manging the tasks for a clone operation.
void Clone_Task_Manager::ack_state | ( | const Clone_Desc_State * | state_desc | ) |
Set acknowledged state.
[in] | state_desc | State descriptor |
void Clone_Task_Manager::add_incomplete_chunk | ( | Clone_Task * | task | ) |
Track any incomplete chunks handled by the task.
[in,out] | task | current task |
Add a task to task manager.
[in] | thd | server THD object |
[in] | ref_loc | reference locator from remote |
[in] | loc_len | locator length in bytes |
[out] | task_id | task identifier |
int Clone_Task_Manager::alloc_buffer | ( | Clone_Task * | task | ) |
Allocate buffers for current task.
[in,out] | task | current task |
int Clone_Task_Manager::change_state | ( | Clone_Task * | task, |
Clone_Desc_State * | state_desc, | ||
Snapshot_State | new_state, | ||
Clone_Alert_Func | cbk, | ||
uint & | num_wait | ||
) |
Move to next snapshot state.
Each task must call this after no more chunk is left in current state. The state can be changed only after all tasks have finished transferring the reserved chunks.
[in] | task | clone task |
[in] | state_desc | descriptor for next state |
[in] | new_state | next state to move to |
[in] | cbk | alert callback for long wait |
[out] | num_wait | unfinished tasks in current state |
|
inline |
Check if state ACK is needed.
[in] | state_desc | State descriptor |
int Clone_Task_Manager::check_state | ( | Clone_Task * | task, |
Snapshot_State | new_state, | ||
bool | exit_on_wait, | ||
int | in_err, | ||
uint32_t & | num_wait | ||
) |
Check if state transition is over and all tasks moved to next state.
[in] | task | requesting task |
[in] | new_state | next state to move to |
[in] | exit_on_wait | exit from transition if needs to wait |
[in] | in_err | input error if already occurred |
[out] | num_wait | number of tasks to move to next state |
int Clone_Task_Manager::debug_restart | ( | Clone_Task * | task, |
int | in_err, | ||
int | restart_count | ||
) |
Force restart clone operation by raising network error.
[in] | task | current task |
[in] | in_err | any err that has occurred |
[in] | restart_count | restart counter |
bool Clone_Task_Manager::debug_sync_check | ( | uint32_t | chunk_num, |
Clone_Task * | task | ||
) |
Check if needs to wait for debug sync point.
[in] | chunk_num | chunk number to process |
[in] | task | current task |
void Clone_Task_Manager::debug_wait | ( | uint | chunk_num, |
Clone_Task * | task | ||
) |
Wait during clone operation.
[in] | chunk_num | chunk number to process |
[in] | task | current task |
void Clone_Task_Manager::debug_wait_ddl_meta | ( | ) |
Wait before sending DDL metadata.
bool Clone_Task_Manager::drop_task | ( | THD * | thd, |
uint | task_id, | ||
bool & | is_master | ||
) |
Drop task from task manager.
[in] | thd | server THD object |
[in] | task_id | current task ID |
[out] | is_master | true, if master task |
Clone_Task * Clone_Task_Manager::find_master_task | ( | ) |
int Clone_Task_Manager::finish_state | ( | Clone_Task * | task | ) |
Mark state finished for current task.
[in] | task | current task |
|
inline |
Get task state mutex.
|
private |
Get next unreserved chunk.
|
private |
Get next in complete chunk if any.
[out] | block_num | first block number in chunk |
|
inline |
Get attached snapshot.
|
inline |
Get current clone state.
|
inline |
Get task by index.
[in] | index | task index |
int Clone_Task_Manager::handle_error_other_task | ( | bool | raise_error | ) |
Handle any error raised by concurrent tasks.
[in] | raise_error | raise error if true |
|
inline |
Check if in state transition.
void Clone_Task_Manager::init | ( | Clone_Snapshot * | snapshot | ) |
Initialize task manager for clone handle.
[in] | snapshot | snapshot |
void Clone_Task_Manager::init_state | ( | ) |
Initialize task manager for current state.
|
inline |
Check if chunk is already reserved.
[in] | chunk_num | chunk number |
|
inline |
|
inlineprivate |
Check if network error.
[in] | err | error code |
|
inline |
Check if needs to send state metadata once.
[in] | task | current task |
|
inline |
Check if clone is restarted after failure.
|
inlineprivate |
Check if we should process incomplete chunk next.
Incomplete chunks could be there after a re-start from network failure. We always process the chunks in order and need to choose accordingly.
void Clone_Task_Manager::reinit_apply_state | ( | const byte * | ref_loc, |
uint | ref_len, | ||
byte *& | new_loc, | ||
uint & | new_len, | ||
uint & | alloc_len | ||
) |
Reinitialize state using locator.
[in] | ref_loc | current locator |
[in] | ref_len | current locator length |
[out] | new_loc | new locator to be sent to remote server |
[out] | new_len | length of new locator |
[in,out] | alloc_len | allocated length for locator buffer |
void Clone_Task_Manager::reinit_copy_state | ( | const byte * | loc, |
uint | loc_len | ||
) |
Reinitialize state using locator.
[in] | loc | locator from remote client |
[in] | loc_len | locator length in bytes |
int Clone_Task_Manager::reserve_next_chunk | ( | Clone_Task * | task, |
uint32_t & | ret_chunk, | ||
uint32_t & | ret_block | ||
) |
Reserve next chunk from task manager.
Called by individual tasks.
[in] | task | requesting task |
[out] | ret_chunk | reserved chunk number |
[out] | ret_block | start block number '0' if no more chunk. |
|
private |
Reserve free task from task manager and initialize.
[in] | thd | server THD object |
[out] | task_id | initialized task ID |
|
inline |
Reset chunk information for task.
[in] | task | current task |
|
inline |
Reset error information.
|
inline |
Reset state transition information.
int Clone_Task_Manager::set_chunk | ( | Clone_Task * | task, |
Clone_Task_Meta * | new_meta | ||
) |
Set current chunk and block information.
[in,out] | task | requesting task |
[in] | new_meta | updated task metadata |
|
inline |
Set error number.
[in] | err | error number |
[in] | file_name | associated file name if any |
|
inline |
Set sub-state: all file metadata is transferred.
int Clone_Task_Manager::wait_ack | ( | Clone_Handle * | clone, |
Clone_Task * | task, | ||
Ha_clone_cbk * | callback | ||
) |
Wait for acknowledgement.
[in] | clone | parent clone handle |
[in] | task | current task |
[in] | callback | user callback interface |
|
private |
Check if we need to wait before adding current task.
[in] | ref_loc | reference locator from remote |
[in] | loc_len | reference locator length |
|
private |
Acknowledged state from client.
|
private |
Finished and incomplete chunk information.
|
private |
Attached snapshot handle.
|
private |
Clone task array.
|
private |
Current state for clone.
|
private |
File name related to the saved error.
|
private |
Next state: used during state transfer.
|
private |
Current number of tasks.
|
private |
Number of tasks finished current state.
|
private |
Number of tasks in transit state.
|
private |
Number of times clone is restarted.
|
private |
Save any error raised by a task.
|
private |
Send state metadata before starting: Used for restart.
|
private |
Mutex synchronizing access by concurrent tasks.
|
private |