MySQL  8.0.19
Source Code Documentation
Remote_clone_handler Class Reference

Class that hold the logic to decide if we should or not execute a clone operation and the logic to launch it. More...

#include <remote_clone_handler.h>

Inheritance diagram for Remote_clone_handler:
Group_event_observer

Public Types

enum  enum_clone_check_result {
  DO_CLONE = 0, DO_RECOVERY = 1, CHECK_ERROR = 2, NO_RECOVERY_POSSIBLE = 3,
  CLONE_CHECKS_END = 4
}
 The possible results when checking what is the recovery strategy. More...
 

Public Member Functions

 Remote_clone_handler (ulonglong threshold, ulong components_stop_timeout)
 Constructor for the remote cloning handler. More...
 
 ~Remote_clone_handler ()
 The destructor. More...
 
void set_clone_threshold (ulonglong threshold)
 Set the class threshold for clone activation. More...
 
int extract_donor_info (std::tuple< uint, uint, uint, ulonglong > *donor_info)
 
enum_clone_check_result check_clone_preconditions ()
 Check if clone or distributed recovery shall be used for provisioning. More...
 
int clone_server (const std::string &group_name, const std::string &view_id)
 Launch the clone process with some preliminary checks. More...
 
void terminate_clone_process (bool rejoin)
 Terminate the clone process. More...
 
void lock_gr_clone_read_mode_lock ()
 Lock when trying to set the read mode and a clone might be running. More...
 
void unlock_gr_clone_read_mode_lock ()
 Unlock when trying to set the read mode and a clone might be running. More...
 
- Public Member Functions inherited from Group_event_observer
virtual ~Group_event_observer ()=0
 

Private Types

enum  enum_clone_presence_query_result { CLONE_PLUGIN_NOT_PRESENT = 0, CLONE_PLUGIN_PRESENT = 1, CLONE_CHECK_QUERY_ERROR = 2 }
 What is the result when we check if the clone plugin is present. More...
 
enum  enum_clone_query_status { CLONE_QUERY_NOT_EXECUTING = 0, CLONE_QUERY_EXECUTING = 1, CLONE_QUERY_EXECUTED = 2 }
 What are the states of the clone execution query. More...
 

Private Member Functions

virtual int after_view_change (const std::vector< Gcs_member_identifier > &joining, const std::vector< Gcs_member_identifier > &leaving, const std::vector< Gcs_member_identifier > &group, bool is_leaving, bool *skip_election, enum_primary_election_mode *election_mode, std::string &suggested_primary)
 Executed after view install and before primary election. More...
 
virtual int after_primary_election (std::string primary_uuid, bool primary_changed, enum_primary_election_mode election_mode, int error)
 Executed after primary election. More...
 
virtual int before_message_handling (const Plugin_gcs_message &message, const std::string &message_origin, bool *skip_message)
 Executed before the message is processed. More...
 
void clone_thread_handle ()
 The clone thread process. More...
 
enum_clone_presence_query_result check_clone_plugin_presence ()
 Check if clone plugin is present. More...
 
void get_clone_donors (std::list< Group_member_info * > &suitable_donors)
 Get all the valid members for cloning. More...
 
int set_clone_ssl_options (Sql_service_command_interface *sql_command_interface)
 Configure the SSL options for the clone plugin. More...
 
int fallback_to_recovery_or_leave (Sql_service_command_interface *sql_command_interface, bool critical_error=false)
 In error fall back to recovery or error out. More...
 
int update_donor_list (Sql_service_command_interface *sql_command_interface, std::string &hostname, std::string &port)
 Executes the query to change the allowed donor list for clone. More...
 
int evaluate_server_connection (Sql_service_command_interface *sql_command_interface)
 Checks if the server connection was not killed. More...
 
int run_clone_query (Sql_service_command_interface *sql_command_interface, std::string &hostname, std::string &port, std::string &username, std::string &password, bool use_ssl)
 Executes the query to remotely clone a server. More...
 
int kill_clone_query ()
 Kill the current query executing a clone. More...
 
void gr_clone_debug_point ()
 Function for debug points. More...
 

