MySQL 8.4.2
Source Code Documentation
|
#include "mysql/components/services/clone_protocol_service.h"
#include "mysql/components/service_implementation.h"
#include "mysql/components/services/log_builtins.h"
#include "my_byteorder.h"
#include "mysql.h"
#include "sql/mysqld.h"
#include "sql/protocol_classic.h"
#include "sql/set_var.h"
#include "sql/sql_class.h"
#include "sql/sql_show.h"
#include "sql/sql_thd_internal_api.h"
#include "sql/ssl_init_callback.h"
#include "sql/sys_vars_shared.h"
#include "sql_common.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dictionary.h"
Typedefs | |
template<typename T > | |
using | DD_Objs = std::vector< const T * > |
using | Releaser = dd::cache::Dictionary_client::Auto_releaser |
typedef std::array< std::string, CLONE_PARSE_ARRAY_SIZE > | ParseArray |
Parsed version strings array type. More... | |
Functions | |
static void | set_read_timeout (NET *net, uint32_t timeout) |
Set Network read timeout. More... | |
static void | set_write_timeout (NET *net, uint32_t timeout) |
Set Network write timeout. More... | |
static void | set_idle_timeout (NET *net, uint32_t timeout) |
Set Network idle timeout. More... | |
void | mysql_clone_start_statement (THD *&thd, PSI_thread_key thread_key, PSI_statement_key statement_key) noexcept |
Start and set session and statement key form current thread. More... | |
void | mysql_clone_finish_statement (THD *thd) noexcept |
Finish statement and session. More... | |
int | mysql_clone_get_charsets (THD *thd, Mysql_Clone_Values &char_sets) noexcept |
Get all character set and collations. More... | |
int | mysql_clone_validate_charsets (THD *thd, Mysql_Clone_Values &char_sets) noexcept |
Check if all characters sets are supported by server. More... | |
static int | get_utf8_config (THD *thd, std::string config_name, String &utf8_val) |
Get configuration parameter value in utf8. More... | |
int | mysql_clone_get_configs (THD *thd, Mysql_Clone_Key_Values &configs) noexcept |
Get system configuration parameter values. More... | |
static ParseArray | parse_version_string (std::string version) |
Parse a version string into an array of strings corresponding to the MAJOR, MINOR, PATCH and BUILD versions. More... | |
static void | test_configure_versions (std::string &config_val, std::string &donor_val) |
Test specific function to configure the version strings of the donor and recipient to cover various scenarios where clone is allowed or not. More... | |
bool | compare_server_version (std::string ver1, std::string ver2) |
Compares versions and determine if clone is allowed. More... | |
int | mysql_clone_validate_configs (THD *thd, Mysql_Clone_Key_Values &configs) noexcept |
Check if configuration parameter values match. More... | |
MYSQL * | mysql_clone_connect (THD *thd, const char *host, uint32_t port, const char *user, const char *passwd, mysql_clone_ssl_context *ssl_ctx, MYSQL_SOCKET *socket) noexcept |
Connect to a remote server and switch to clone protocol. More... | |
int | mysql_clone_send_command (THD *thd, MYSQL *connection, bool set_active, uchar command, uchar *com_buffer, size_t buffer_length) noexcept |
Execute clone command on remote server. More... | |
int | mysql_clone_get_response (THD *thd, MYSQL *connection, bool set_active, uint32_t timeout, uchar **packet, size_t *length, size_t *net_length) noexcept |
Get response from remote server. More... | |
int | mysql_clone_kill (MYSQL *connection, MYSQL *kill_connection) noexcept |
Kill a remote connection. More... | |
void | mysql_clone_disconnect (THD *thd, MYSQL *mysql, bool is_fatal, bool clear_error) noexcept |
Disconnect from a remote server. More... | |
void | mysql_clone_get_error (THD *thd, uint32_t *err_num, const char **err_mesg) noexcept |
Get error number and message. More... | |
int | mysql_clone_get_command (THD *thd, uchar *command, uchar **com_buffer, size_t *buffer_length) noexcept |
Get command from client. More... | |
int | mysql_clone_send_response (THD *thd, bool secure, uchar *packet, size_t length) noexcept |
Send response to client. More... | |
int | mysql_clone_send_error (THD *thd, uchar err_cmd, bool is_fatal) noexcept |
Send error to client. More... | |
Variables | |
static const uint32_t | MIN_IDLE_TIME_OUT_SEC = 8 * 60 * 60 |
The minimum idle timeout in seconds. More... | |
static const uint32_t | MIN_READ_TIME_OUT_SEC = 30 |
Minimum read timeout in seconds. More... | |
static const uint32_t | MIN_WRITE_TIME_OUT_SEC = 60 |
Minimum write timeout in seconds. More... | |
constexpr unsigned int | CLONE_PARSE_ARRAY_SIZE = 4 |
Size of the parsed version strings array. More... | |
constexpr unsigned int | MAJOR = 0 |
Index of the array correpsonding to parts of version. More... | |
constexpr unsigned int | MINOR = 1 |
constexpr unsigned int | PATCH = 2 |
constexpr unsigned int | BUILD = 3 |
constexpr unsigned long | CLONE_BACKPORT_VERSION = 37 |
using DD_Objs = std::vector<const T *> |
typedef std::array<std::string, CLONE_PARSE_ARRAY_SIZE> ParseArray |
Parsed version strings array type.
|
inline |
Compares versions and determine if clone is allowed.
Clone is allowed if both the donor and recipient have exactly same version string. In version series 8.1 and above, cloning is allowed if Major and Minor versions match. In 8.0 series, clone is allowed if patch version is above clone backport version. In this comparison, suffixes are ignored: i.e. 8.0.25 should be the same as 8.0.25-debug, but 8.0.25 isn't the same as 8.0.251
ver1 | version1 string |
ver2 | version2 string |
Get configuration parameter value in utf8.
[in] | thd | server session THD |
[in] | config_name | parameter name |
[out] | utf8_val | parameter value in utf8 string |
|
noexcept |
Connect to a remote server and switch to clone protocol.
[in,out] | thd | server session THD |
[in] | host | host name to connect to |
[in] | port | port number to connect to |
[in] | user | user name on remote host |
[in] | passwd | password for the user |
[in] | ssl_ctx | client ssl context |
[out] | socket | Network socket for the connection |
Disconnect from a remote server.
[in,out] | thd | local session THD |
[in,out] | mysql | connection object |
[in] | is_fatal | if closing after fatal error |
[in] | clear_error | clear any earlier error in session |
|
noexcept |
Finish statement and session.
[in,out] | thd | server session THD |
|
noexcept |
Get all character set and collations.
[in,out] | thd | server session THD |
[out] | char_sets | all character set collations |
|
noexcept |
Get command from client.
[in,out] | thd | server session THD |
[out] | command | remote command |
[out] | com_buffer | data following command |
[out] | buffer_length | data length |
|
noexcept |
Get system configuration parameter values.
[in,out] | thd | server session THD |
[in,out] | configs | a list of configuration key value pair keys are input and values are output |
|
noexcept |
Get error number and message.
[in,out] | thd | local session THD |
[out] | err_num | error number |
[out] | err_mesg | error message text |
|
noexcept |
Get response from remote server.
[in,out] | thd | local session THD |
[in,out] | connection | connection object |
[in] | set_active | set socket active for current THD |
[in] | timeout | timeout in seconds |
[out] | packet | response packet |
[out] | length | packet length |
[out] | net_length | network data length for compressed data |
Kill a remote connection.
[in,out] | connection | connection object |
[in] | kill_connection | connection to kill |
|
noexcept |
Execute clone command on remote server.
[in,out] | thd | local session THD |
[in,out] | connection | connection object |
[in] | set_active | set socket active for current THD |
[in] | command | remote command |
[in] | com_buffer | data following command |
[in] | buffer_length | data length |
Send error to client.
[in,out] | thd | server session THD |
[in] | err_cmd | error response command |
[in] | is_fatal | if fatal error |
Send response to client.
[in,out] | thd | server session THD |
[in] | secure | needs to be sent over secure connection |
[in] | packet | response packet |
[in] | length | packet length |
|
noexcept |
Start and set session and statement key form current thread.
[in,out] | thd | server session THD |
[in] | thread_key | PSI key for thread |
[in] | statement_key | PSI Key for statement |
|
noexcept |
Check if all characters sets are supported by server.
[in,out] | thd | server session THD |
[in] | char_sets | all character set collations to validate |
|
noexcept |
Check if configuration parameter values match.
[in,out] | thd | server session THD |
[in] | configs | a list of configuration key value pair |
|
static |
Parse a version string into an array of strings corresponding to the MAJOR, MINOR, PATCH and BUILD versions.
A string of length 0 is filled in case a particular version string could not be parsed. For example, "Major.Minor.Patch-Build" yields ["Major", "Minor", "Patch", "Build"], "8.0.23-SR1" yields ["8", "0", "23", "SR1"], "8.0.-u5" yields ["8", "0", "", "u5"]
version | input version string |
|
static |
Set Network idle timeout.
[in,out] | net | network object |
[in] | timeout | time out in seconds |
|
static |
Set Network read timeout.
[in,out] | net | network object |
[in] | timeout | time out in seconds |
|
static |
Set Network write timeout.
[in,out] | net | network object |
[in] | timeout | time out in seconds |
|
static |
Test specific function to configure the version strings of the donor and recipient to cover various scenarios where clone is allowed or not.
This function will modify the input to ensure correct error message is printed.
config_val | recipient server's version string |
donor_val | donor server's version string |
|
constexpr |
|
constexpr |
|
constexpr |
Size of the parsed version strings array.
|
constexpr |
Index of the array correpsonding to parts of version.
|
static |
The minimum idle timeout in seconds.
It is kept at 8 hours which is also the Server default. Currently recipient sends ACK during state transition. In future we could have better time controlled ACK.
|
static |
Minimum read timeout in seconds.
Maintain above the donor ACK frequency.
|
static |
Minimum write timeout in seconds.
Disallow configuring it to too low. We might need a separate clone configuration in future or retry on failure.
|
constexpr |
|
constexpr |