![]() |
MySQL 8.0.43
Source Code Documentation
|
Innodb Clone Interface. More...
#include <cstdio>#include <fstream>#include <iostream>#include "clone0api.h"#include "clone0clone.h"#include "os0thread-create.h"#include "sql/clone_handler.h"#include "sql/mysqld.h"#include "sql/sql_backup_lock.h"#include "sql/sql_class.h"#include "sql/sql_prepare.h"#include "sql/sql_table.h"#include "sql/sql_thd_internal_api.h"#include "sql/strfunc.h"#include "dict0dd.h"#include "ha_innodb.h"#include "log0files_io.h"#include "sql/dd/cache/dictionary_client.h"#include "sql/dd/dictionary.h"#include "sql/dd/impl/dictionary_impl.h"#include "sql/dd/impl/sdi.h"#include "sql/dd/impl/utils.h"#include "sql/dd/types/schema.h"#include "sql/dd/types/table.h"#include "sql/rpl_msr.h"Classes | |
| class | anonymous_namespace{clone0api.cc}::Fixup_data |
| Fix schema, table and tablespace. More... | |
Namespaces | |
| namespace | anonymous_namespace{clone0api.cc} |
Typedefs | |
| typedef std::function< void(const std::string &)> | Clone_file_handler |
| Type of function which is supposed to handle a single file during Clone operations, accepting the file's name (string). More... | |
| template<typename T > | |
| using | DD_Objs = std::vector< const T * > |
| template<typename T > | |
| using | DD_Objs_Iter = typename DD_Objs< T >::const_iterator |
| using | Releaser = dd::cache::Dictionary_client::Auto_releaser |
Functions | |
| THD * | thd_get_current_thd () |
| Get current THD object from thread local data. More... | |
| static bool | file_exists (const std::string &file_name) |
| Check if clone status file exists. More... | |
| static void | rename_file (const std::string &from_file, const std::string &to_file) |
| Rename clone status file. More... | |
| static void | create_file (std::string &file_name) |
| Create clone status file. More... | |
| static void | remove_file (const std::string &file) |
| Delete clone status file or directory. More... | |
| static void | create_status_file (const Clone_Handle *clone) |
| Create clone in progress file and error file. More... | |
| static void | drop_status_file (const Clone_Handle *clone) |
| Drop clone in progress file and error file. More... | |
| void | clone_init_list_files () |
| Check and delete any old list files. More... | |
| void | clone_remove_list_file (const char *file_name) |
| Remove one of the clone list files. More... | |
| int | clone_add_to_list_file (const char *list_file_name, const char *file_name) |
| Add file name to clone list file for future replacement or rollback. More... | |
| static void | track_redo_files () |
| Add redo log directory to the old file list. More... | |
| static bool | clone_execute_query (THD *thd, const char *sql_stmt, size_t thread_number, bool skip_error) |
| Execute sql statement. More... | |
| static int | clone_drop_binary_logs (THD *thd) |
| Delete all binary logs before clone. More... | |
| static int | clone_drop_user_data (THD *thd, bool allow_threads) |
| Drop all user data before starting clone. More... | |
| static void | clone_init_compression (THD *thd) |
| Initialize transparent page compression in innodb space by checking all innodb tables in DD. More... | |
| static int | clone_init_tablespaces (THD *thd) |
| Open all Innodb tablespaces. More... | |
| static void | skip_grants (THD *thd, Security_context &sctx) |
| Set security context to skip privilege check. More... | |
| void | innodb_clone_get_capability (Ha_clone_flagset &flags) |
| Get capability flags for clone operation. More... | |
| static int | clone_begin_check (THD *thd) |
| Check if clone can be started. More... | |
| static bool | get_clone_timeout_config (THD *thd, const std::string &config_name, int &timeout) |
| Get clone timeout configuration value. More... | |
| static int | get_ddl_timeout (THD *thd) |
| Timeout while waiting for DDL commands. More... | |
| int | innodb_clone_begin (handlerton *, THD *thd, const byte *&loc, uint &loc_len, uint &task_id, Ha_clone_type type, Ha_clone_mode mode) |
| Begin copy from source database. More... | |
| int | innodb_clone_copy (handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, Ha_clone_cbk *cbk) |
| Copy data from source database in chunks via callback. More... | |
| int | innodb_clone_ack (handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk) |
| Acknowledge data to source database. More... | |
| static Clone_Min | get_donor_timeout (THD *thd) |
| Timeout while waiting for recipient after network failure. More... | |
| int | innodb_clone_end (handlerton *, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err) |
| End copy from source database. More... | |
| int | innodb_clone_apply_begin (handlerton *, THD *thd, const byte *&loc, uint &loc_len, uint &task_id, Ha_clone_mode mode, const char *data_dir) |
| Begin apply to destination database. More... | |
| int | innodb_clone_apply (handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk) |
| Apply data to destination database in chunks via callback. More... | |
| int | innodb_clone_apply_end (handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err) |
| End apply to destination database. More... | |
| static int | get_file_state (const std::string &data_file) |
| Get current state of a clone file. More... | |
| static int | file_roll_forward (const std::string &data_file, int final_state) |
| Roll forward clone file state till final state. More... | |
| static void | file_rollback (const std::string &data_file) |
| Roll back clone file state to normal state. More... | |
| static void | old_file_roll_forward (const std::string &data_file, int final_state) |
| Roll forward old data file state till final state. More... | |
| static void | old_file_rollback (const std::string &data_file) |
| Roll back old data file state to normal state. More... | |
| static void | clone_files_fatal_error () |
| Fatal error callback function. More... | |
| static void | clone_update_recovery_status (bool finished, bool is_error, bool is_replace) |
| Update recovery status file at end of clone recovery. More... | |
| static void | clone_init_recovery_status (bool replace) |
| Initialize recovery status for cloned recovery. More... | |
| void | clone_update_gtid_status (std::string >ids) |
| Update cloned GTIDs to recovery status file. More... | |
| static bool | clone_files_for_each_file (const char *status_file_name, const Clone_file_handler &process) |
| Processes each file name listed in the given status file, executing a given function for each of them. More... | |
| static void | process_remove_file (const char *file_name, const Clone_file_handler &process) |
| Process all entries and remove status file. More... | |
| void | clone_files_error () |
| Revert back clone changes in case of an error. More... | |
| bool | clone_check_recovery_crashpoint (bool is_cloned_db) |
| Debug function to check and crash during recovery. More... | |
| void | clone_files_recovery (bool finished) |
| Change cloned file states during recovery. More... | |
| dberr_t | clone_init () |
| Initialize Clone system. More... | |
| void | clone_free () |
| Uninitialize Clone system. More... | |
| bool | clone_check_provisioning () |
| bool | clone_check_active () |
| Check if active clone is running. More... | |
| bool | fix_cloned_tables (THD *thd) |
| Fix cloned non-Innodb tables during recovery. More... | |
Variables | |
| const int | FILE_DATA = 1 |
| Data file is found. More... | |
| const int | FILE_SAVED = 10 |
| Saved data file is found. More... | |
| const int | FILE_CLONED = 100 |
| Cloned data file is found. More... | |
| const int | FILE_STATE_NONE = 0 |
| NONE state: file not present. More... | |
| const int | FILE_STATE_NORMAL = FILE_DATA |
| Normal state: only data file is present. More... | |
| const int | FILE_STATE_SAVED = FILE_SAVED |
| Saved state: only saved data file is present. More... | |
| const int | FILE_STATE_CLONED = FILE_DATA + FILE_CLONED |
| Cloned state: data file and cloned data file are present. More... | |
| const int | FILE_STATE_CLONE_SAVED = FILE_SAVED + FILE_CLONED |
| Saved clone state: saved data file and cloned data file are present. More... | |
| const int | FILE_STATE_REPLACED = FILE_SAVED + FILE_DATA |
| Replaced state: saved data file and data file are present. More... | |
Innodb Clone Interface.
| typedef std::function<void(const std::string &)> Clone_file_handler |
Type of function which is supposed to handle a single file during Clone operations, accepting the file's name (string).
| using DD_Objs = std::vector<const T *> |
| using DD_Objs_Iter = typename DD_Objs<T>::const_iterator |
| int clone_add_to_list_file | ( | const char * | list_file_name, |
| const char * | file_name | ||
| ) |
Add file name to clone list file for future replacement or rollback.
| [in] | list_file_name | list file name where to add the file |
| [in] | file_name | file name to add to the list |
|
static |
Check if clone can be started.
| [in,out] | thd | session THD |
| bool clone_check_active | ( | ) |
Check if active clone is running.
| bool clone_check_provisioning | ( | ) |
| bool clone_check_recovery_crashpoint | ( | bool | is_cloned_db | ) |
Debug function to check and crash during recovery.
| [in] | is_cloned_db | if cloned database recovery |
|
static |
Delete all binary logs before clone.
| [in] | thd | current THD |
|
static |
Drop all user data before starting clone.
| [in,out] | thd | current THD |
| [in] | allow_threads | allow multiple threads |
|
static |
Execute sql statement.
| [in,out] | thd | current THD |
| [in] | sql_stmt | SQL statement |
| [in] | thread_number | executing thread number |
| [in] | skip_error | skip statement on error |
| void clone_files_error | ( | ) |
Revert back clone changes in case of an error.
|
static |
Fatal error callback function.
Don't call other functions from here. Don't use ut_a, ut_ad asserts or ib::fatal to avoid recursive invocation.
|
static |
Processes each file name listed in the given status file, executing a given function for each of them.
| [in] | status_file_name | status file name |
| [in] | process | the given function, accepting file name string |
| void clone_files_recovery | ( | bool | finished | ) |
Change cloned file states during recovery.
| [in] | finished | if recovery is finishing |
| void clone_free | ( | ) |
Uninitialize Clone system.
| dberr_t clone_init | ( | ) |
Initialize Clone system.
|
static |
Initialize transparent page compression in innodb space by checking all innodb tables in DD.
Usually this initialization is done later when user opens a table. Clone needs to read this from innodb space object.
| [in,out] | thd | session THD |
| void clone_init_list_files | ( | ) |
Check and delete any old list files.
|
static |
Initialize recovery status for cloned recovery.
| [in] | replace | we are replacing current directory. |
|
static |
Open all Innodb tablespaces.
| [in,out] | thd | session THD |
| void clone_remove_list_file | ( | const char * | file_name | ) |
Remove one of the clone list files.
| [in] | file_name | list file name to delete |
| void clone_update_gtid_status | ( | std::string & | gtids | ) |
Update cloned GTIDs to recovery status file.
| [in] | gtids | cloned GTIDs |
|
static |
Update recovery status file at end of clone recovery.
| [in] | finished | true if finishing clone recovery |
| [in] | is_error | if recovery error |
| [in] | is_replace | true, if replacing current directory |
|
static |
Create clone status file.
| [in] | file_name | file name |
|
static |
Create clone in progress file and error file.
| [in] | clone | clone handle |
|
static |
Drop clone in progress file and error file.
| [in] | clone | clone handle |
|
static |
Check if clone status file exists.
| [in] | file_name | file name |
|
static |
Roll forward clone file state till final state.
| [in] | data_file | data file name |
| [in] | final_state | data file state to forward to |
|
static |
Roll back clone file state to normal state.
| [in] | data_file | data file name |
| bool fix_cloned_tables | ( | THD * | thd | ) |
Fix cloned non-Innodb tables during recovery.
| [in,out] | thd | current THD |
|
static |
Get clone timeout configuration value.
| [in,out] | thd | server thread handle |
| [in] | config_name | timeout configuration name |
| [out] | timeout | timeout value |
|
static |
Timeout while waiting for DDL commands.
| [in,out] | thd | server thread handle |
Timeout while waiting for recipient after network failure.
| [in,out] | thd | server thread handle |
|
static |
Get current state of a clone file.
| [in] | data_file | data file name |
| int innodb_clone_ack | ( | handlerton * | hton, |
| THD * | thd, | ||
| const byte * | loc, | ||
| uint | loc_len, | ||
| uint | task_id, | ||
| int | in_err, | ||
| Ha_clone_cbk * | cbk | ||
| ) |
Acknowledge data to source database.
| [in] | hton | handlerton for SE |
| [in] | thd | server thread handle |
| [in] | loc | locator |
| [in] | loc_len | locator length in bytes |
| [in] | task_id | task identifier |
| [in] | in_err | inform any error occurred |
| [in] | cbk | callback interface for receiving data |
| int innodb_clone_apply | ( | handlerton * | hton, |
| THD * | thd, | ||
| const byte * | loc, | ||
| uint | loc_len, | ||
| uint | task_id, | ||
| int | in_err, | ||
| Ha_clone_cbk * | cbk | ||
| ) |
Apply data to destination database in chunks via callback.
| [in] | hton | handlerton for SE |
| [in] | thd | server thread handle |
| [in] | loc | locator |
| [in] | loc_len | locator length in bytes |
| [in] | task_id | task identifier |
| [in] | in_err | inform any error occurred |
| [in] | cbk | callback interface for receiving data |
| int innodb_clone_apply_begin | ( | handlerton * | hton, |
| THD * | thd, | ||
| const byte *& | loc, | ||
| uint & | loc_len, | ||
| uint & | task_id, | ||
| Ha_clone_mode | mode, | ||
| const char * | data_dir | ||
| ) |
Begin apply to destination database.
| [in] | hton | handlerton for SE |
| [in] | thd | server thread handle |
| [in,out] | loc | locator |
| [in,out] | loc_len | locator length |
| [out] | task_id | task identifier |
| [in] | mode | mode for starting clone |
| [in] | data_dir | target data directory |
| int innodb_clone_apply_end | ( | handlerton * | hton, |
| THD * | thd, | ||
| const byte * | loc, | ||
| uint | loc_len, | ||
| uint | task_id, | ||
| int | in_err | ||
| ) |
End apply to destination database.
| [in] | hton | handlerton for SE |
| [in] | thd | server thread handle |
| [in] | loc | locator |
| [in] | loc_len | locator length in bytes |
| [in] | task_id | task identifier |
| [in] | in_err | error code when ending after error |
| int innodb_clone_begin | ( | handlerton * | hton, |
| THD * | thd, | ||
| const byte *& | loc, | ||
| uint & | loc_len, | ||
| uint & | task_id, | ||
| Ha_clone_type | type, | ||
| Ha_clone_mode | mode | ||
| ) |
Begin copy from source database.
| [in] | hton | handlerton for SE |
| [in] | thd | server thread handle |
| [in,out] | loc | locator |
| [in,out] | loc_len | locator length |
| [out] | task_id | task identifier |
| [in] | type | clone type |
| [in] | mode | mode for starting clone |
| int innodb_clone_copy | ( | handlerton * | hton, |
| THD * | thd, | ||
| const byte * | loc, | ||
| uint | loc_len, | ||
| uint | task_id, | ||
| Ha_clone_cbk * | cbk | ||
| ) |
Copy data from source database in chunks via callback.
| [in] | hton | handlerton for SE |
| [in] | thd | server thread handle |
| [in] | loc | locator |
| [in] | loc_len | locator length in bytes |
| [in] | task_id | task identifier |
| [in] | cbk | callback interface for sending data |
| int innodb_clone_end | ( | handlerton * | hton, |
| THD * | thd, | ||
| const byte * | loc, | ||
| uint | loc_len, | ||
| uint | task_id, | ||
| int | in_err | ||
| ) |
End copy from source database.
| [in] | hton | handlerton for SE |
| [in] | thd | server thread handle |
| [in] | loc | locator |
| [in] | loc_len | locator length in bytes |
| [in] | task_id | task identifier |
| [in] | in_err | error code when ending after error |
| void innodb_clone_get_capability | ( | Ha_clone_flagset & | flags | ) |
Get capability flags for clone operation.
| [out] | flags | capability flag |
|
static |
Roll forward old data file state till final state.
| [in] | data_file | data file name |
| [in] | final_state | data file state to forward to |
|
static |
Roll back old data file state to normal state.
| [in] | data_file | data file name |
|
static |
Process all entries and remove status file.
| [in] | file_name | status file name |
| [in] | process | callback to process entries |
|
static |
Delete clone status file or directory.
| [in] | file | name of file |
|
static |
Rename clone status file.
The operation is expected to be atomic when the files belong to same directory.
| [in] | from_file | name of current file |
| [in] | to_file | name of new file |
|
static |
Set security context to skip privilege check.
| [in,out] | thd | session THD |
| [in,out] | sctx | security context |
| THD * thd_get_current_thd | ( | ) |
Get current THD object from thread local data.
| The | THD object for the thread, NULL if not connection thread |
|
static |
Add redo log directory to the old file list.
| const int FILE_CLONED = 100 |
Cloned data file is found.
| const int FILE_DATA = 1 |
Data file is found.
| const int FILE_SAVED = 10 |
Saved data file is found.
| const int FILE_STATE_CLONE_SAVED = FILE_SAVED + FILE_CLONED |
Saved clone state: saved data file and cloned data file are present.
| const int FILE_STATE_CLONED = FILE_DATA + FILE_CLONED |
Cloned state: data file and cloned data file are present.
| const int FILE_STATE_NONE = 0 |
NONE state: file not present.
| const int FILE_STATE_NORMAL = FILE_DATA |
Normal state: only data file is present.
| const int FILE_STATE_REPLACED = FILE_SAVED + FILE_DATA |
Replaced state: saved data file and data file are present.
| const int FILE_STATE_SAVED = FILE_SAVED |
Saved state: only saved data file is present.