Static Private Member Functions

static void * launch_thread (void *arg)
 The thread callback passed onto mysql_thread_create. More...
 

Private Attributes

std::string m_group_name
 The group to which the recovering member belongs. More...
 
std::string m_view_id
 The view id when the clone started. More...
 
THDm_clone_thd
 the THD handle. More...
 
thread_state m_clone_process_thd_state
 the state of the thread. More...
 
my_thread_handle m_thd_handle
 the thread handle. More...
 
mysql_mutex_t m_run_lock
 the mutex for controlling access to the thread itself. More...
 
mysql_cond_t m_run_cond
 the cond_var used to signal the thread. More...
 
mysql_mutex_t m_clone_query_lock
 the mutex for the clone process query. More...
 
mysql_mutex_t m_clone_read_mode_lock
 the mutex for the clone external running status/read mode More...
 
bool m_being_terminated
 Is the process being terminated. More...
 
enum_clone_query_status m_clone_query_status
 What is the status on the read only mode enabling query. More...
 
unsigned long m_clone_query_session_id
 The session id for the clone query. More...
 
ulonglong m_clone_activation_threshold
 The threshold after which the clone process is invoked. More...
 
mysql_mutex_t m_donor_list_lock
 the mutex for donor list accesses. More...
 
std::list< Group_member_info * > m_suitable_donors
 The list of available donors. More...
 
Gcs_member_identifierm_current_donor_address
 The current donor address. More...
 
ulong m_stop_wait_timeout
 Timeout on shutdown. More...
 

Detailed Description

Class that hold the logic to decide if we should or not execute a clone operation and the logic to launch it.

Member Enumeration Documentation

◆ enum_clone_check_result

The possible results when checking what is the recovery strategy.

Enumerator
DO_CLONE 
DO_RECOVERY 
CHECK_ERROR 
NO_RECOVERY_POSSIBLE 
CLONE_CHECKS_END 

◆ enum_clone_presence_query_result

What is the result when we check if the clone plugin is present.

Enumerator
CLONE_PLUGIN_NOT_PRESENT 
CLONE_PLUGIN_PRESENT 
CLONE_CHECK_QUERY_ERROR 

◆ enum_clone_query_status

What are the states of the clone execution query.

Enumerator
CLONE_QUERY_NOT_EXECUTING 
CLONE_QUERY_EXECUTING 
CLONE_QUERY_EXECUTED 

Constructor & Destructor Documentation

◆ Remote_clone_handler()

Remote_clone_handler::Remote_clone_handler ( ulonglong  threshold,
ulong  components_stop_timeout 
)

Constructor for the remote cloning handler.

Parameters
thresholdThe threshold for clone activation
components_stop_timeoutThe stop timeout in error cases

◆ ~Remote_clone_handler()

Remote_clone_handler::~Remote_clone_handler ( )

The destructor.

Member Function Documentation

◆ after_primary_election()

int Remote_clone_handler::after_primary_election ( std::string  primary_uuid,
bool  primary_changed,
enum_primary_election_mode  election_mode,
int  error 
)
privatevirtual

Executed after primary election.

Parameters
primary_uuidthe elected primary
primary_changedif the primary changed after the election
election_modewhat was the election mode
errorif there was and error on the process

Implements Group_event_observer.

◆ after_view_change()

int Remote_clone_handler::after_view_change ( const std::vector< Gcs_member_identifier > &  joining,
const std::vector< Gcs_member_identifier > &  leaving,
const std::vector< Gcs_member_identifier > &  group,
bool  is_leaving,
bool skip_election,
enum_primary_election_mode election_mode,
std::string &  suggested_primary 
)
privatevirtual

Executed after view install and before primary election.

Parameters
joiningmembers joining the group
leavingmembers leaving the group
groupmembers in the group
is_leavingis the member leaving
[out]skip_electionskip primary election on view
[out]election_modeelection mode
[out]suggested_primarywhat should be the next primary to elect

Implements Group_event_observer.

◆ before_message_handling()

