MySQL 8.3.0
Source Code Documentation
clone_protocol_service.cc File Reference

Typedefs

template<typename T >
using DD_Objs = std::vector< const T * >
 
using Releaser = dd::cache::Dictionary_client::Auto_releaser
 

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...
 
bool is_digit_or_dot (char c)
 Says whether a character is a digit or a dot. More...
 
bool compare_prefix_version (std::string ver1, std::string ver2)
 Compares versions, ignoring suffixes, i.e. More...
 
int mysql_clone_validate_configs (THD *thd, Mysql_Clone_Key_Values &configs) noexcept
 Check if configuration parameter values match. More...
 
MYSQLmysql_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...
 

Typedef Documentation

◆ DD_Objs

template<typename T >
using DD_Objs = std::vector<const T *>

◆ Releaser

Function Documentation

◆ compare_prefix_version()

bool compare_prefix_version ( std::string  ver1,
std::string  ver2 
)
inline

Compares versions, ignoring suffixes, 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.

Parameters
ver1version1 string
ver2version2 string
Returns
true if versions match (ignoring suffixes), false otherwise

◆ get_utf8_config()

static int get_utf8_config ( THD thd,
std::string  config_name,
String utf8_val 
)
static

Get configuration parameter value in utf8.

Parameters
[in]thdserver session THD
[in]config_nameparameter name
[out]utf8_valparameter value in utf8 string
Returns
error code.

◆ is_digit_or_dot()

bool is_digit_or_dot ( char  c)
inline

Says whether a character is a digit or a dot.

Parameters
ccharacter
Returns
true if c is a digit or a dot, otherwise false

◆ mysql_clone_connect()

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.

Parameters
[in,out]thdserver session THD
[in]hosthost name to connect to
[in]portport number to connect to
[in]useruser name on remote host
[in]passwdpassword for the user
[in]ssl_ctxclient ssl context
[out]socketNetwork socket for the connection
Returns
Connection object if successful.

◆ mysql_clone_disconnect()

void mysql_clone_disconnect ( THD thd,
MYSQL mysql,
bool  is_fatal,
bool  clear_error 
)
noexcept

Disconnect from a remote server.

Parameters
[in,out]thdlocal session THD
[in,out]mysqlconnection object
[in]is_fatalif closing after fatal error
[in]clear_errorclear any earlier error in session

◆ mysql_clone_finish_statement()

void mysql_clone_finish_statement ( THD thd)
noexcept

Finish statement and session.

Parameters
[in,out]thdserver session THD

◆ mysql_clone_get_charsets()

int mysql_clone_get_charsets ( THD thd,
Mysql_Clone_Values char_sets 
)
noexcept

Get all character set and collations.

Parameters
[in,out]thdserver session THD
[out]char_setsall character set collations
Returns
error code.

◆ mysql_clone_get_command()

int mysql_clone_get_command ( THD thd,
uchar command,
uchar **  com_buffer,
size_t *  buffer_length 
)
noexcept

Get command from client.

Parameters
[in,out]thdserver session THD
[out]commandremote command
[out]com_bufferdata following command
[out]buffer_lengthdata length
Returns
error code.

◆ mysql_clone_get_configs()

int mysql_clone_get_configs ( THD thd,
Mysql_Clone_Key_Values configs 
)
noexcept

Get system configuration parameter values.

Parameters
[in,out]thdserver session THD
[in,out]configsa list of configuration key value pair keys are input and values are output
Returns
error code.

◆ mysql_clone_get_error()

void mysql_clone_get_error ( THD thd,
uint32_t *  err_num,
const char **  err_mesg 
)
noexcept

Get error number and message.

Parameters
[in,out]thdlocal session THD
[out]err_numerror number
[out]err_mesgerror message text

◆ mysql_clone_get_response()

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.

Parameters
[in,out]thdlocal session THD
[in,out]connectionconnection object
[in]set_activeset socket active for current THD
[in]timeouttimeout in seconds
[out]packetresponse packet
[out]lengthpacket length
[out]net_lengthnetwork data length for compressed data
Returns
error code.

◆ mysql_clone_kill()

int mysql_clone_kill ( MYSQL connection,
MYSQL kill_connection 
)
noexcept

Kill a remote connection.

Parameters
[in,out]connectionconnection object
[in]kill_connectionconnection to kill
Returns
error code.

◆ mysql_clone_send_command()

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.

Parameters
[in,out]thdlocal session THD
[in,out]connectionconnection object
[in]set_activeset socket active for current THD
[in]commandremote command
[in]com_bufferdata following command
[in]buffer_lengthdata length
Returns
error code.

◆ mysql_clone_send_error()

int mysql_clone_send_error ( THD thd,
uchar  err_cmd,
bool  is_fatal 
)
noexcept

Send error to client.

Parameters
[in,out]thdserver session THD
[in]err_cmderror response command
[in]is_fatalif fatal error
Returns
error code.

◆ mysql_clone_send_response()

int mysql_clone_send_response ( THD thd,
bool  secure,
uchar packet,
size_t  length 
)
noexcept

Send response to client.

Parameters
[in,out]thdserver session THD
[in]secureneeds to be sent over secure connection
[in]packetresponse packet
[in]lengthpacket length
Returns
error code.

◆ mysql_clone_start_statement()

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.

Parameters
[in,out]thdserver session THD
[in]thread_keyPSI key for thread
[in]statement_keyPSI Key for statement

◆ mysql_clone_validate_charsets()

int mysql_clone_validate_charsets ( THD thd,
Mysql_Clone_Values char_sets 
)
noexcept

Check if all characters sets are supported by server.

Parameters
[in,out]thdserver session THD
[in]char_setsall character set collations to validate
Returns
error code.

◆ mysql_clone_validate_configs()

int mysql_clone_validate_configs ( THD thd,
Mysql_Clone_Key_Values configs 
)
noexcept

Check if configuration parameter values match.

Parameters
[in,out]thdserver session THD
[in]configsa list of configuration key value pair
Returns
error code.

◆ set_idle_timeout()

static void set_idle_timeout ( NET net,
uint32_t  timeout 
)
static

Set Network idle timeout.

Parameters
[in,out]netnetwork object
[in]timeouttime out in seconds

◆ set_read_timeout()

static void set_read_timeout ( NET net,
uint32_t  timeout 
)
static

Set Network read timeout.

Parameters
[in,out]netnetwork object
[in]timeouttime out in seconds

◆ set_write_timeout()

static void set_write_timeout ( NET net,
uint32_t  timeout 
)
static

Set Network write timeout.

Parameters
[in,out]netnetwork object
[in]timeouttime out in seconds

Variable Documentation

◆ MIN_IDLE_TIME_OUT_SEC

const uint32_t MIN_IDLE_TIME_OUT_SEC = 8 * 60 * 60
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.

◆ MIN_READ_TIME_OUT_SEC

const uint32_t MIN_READ_TIME_OUT_SEC = 30
static

Minimum read timeout in seconds.

Maintain above the donor ACK frequency.

◆ MIN_WRITE_TIME_OUT_SEC

const uint32_t MIN_WRITE_TIME_OUT_SEC = 60
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.