MySQL 8.4.0
Source Code Documentation
Recovery_state_transfer Class Reference

#include <recovery_state_transfer.h>

Public Member Functions

 Recovery_state_transfer (char *recovery_channel_name, const std::string &member_uuid, Channel_observation_manager *channel_obsr_mngr)
 Recovery state transfer constructor. More...
 
 ~Recovery_state_transfer ()
 
void initialize (const std::string &view_id, bool is_vcle_enabled)
 Initialize the state transfer class and reset the class flags. More...
 
void set_until_condition_after_gtids (const std::string &after_gtids)
 Set the gtids to use for the recovery until condition. More...
 
void abort_state_transfer ()
 Abort the state transfer. More...
 
void end_state_transfer ()
 Signals that the data was received so the process can end. More...
 
void set_recovery_donor_retry_count (ulong retry_count)
 Sets the number of times recovery tries to connect to a given donor. More...
 
void set_recovery_donor_reconnect_interval (ulong reconnect_interval)
 Sets the sleep time between connection attempts to all possible donors. More...
 
void set_recovery_ssl_options (bool use_ssl, const char *ssl_ca, const char *ssl_capath, const char *ssl_cert, const char *ssl_cipher, const char *ssl_key, const char *ssl_crl, const char *ssl_crlpath, bool ssl_verify_server_cert, char *tls_version, char *tls_ciphersuites)
 Sets all the SSL option to use on recovery. More...
 
void set_recovery_use_ssl (char use_ssl)
 Set the option that forces the use of SSL on recovery connections. More...
 
void set_recovery_ssl_ca (const char *ssl_ca)
 Set a SSL trusted certificate authorities file. More...
 
void set_recovery_ssl_capath (const char *ssl_capath)
 Set a folder with SSL trusted CA files. More...
 
void set_recovery_ssl_cert (const char *ssl_cert)
 Set a SSL certificate for connection. More...
 
void set_recovery_ssl_cipher (const char *ssl_cipher)
 Set a SSL ciphers to be used. More...
 
void set_recovery_ssl_key (const char *ssl_key)
 Set a SSL key for connections. More...
 
void set_recovery_ssl_crl (const char *ssl_crl)
 Set a SSL revocation list file. More...
 
void set_recovery_ssl_crlpath (const char *ssl_crlpath)
 Set a folder with SSL revocation list files. More...
 
void set_recovery_ssl_verify_server_cert (char ssl_verify_server_cert)
 Set if recovery shall compare the used hostname against the certificate. More...
 
void set_recovery_tls_version (const char *tls_version)
 Set a TLS versions to be used. More...
 
void set_recovery_tls_ciphersuites (const char *tls_ciphersuites)
 Set a TLS ciphersuites to be used. More...
 
bool get_recovery_use_ssl ()
 
void get_recovery_base_ssl_options (std::string *ssl_ca, std::string *ssl_cert, std::string *ssl_key)
 Get SSL options configured for recovery. More...
 
void set_stop_wait_timeout (ulong timeout)
 Sets the recovery shutdown timeout. More...
 
void set_recovery_public_key_path (const char *public_key_path)
 Set a public key file. More...
 
void set_recovery_get_public_key (bool set)
 Get preference to get public key. More...
 
void set_recovery_compression_algorithm (const char *name)
 Set compression algorithm. More...
 
void set_recovery_zstd_compression_level (uint level)
 Set compression level. More...
 
void initialize_group_info ()
 This method initializes the group membership info. More...
 
int update_recovery_process (bool did_members_left)
 This method decides what action to take when a member exits the group. More...
 
void inform_of_applier_stop (my_thread_id thread_id, bool aborted)
 Method that informs recovery that the donor channel applier was stopped. More...
 
void inform_of_receiver_stop (my_thread_id thread_id)
 Method that informs recovery that the donor channel receiver was stopped. More...
 
bool is_own_event_channel (my_thread_id id)
 Checks if the given id matches the recovery applier thread. More...
 
int check_recovery_thread_status ()
 Checks to see if the recovery IO/SQL thread is still running, probably caused by an timeout on shutdown. More...
 
State_transfer_status state_transfer (Plugin_stage_monitor_handler &stage_handler)
 Execute state transfer. More...
 

Private Member Functions

void update_group_membership (bool update_donor)
 Removes the old list of group members and enquires about the current members. More...
 
void build_donor_list (std::string *selected_donor)
 Based on the group list, build a random order list with all suitable donors. More...
 
void donor_failover ()
 Method that sets the failover status to true and awakes recovery. More...
 
bool verify_member_has_after_gtids_present (std::string &local_gtid_executed_string)
 Verify member has after_gtids received from replication donor already present in member's gtid_executed. More...
 
int establish_donor_connection ()
 Establish a master/slave connection to the selected donor. More...
 
int initialize_donor_connection (std::string hostname, uint port)
 Initializes the structures for the donor connection threads. More...
 
bool initialize_connection_parameters ()
 Initializes the connection parameters for the donor connection. More...
 
int start_recovery_donor_threads ()
 Starts the recovery slave threads to receive data from the donor. More...
 
State_transfer_status terminate_recovery_slave_threads (bool purge_logs=true)
 Terminates the connection to the donor. More...
 
int purge_recovery_slave_threads_repos ()
 Purges relay logs and the master info object. More...
 
bool verify_after_gtids_applied ()
 Verifies if after_gtids sent by sender is successfully applied when recovery is using CHANNEL_UNTIL_APPLIER_AFTER_GTIDS for start replica until condition. More...
 

Private Attributes

std::string m_recovery_channel_name
 The recovery channel name. More...
 
std::string member_uuid
 
std::string view_id
 
std::string m_after_gtids
 
enum_channel_until_condition m_until_condition
 
Group_member_infoselected_donor
 
std::string selected_donor_hostname
 
Group_member_info_listgroup_members
 
Group_member_info_list suitable_donors
 
long donor_connection_retry_count
 
bool recovery_aborted
 
bool donor_transfer_finished
 
bool connected_to_donor
 
bool on_failover
 
bool donor_channel_thread_error
 
Replication_thread_api donor_connection_interface
 Interface class to interact with the donor connection threads. More...
 
Channel_observation_managerchannel_observation_manager
 
Channel_state_observerrecovery_channel_observer
 
bool recovery_use_ssl
 If the use of SSL is obligatory on recovery connections. More...
 
bool recovery_get_public_key
 Get public key. More...
 
char recovery_ssl_ca [FN_REFLEN]
 The configured SSL trusted certificate authorities file. More...
 
char recovery_ssl_capath [FN_REFLEN]
 The configured directory that contains trusted SSL CA files. More...
 
char recovery_ssl_cert [FN_REFLEN]
 The configured SSL certificate file to use for a secure connection. More...
 
char recovery_ssl_cipher [FN_REFLEN]
 The configured SSL list of permissible ciphers to use for encryption. More...
 
char recovery_ssl_key [FN_REFLEN]
 The configured SSL key file to use for establishing a secure connection. More...
 
char recovery_ssl_crl [FN_REFLEN]
 The configured SSL file containing certificate revocation lists. More...
 
char recovery_ssl_crlpath [FN_REFLEN]
 The configured directory that contains certificate revocation list files. More...
 
bool recovery_ssl_verify_server_cert
 If the server's Common Name value checks against donor sent certificate. More...
 
char recovery_public_key_path [FN_REFLEN]
 Public key information. More...
 
char recovery_tls_version [FN_REFLEN]
 Permitted TLS versions. More...
 
bool recovery_tls_ciphersuites_null
 Permitted TLS 1.3 ciphersuites. More...
 
char recovery_tls_ciphersuites [FN_REFLEN]
 
mysql_mutex_t recovery_lock
 
mysql_cond_t recovery_condition
 
mysql_mutex_t donor_selection_lock
 
long max_connection_attempts_to_donors
 
long donor_reconnect_interval
 
char recovery_compression_algorithm [COMPRESSION_ALGORITHM_NAME_LENGTH_MAX]
 
uint recovery_zstd_compression_level
 

Constructor & Destructor Documentation

◆ Recovery_state_transfer()

Recovery_state_transfer::Recovery_state_transfer ( char *  recovery_channel_name,
const std::string &  member_uuid,
Channel_observation_manager channel_obsr_mngr 
)

Recovery state transfer constructor.

Parameters
recovery_channel_nameThe channel name to be used
member_uuidThis member uuid
channel_obsr_mngrThe channel state observer manager

◆ ~Recovery_state_transfer()

Recovery_state_transfer::~Recovery_state_transfer ( )

Member Function Documentation

◆ abort_state_transfer()

void Recovery_state_transfer::abort_state_transfer ( )

Abort the state transfer.

◆ build_donor_list()

void Recovery_state_transfer::build_donor_list ( std::string *  selected_donor)
private

Based on the group list, build a random order list with all suitable donors.

Parameters
selected_donorthe current selected donor to update its pointer

◆ check_recovery_thread_status()

int Recovery_state_transfer::check_recovery_thread_status ( )

Checks to see if the recovery IO/SQL thread is still running, probably caused by an timeout on shutdown.

If the threads are still running, we try to stop them again. If not possible, an error is reported.

Returns
are the threads stopped
Return values
0All is stopped.
!=0Threads are still running

◆ donor_failover()

void Recovery_state_transfer::donor_failover ( )
private

Method that sets the failover status to true and awakes recovery.

◆ end_state_transfer()

void Recovery_state_transfer::end_state_transfer ( )

Signals that the data was received so the process can end.

◆ establish_donor_connection()

int Recovery_state_transfer::establish_donor_connection ( )
private

Establish a master/slave connection to the selected donor.

Returns
the operation status
Return values
0OK
!=0Error

◆ get_recovery_base_ssl_options()

void Recovery_state_transfer::get_recovery_base_ssl_options ( std::string *  ssl_ca,
std::string *  ssl_cert,
std::string *  ssl_key 
)
inline

Get SSL options configured for recovery.

Parameters
[out]ssl_cathe ssl ca
[out]ssl_certthe ssl cert
[out]ssl_keythe ssl key

◆ get_recovery_use_ssl()

bool Recovery_state_transfer::get_recovery_use_ssl ( )
inline
Returns
Is recovery configured to use SSL

◆ inform_of_applier_stop()

void Recovery_state_transfer::inform_of_applier_stop ( my_thread_id  thread_id,
bool  aborted 
)

Method that informs recovery that the donor channel applier was stopped.

Parameters
thread_idthe applier thread id
abortedif the applier was aborted or stopped

◆ inform_of_receiver_stop()

void Recovery_state_transfer::inform_of_receiver_stop ( my_thread_id  thread_id)

Method that informs recovery that the donor channel receiver was stopped.

Parameters
thread_idthe applier thread id

◆ initialize()

void Recovery_state_transfer::initialize ( const std::string &  view_id,
bool  is_vcle_enabled 
)

Initialize the state transfer class and reset the class flags.

Parameters
view_idThe view id to use for the recovery.
is_vcle_enabledthe flag determine if View_change_log_event is enabled.

◆ initialize_connection_parameters()

bool Recovery_state_transfer::initialize_connection_parameters ( )
private

Initializes the connection parameters for the donor connection.

Return values
falseEverything OK
trueIn case of the selected donor is not available

◆ initialize_donor_connection()

int Recovery_state_transfer::initialize_donor_connection ( std::string  hostname,
uint  port 
)
private

Initializes the structures for the donor connection threads.

Recovery channel is always purged.

Parameters
hostnamehostname of current selected donor
portport of current selected donor
Returns
the operation status
Return values
0OK
!=0Error

◆ initialize_group_info()

void Recovery_state_transfer::initialize_group_info ( )

This method initializes the group membership info.

◆ is_own_event_channel()

bool Recovery_state_transfer::is_own_event_channel ( my_thread_id  id)

Checks if the given id matches the recovery applier thread.

Parameters
idthe thread id
Returns
if it belongs to a thread
Return values
truethe id matches a SQL or worker thread
falsethe id doesn't match any thread

◆ purge_recovery_slave_threads_repos()

int Recovery_state_transfer::purge_recovery_slave_threads_repos ( )
private

Purges relay logs and the master info object.

Returns
the operation status
Return values
0OK
REPLICATION_THREAD_REPOSITORY_RL_PURGE_ERRORError when purging the relay logs
REPLICATION_THREAD_REPOSITORY_MI_PURGE_ERRORError when cleaning the master info repository

◆ set_recovery_compression_algorithm()

void Recovery_state_transfer::set_recovery_compression_algorithm ( const char *  name)
inline

Set compression algorithm.

◆ set_recovery_donor_reconnect_interval()

void Recovery_state_transfer::set_recovery_donor_reconnect_interval ( ulong  reconnect_interval)
inline

Sets the sleep time between connection attempts to all possible donors.

◆ set_recovery_donor_retry_count()

void Recovery_state_transfer::set_recovery_donor_retry_count ( ulong  retry_count)
inline

Sets the number of times recovery tries to connect to a given donor.

◆ set_recovery_get_public_key()

void Recovery_state_transfer::set_recovery_get_public_key ( bool  set)
inline

Get preference to get public key.

◆ set_recovery_public_key_path()

void Recovery_state_transfer::set_recovery_public_key_path ( const char *  public_key_path)
inline

Set a public key file.

◆ set_recovery_ssl_ca()

void Recovery_state_transfer::set_recovery_ssl_ca ( const char *  ssl_ca)
inline

Set a SSL trusted certificate authorities file.

◆ set_recovery_ssl_capath()

void Recovery_state_transfer::set_recovery_ssl_capath ( const char *  ssl_capath)
inline

Set a folder with SSL trusted CA files.

◆ set_recovery_ssl_cert()

void Recovery_state_transfer::set_recovery_ssl_cert ( const char *  ssl_cert)
inline

Set a SSL certificate for connection.

◆ set_recovery_ssl_cipher()

void Recovery_state_transfer::set_recovery_ssl_cipher ( const char *  ssl_cipher)
inline

Set a SSL ciphers to be used.

◆ set_recovery_ssl_crl()

void Recovery_state_transfer::set_recovery_ssl_crl ( const char *  ssl_crl)
inline

Set a SSL revocation list file.

◆ set_recovery_ssl_crlpath()

void Recovery_state_transfer::set_recovery_ssl_crlpath ( const char *  ssl_crlpath)
inline

Set a folder with SSL revocation list files.

◆ set_recovery_ssl_key()

void Recovery_state_transfer::set_recovery_ssl_key ( const char *  ssl_key)
inline

Set a SSL key for connections.

◆ set_recovery_ssl_options()

void Recovery_state_transfer::set_recovery_ssl_options ( bool  use_ssl,
const char *  ssl_ca,
const char *  ssl_capath,
const char *  ssl_cert,
const char *  ssl_cipher,
const char *  ssl_key,
const char *  ssl_crl,
const char *  ssl_crlpath,
bool  ssl_verify_server_cert,
char *  tls_version,
char *  tls_ciphersuites 
)
inline

Sets all the SSL option to use on recovery.

Parameters
use_sslforce the use of SSL on recovery connections
ssl_caSSL trusted certificate authorities file
ssl_capatha directory with trusted CA files
ssl_certthe certificate file for secure connections
ssl_cipherthe list of ciphers to use
ssl_keythe SSL key file
ssl_crlSSL revocation list file
ssl_crlpathpath with revocation list files
ssl_verify_server_certverify the hostname against the certificate
tls_versionthe list of TLS versions to use
tls_ciphersuitesthe list of TLS ciphersuites to use

◆ set_recovery_ssl_verify_server_cert()

void Recovery_state_transfer::set_recovery_ssl_verify_server_cert ( char  ssl_verify_server_cert)
inline

Set if recovery shall compare the used hostname against the certificate.

◆ set_recovery_tls_ciphersuites()

void Recovery_state_transfer::set_recovery_tls_ciphersuites ( const char *  tls_ciphersuites)
inline

Set a TLS ciphersuites to be used.

◆ set_recovery_tls_version()

void Recovery_state_transfer::set_recovery_tls_version ( const char *  tls_version)
inline

Set a TLS versions to be used.

◆ set_recovery_use_ssl()

void Recovery_state_transfer::set_recovery_use_ssl ( char  use_ssl)
inline

Set the option that forces the use of SSL on recovery connections.

◆ set_recovery_zstd_compression_level()

void Recovery_state_transfer::set_recovery_zstd_compression_level ( uint  level)
inline

Set compression level.

◆ set_stop_wait_timeout()

void Recovery_state_transfer::set_stop_wait_timeout ( ulong  timeout)
inline

Sets the recovery shutdown timeout.

Parameters
[in]timeoutthe timeout

◆ set_until_condition_after_gtids()

void Recovery_state_transfer::set_until_condition_after_gtids ( const std::string &  after_gtids)

Set the gtids to use for the recovery until condition.

Parameters
after_gtidsthe gtids to use for the recovery until condition.

◆ start_recovery_donor_threads()

int Recovery_state_transfer::start_recovery_donor_threads ( )
private

Starts the recovery slave threads to receive data from the donor.

Returns
the operation status
Return values
0OK
!=0Error

◆ state_transfer()

State_transfer_status Recovery_state_transfer::state_transfer ( Plugin_stage_monitor_handler stage_handler)

Execute state transfer.

Parameters
stage_handlerStage handler to update the system tables
Returns
the operation status
Return values
0OK
!=0Recovery state transfer failed

◆ terminate_recovery_slave_threads()

State_transfer_status Recovery_state_transfer::terminate_recovery_slave_threads ( bool  purge_logs = true)
private

Terminates the connection to the donor.

Parameters
purge_logspurge recovery logs
Returns
the operation status
Return values
STATE_TRANSFER_OKOK
!=STATE_TRANSFER_OKError

◆ update_group_membership()

void Recovery_state_transfer::update_group_membership ( bool  update_donor)
private

Removes the old list of group members and enquires about the current members.

Parameters
[in]update_donorupdate the selected donor pointer when updating

◆ update_recovery_process()

int Recovery_state_transfer::update_recovery_process ( bool  did_members_left)

This method decides what action to take when a member exits the group.

If the donor left, and the state transfer is still ongoing, then pick a new one and restart the transfer.

Parameters
did_members_leftstates if members left the view
Returns
the operation status
Return values
0OK
!=0Error

◆ verify_after_gtids_applied()

bool Recovery_state_transfer::verify_after_gtids_applied ( )
private

Verifies if after_gtids sent by sender is successfully applied when recovery is using CHANNEL_UNTIL_APPLIER_AFTER_GTIDS for start replica until condition.

Return values
falseafter_gtids is successfully applied.
trueError in applying after_gtids.

◆ verify_member_has_after_gtids_present()

bool Recovery_state_transfer::verify_member_has_after_gtids_present ( std::string &  local_gtid_executed_string)
private

Verify member has after_gtids received from replication donor already present in member's gtid_executed.

Parameters
local_gtid_executed_stringthe local member gtid_executed string
Returns
the operation status
Return values
trueafter_gtids there in member's gtid_executed.
falseafter_gtids not there in member's gtid_executed.

Member Data Documentation

◆ channel_observation_manager

Channel_observation_manager* Recovery_state_transfer::channel_observation_manager
private

◆ connected_to_donor

bool Recovery_state_transfer::connected_to_donor
private

◆ donor_channel_thread_error

bool Recovery_state_transfer::donor_channel_thread_error
private

◆ donor_connection_interface

Replication_thread_api Recovery_state_transfer::donor_connection_interface
private

Interface class to interact with the donor connection threads.

◆ donor_connection_retry_count

long Recovery_state_transfer::donor_connection_retry_count
private

◆ donor_reconnect_interval

long Recovery_state_transfer::donor_reconnect_interval
private

◆ donor_selection_lock

mysql_mutex_t Recovery_state_transfer::donor_selection_lock
private

◆ donor_transfer_finished

bool Recovery_state_transfer::donor_transfer_finished
private

◆ group_members

Group_member_info_list* Recovery_state_transfer::group_members
private

◆ m_after_gtids

std::string Recovery_state_transfer::m_after_gtids
private

◆ m_recovery_channel_name

std::string Recovery_state_transfer::m_recovery_channel_name
private

The recovery channel name.

◆ m_until_condition

enum_channel_until_condition Recovery_state_transfer::m_until_condition
private

◆ max_connection_attempts_to_donors

long Recovery_state_transfer::max_connection_attempts_to_donors
private

◆ member_uuid

std::string Recovery_state_transfer::member_uuid
private

◆ on_failover

bool Recovery_state_transfer::on_failover
private

◆ recovery_aborted

bool Recovery_state_transfer::recovery_aborted
private

◆ recovery_channel_observer

Channel_state_observer* Recovery_state_transfer::recovery_channel_observer
private

◆ recovery_compression_algorithm

char Recovery_state_transfer::recovery_compression_algorithm[COMPRESSION_ALGORITHM_NAME_LENGTH_MAX]
private

◆ recovery_condition

mysql_cond_t Recovery_state_transfer::recovery_condition
private

◆ recovery_get_public_key

bool Recovery_state_transfer::recovery_get_public_key
private

Get public key.

◆ recovery_lock

mysql_mutex_t Recovery_state_transfer::recovery_lock
private

◆ recovery_public_key_path

char Recovery_state_transfer::recovery_public_key_path[FN_REFLEN]
private

Public key information.

◆ recovery_ssl_ca

char Recovery_state_transfer::recovery_ssl_ca[FN_REFLEN]
private

The configured SSL trusted certificate authorities file.

◆ recovery_ssl_capath

char Recovery_state_transfer::recovery_ssl_capath[FN_REFLEN]
private

The configured directory that contains trusted SSL CA files.

◆ recovery_ssl_cert

char Recovery_state_transfer::recovery_ssl_cert[FN_REFLEN]
private

The configured SSL certificate file to use for a secure connection.

◆ recovery_ssl_cipher

char Recovery_state_transfer::recovery_ssl_cipher[FN_REFLEN]
private

The configured SSL list of permissible ciphers to use for encryption.

◆ recovery_ssl_crl

char Recovery_state_transfer::recovery_ssl_crl[FN_REFLEN]
private

The configured SSL file containing certificate revocation lists.

◆ recovery_ssl_crlpath

char Recovery_state_transfer::recovery_ssl_crlpath[FN_REFLEN]
private

The configured directory that contains certificate revocation list files.

◆ recovery_ssl_key

char Recovery_state_transfer::recovery_ssl_key[FN_REFLEN]
private

The configured SSL key file to use for establishing a secure connection.

◆ recovery_ssl_verify_server_cert

bool Recovery_state_transfer::recovery_ssl_verify_server_cert
private

If the server's Common Name value checks against donor sent certificate.

◆ recovery_tls_ciphersuites

char Recovery_state_transfer::recovery_tls_ciphersuites[FN_REFLEN]
private

◆ recovery_tls_ciphersuites_null

bool Recovery_state_transfer::recovery_tls_ciphersuites_null
private

Permitted TLS 1.3 ciphersuites.

◆ recovery_tls_version

char Recovery_state_transfer::recovery_tls_version[FN_REFLEN]
private

Permitted TLS versions.

◆ recovery_use_ssl

bool Recovery_state_transfer::recovery_use_ssl
private

If the use of SSL is obligatory on recovery connections.

◆ recovery_zstd_compression_level

uint Recovery_state_transfer::recovery_zstd_compression_level
private

◆ selected_donor

Group_member_info* Recovery_state_transfer::selected_donor
private

◆ selected_donor_hostname

std::string Recovery_state_transfer::selected_donor_hostname
private

◆ suitable_donors

Group_member_info_list Recovery_state_transfer::suitable_donors
private

◆ view_id

std::string Recovery_state_transfer::view_id
private

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