int Remote_clone_handler::before_message_handling ( const Plugin_gcs_message message,
const std::string &  message_origin,
bool skip_message 
)
privatevirtual

Executed before the message is processed.

Parameters
messageThe GCS message
message_originThe member that sent this message (address)
[out]skip_messageskip message handling if true

Implements Group_event_observer.

◆ check_clone_plugin_presence()

Remote_clone_handler::enum_clone_presence_query_result Remote_clone_handler::check_clone_plugin_presence ( )
private

Check if clone plugin is present.

Returns
is the clone present or error
Return values
CLONE_PLUGIN_NOT_PRESENTThe plugin is not present or active
CLONE_PLUGIN_PRESENTThe plugin is present and active
CLONE_CHECK_QUERY_ERRORThere was an error when checking

◆ check_clone_preconditions()

Remote_clone_handler::enum_clone_check_result Remote_clone_handler::check_clone_preconditions ( )

Check if clone or distributed recovery shall be used for provisioning.

Returns
What is the clone strategy to follow or shall we error out
Return values
DO_CLONEDo a remote clone
DO_RECOVERYDon't clone, use distributed recovery
CHECK_ERRORError when choosing the strategy
NO_RECOVERY_POSSIBLENo available members for clone or recovery

◆ clone_server()

int Remote_clone_handler::clone_server ( const std::string &  group_name,
const std::string &  view_id 
)

Launch the clone process with some preliminary checks.

Parameters
group_nameThe group name
view_idThe view id when clone started
Note
: the given parameters are used when falling back to distributed recovery in case of a clone issue.
Returns
whether or not we managed to launch the clone thread.
Return values
0the thread launched successfully
!=0 for some reason we did not launch the thread

◆ clone_thread_handle()

void Remote_clone_handler::clone_thread_handle ( )
private

The clone thread process.

◆ evaluate_server_connection()

int Remote_clone_handler::evaluate_server_connection ( Sql_service_command_interface sql_command_interface)
private

Checks if the server connection was not killed.

If so, establish a new one.

Parameters
[in]sql_command_interfacethe server connection
Returns
did we manage to reconnect
Return values
0yes
!=0 some error occurred

◆ extract_donor_info()

int Remote_clone_handler::extract_donor_info ( std::tuple< uint, uint, uint, ulonglong > *  donor_info)

◆ fallback_to_recovery_or_leave()

int Remote_clone_handler::fallback_to_recovery_or_leave ( Sql_service_command_interface sql_command_interface,
bool  critical_error = false 
)
private

In error fall back to recovery or error out.

Parameters
[in]sql_command_interfacethe server connection
[in]critical_errorthe error prevent distributed recovery

Before falling back to recovery check if there are valid donors Since cloning can be time consuming valid members may have left or joined in the meanwhile.

◆ get_clone_donors()

void Remote_clone_handler::get_clone_donors ( std::list< Group_member_info * > &  suitable_donors)
private

Get all the valid members for cloning.

Parameters
[out]suitable_donorsthe list of possible donors

◆ gr_clone_debug_point()

void Remote_clone_handler::gr_clone_debug_point ( )
private

Function for debug points.

Note
this function can have a parameter for different debug points

◆ kill_clone_query()

int Remote_clone_handler::kill_clone_query ( )
private

Kill the current query executing a clone.

Returns
whether or not we managed to kill the clone query
Return values
0the kill query was sucessfull
!=0 some error occurred

◆ launch_thread()

void * Remote_clone_handler::launch_thread ( void *  arg)
staticprivate

The thread callback passed onto mysql_thread_create.

Parameters
[in]arga pointer to a Remote_clone_handler instance.

◆ lock_gr_clone_read_mode_lock()

void Remote_clone_handler::lock_gr_clone_read_mode_lock ( )
inline

Lock when trying to set the read mode and a clone might be running.

◆ run_clone_query()

int Remote_clone_handler::run_clone_query ( Sql_service_command_interface sql_command_interface,
std::string &  hostname,
std::string &  port,
std::string &  username,
std::string &  password,
bool  use_ssl 
)
private

Executes the query to remotely clone a server.

Parameters
[in]sql_command_interfacethe connection to use
[in]hostnamethe hostname to use
[in]portthe port to use
[in]usernamethe username to use
[in]passwordthe password to use
[in]use_sslmake clone use SSL
Returns
whether or not we managed to clone the server
Return values
0the clone was sucessfull
!=0 some error occurred

◆ set_clone_ssl_options()

int Remote_clone_handler::set_clone_ssl_options ( Sql_service_command_interface sql_command_interface)
private

Configure the SSL options for the clone plugin.

Parameters
[in]sql_command_interfacethe connection to use

◆ set_clone_threshold()

void Remote_clone_handler::set_clone_threshold ( ulonglong  threshold)
inline

Set the class threshold for clone activation.

Parameters
thresholdThe threshold for clone activation

◆ terminate_clone_process()

void Remote_clone_handler::terminate_clone_process ( bool  rejoin)

Terminate the clone process.

Parameters
rejoinAre we terminating or rejoining in the plugin
Note
: the flag tells the method if the clone query should be killed or not Usually on rejoins the clone query is not killed. When stopping GR, then the query is terminated. No guarantees are made about what the server state is after that

◆ unlock_gr_clone_read_mode_lock()

void Remote_clone_handler::unlock_gr_clone_read_mode_lock ( )
inline

Unlock when trying to set the read mode and a clone might be running.

◆ update_donor_list()

int Remote_clone_handler::update_donor_list ( Sql_service_command_interface sql_command_interface,
std::string &  hostname,
std::string &  port 
)
private

Executes the query to change the allowed donor list for clone.

Parameters
[in]sql_command_interfacethe connection to use
[in]hostnamethe hostname to set
[in]portthe port to set
Returns
whether or not we managed to set the value
Return values
0the value was set
!=0 some error occurred

Member Data Documentation

◆ m_being_terminated

bool Remote_clone_handler::m_being_terminated
private

Is the process being terminated.

◆ m_clone_activation_threshold

ulonglong Remote_clone_handler::m_clone_activation_threshold
private

The threshold after which the clone process is invoked.

◆ m_clone_process_thd_state

thread_state Remote_clone_handler::m_clone_process_thd_state
private

the state of the thread.

◆ m_clone_query_lock

mysql_mutex_t Remote_clone_handler::m_clone_query_lock
private

the mutex for the clone process query.

◆ m_clone_query_session_id

unsigned long Remote_clone_handler::m_clone_query_session_id
private

The session id for the clone query.

◆ m_clone_query_status

enum_clone_query_status Remote_clone_handler::m_clone_query_status
private

What is the status on the read only mode enabling query.

◆ m_clone_read_mode_lock

mysql_mutex_t Remote_clone_handler::m_clone_read_mode_lock
private

the mutex for the clone external running status/read mode

◆ m_clone_thd

THD* Remote_clone_handler::m_clone_thd
private

the THD handle.

◆ m_current_donor_address

Gcs_member_identifier* Remote_clone_handler::m_current_donor_address
private

The current donor address.

◆ m_donor_list_lock

mysql_mutex_t Remote_clone_handler::m_donor_list_lock
private

the mutex for donor list accesses.

◆ m_group_name

std::string Remote_clone_handler::m_group_name
private

The group to which the recovering member belongs.

◆ m_run_cond

mysql_cond_t Remote_clone_handler::m_run_cond
private

the cond_var used to signal the thread.

◆ m_run_lock

mysql_mutex_t Remote_clone_handler::m_run_lock
private

the mutex for controlling access to the thread itself.

◆ m_stop_wait_timeout

ulong Remote_clone_handler::m_stop_wait_timeout
private

Timeout on shutdown.

◆ m_suitable_donors

std::list<Group_member_info *> Remote_clone_handler::m_suitable_donors
private

The list of available donors.

◆ m_thd_handle

my_thread_handle Remote_clone_handler::m_thd_handle
private

the thread handle.

◆ m_view_id

std::string Remote_clone_handler::m_view_id
private

The view id when the clone started.


The documentation for this class was generated from the following files: