MySQL 8.3.0
Source Code Documentation
Recovery_module Class Reference

#include <recovery.h>

Public Types

enum class  enum_recovery_metadata_error { RECOVERY_METADATA_RECEIVED_NO_ERROR , RECOVERY_METADATA_RECEIVED_TIMEOUT_ERROR , RECOVERY_METADATA_RECOVERY_ABORTED_ERROR , RECOVERY_METADATA_RECEIVED_ERROR }
 

Public Member Functions

 Recovery_module (Applier_module_interface *applier, Channel_observation_manager *channel_obsr_mngr)
 Recovery_module constructor. More...
 
 ~Recovery_module ()
 
void set_applier_module (Applier_module_interface *applier)
 
int start_recovery (const std::string &group_name, const std::string &view_id)
 Starts the recovery process, initializing the recovery thread. More...
 
int recovery_thread_handle ()
 Recovery thread main execution method. More...
 
int set_retrieved_cert_info (void *info)
 Set retrieved certification info from a group replication channel extracted from a given View_change event. More...
 
int stop_recovery (bool wait_for_termination=true)
 Stops the recovery process, shutting down the recovery thread. More...
 
int update_recovery_process (bool did_members_left, bool is_leaving)
 This method decides what action to take when a member exits the group and executes it. 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 TLS version to be used. More...
 
void set_recovery_tls_ciphersuites (const char *tls_ciphersuites)
 Set 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_completion_policy (enum_recovery_completion_policies completion_policy)
 Sets recovery threshold policy on what to wait when handling transactions. 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 public key automatically. 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...
 
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...
 
void awake_recovery_metadata_suspension (bool error=false)
 Awakes recovery thd, waiting for the donor to send recovery metadata. More...
 
void suspend_recovery_metadata ()
 Suspend recovery thd, so that member can wait to receive the recovery metadata. More...
 
bool set_recovery_metadata_message (Recovery_metadata_message *recovery_metadata_message)
 Set the recovery metadata message. More...
 
void delete_recovery_metadata_message ()
 Delete recovery metadata object. More...
 
bool is_vcle_enable ()
 Return the flag which determine if VCLE is enabled. More...
 
void set_vcle_enabled (bool is_vcle_enabled)
 Set the View ID on which the joiner joined. More...
 

Private Member Functions

void set_recovery_thread_context ()
 Sets the thread context. More...
 
void leave_group_on_recovery_failure ()
 Handles code for removing the member in case of a failure during recovery. More...
 
void clean_recovery_thread_context ()
 Cleans the recovery thread related options/structures. More...
 
int wait_for_applier_module_recovery ()
 Starts a wait process until the applier fulfills the necessary condition for the member to be acknowledge as being online. More...
 
void notify_group_recovery_end ()
 Sends a message throughout the group stating the member as online. More...
 
enum_recovery_metadata_error wait_for_recovery_metadata_gtid_executed ()
 Starts a wait process until the recovery metadata is successfully send by the donor. More...
 

Private Attributes

bool m_is_vcle_enable {false}
 Flag to determine if recovery should use VCLE. More...
 
Recovery_metadata_messagem_recovery_metadata_message {nullptr}
 Recovery metadata received on group members. More...
 
my_thread_handle recovery_pthd
 
THDrecovery_thd
 
Applier_module_interfaceapplier_module
 
std::string group_name
 
Recovery_state_transfer recovery_state_transfer
 
thread_state recovery_thd_state
 
bool recovery_aborted
 
enum_channel_until_condition m_until_condition {CHANNEL_UNTIL_VIEW_ID}
 
unsigned int m_max_metadata_wait_time
 
mysql_mutex_t run_lock
 
mysql_cond_t run_cond
 
enum_recovery_completion_policies recovery_completion_policy
 
State_transfer_status m_state_transfer_return
 
bool m_recovery_metadata_received {false}
 
bool m_recovery_metadata_received_error {false}
 Error while fetching Recovery metadata. More...
 
enum_recovery_metadata_error m_recovery_metadata_error_status
 Recovery metadata receive error status. More...
 
mysql_mutex_t m_recovery_metadata_receive_lock
 
mysql_cond_t m_recovery_metadata_receive_waiting_condition
 

Member Enumeration Documentation

◆ enum_recovery_metadata_error

Enumerator
RECOVERY_METADATA_RECEIVED_NO_ERROR 
RECOVERY_METADATA_RECEIVED_TIMEOUT_ERROR 
RECOVERY_METADATA_RECOVERY_ABORTED_ERROR 
RECOVERY_METADATA_RECEIVED_ERROR 

Constructor & Destructor Documentation

◆ Recovery_module()

Recovery_module::Recovery_module ( Applier_module_interface applier,
Channel_observation_manager channel_obsr_mngr 
)

Recovery_module constructor.

Parameters
applierreference to the applier
channel_obsr_mngrreference to the channel hooks observation manager

◆ ~Recovery_module()

Recovery_module::~Recovery_module ( )

Member Function Documentation

◆ awake_recovery_metadata_suspension()

void Recovery_module::awake_recovery_metadata_suspension ( bool  error = false)

Awakes recovery thd, waiting for the donor to send recovery metadata.

If send recovery metadata fails it sets the error, so that waiting recovery thd unblocks and stops with error, otherwise on successful receive of recovery metadata it awakes waiting recovery thd without error.

Parameters
errorError status in recovery metadata fetching.

◆ check_recovery_thread_status()

int Recovery_module::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

◆ clean_recovery_thread_context()

void Recovery_module::clean_recovery_thread_context ( )
private

Cleans the recovery thread related options/structures.

◆ delete_recovery_metadata_message()

void Recovery_module::delete_recovery_metadata_message ( )

Delete recovery metadata object.

◆ get_recovery_base_ssl_options()

void Recovery_module::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_module::get_recovery_use_ssl ( )
inline
Returns
Is recovery configured to use SSL

◆ is_own_event_channel()

bool Recovery_module::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

◆ is_vcle_enable()

bool Recovery_module::is_vcle_enable ( )

Return the flag which determine if VCLE is enabled.

Returns
the status which determine if VCLE is enabled.

◆ leave_group_on_recovery_failure()

void Recovery_module::leave_group_on_recovery_failure ( )
private

Handles code for removing the member in case of a failure during recovery.

◆ notify_group_recovery_end()

void Recovery_module::notify_group_recovery_end ( )
private

Sends a message throughout the group stating the member as online.

◆ recovery_thread_handle()

int Recovery_module::recovery_thread_handle ( )

Recovery thread main execution method.

Here, the donor is selected, the connection to the donor is established, and several safe keeping assurances are guaranteed, such as the applier being suspended.

If recovery fails or is aborted, it never makes sense to awake the applier, as that would lead to the certification and execution of transactions on the wrong context.

◆ set_applier_module()

void Recovery_module::set_applier_module ( Applier_module_interface applier)
inline

◆ set_recovery_completion_policy()

void Recovery_module::set_recovery_completion_policy ( enum_recovery_completion_policies  completion_policy)
inline

Sets recovery threshold policy on what to wait when handling transactions.

Parameters
completion_policyif recovery shall wait for execution or certification

◆ set_recovery_compression_algorithm()

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

Set compression algorithm.

◆ set_recovery_donor_reconnect_interval()

void Recovery_module::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_module::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_module::set_recovery_get_public_key ( bool  set)
inline

Get public key automatically.

◆ set_recovery_metadata_message()

bool Recovery_module::set_recovery_metadata_message ( Recovery_metadata_message recovery_metadata_message)

Set the recovery metadata message.

Parameters
[in]recovery_metadata_messagethe recovery metadata message pointer.
Returns
the error status
Return values
trueError
falseSuccess

◆ set_recovery_public_key_path()

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

Set a public key file.

◆ set_recovery_ssl_ca()

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

Set a SSL trusted certificate authorities file.

◆ set_recovery_ssl_capath()

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

Set a folder with SSL trusted CA files.

◆ set_recovery_ssl_cert()

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

Set a SSL certificate for connection.

◆ set_recovery_ssl_cipher()

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

Set a SSL ciphers to be used.

◆ set_recovery_ssl_crl()

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

Set a SSL revocation list file.

◆ set_recovery_ssl_crlpath()

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

Set a folder with SSL revocation list files.

◆ set_recovery_ssl_key()

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

Set a SSL key for connections.

◆ set_recovery_ssl_options()

void Recovery_module::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_module::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_thread_context()

void Recovery_module::set_recovery_thread_context ( )
private

Sets the thread context.

◆ set_recovery_tls_ciphersuites()

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

Set TLS ciphersuites to be used.

◆ set_recovery_tls_version()

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

Set TLS version to be used.

◆ set_recovery_use_ssl()

void Recovery_module::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_module::set_recovery_zstd_compression_level ( uint  level)
inline

Set compression level.

◆ set_retrieved_cert_info()

int Recovery_module::set_retrieved_cert_info ( void *  info)

Set retrieved certification info from a group replication channel extracted from a given View_change event.

Parameters
infothe given view_change_event
Returns
the operation status
Return values
0OK
!=0Error

◆ set_stop_wait_timeout()

void Recovery_module::set_stop_wait_timeout ( ulong  timeout)
inline

Sets the recovery shutdown timeout.

Parameters
[in]timeoutthe timeout

◆ set_vcle_enabled()

void Recovery_module::set_vcle_enabled ( bool  is_vcle_enabled)

Set the View ID on which the joiner joined.

Parameters
is_vcle_enabledthe flag determine if View_change_log_event is enabled.

◆ start_recovery()

int Recovery_module::start_recovery ( const std::string &  group_name,
const std::string &  view_id 
)

Starts the recovery process, initializing the recovery thread.

This method is designed to be as light as possible, as if it involved any major computation or wait process that would block the view change process delaying the group.

Note
this method only returns when the recovery thread is already running
Parameters
group_namethe joiner's group name
view_idthe view id to use for the recovery.
Returns
the operation status
Return values
0OK
!=0Error

◆ stop_recovery()

int Recovery_module::stop_recovery ( bool  wait_for_termination = true)

Stops the recovery process, shutting down the recovery thread.

If the thread does not stop in a user designated time interval, a timeout is issued.

Parameters
wait_for_terminationwait for thread termination or not
Note
this method only returns when the thread is stopped or on timeout
Returns
the operation status
Return values
0OK
!=0Timeout

◆ suspend_recovery_metadata()

void Recovery_module::suspend_recovery_metadata ( )

Suspend recovery thd, so that member can wait to receive the recovery metadata.

◆ update_recovery_process()

int Recovery_module::update_recovery_process ( bool  did_members_left,
bool  is_leaving 
)

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

It can for the joiner: If it exited, then terminate the recovery process. 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
is_leavingtrue if the member is leaving the group
Returns
the operation status
Return values
0OK
!=0Error

◆ wait_for_applier_module_recovery()

int Recovery_module::wait_for_applier_module_recovery ( )
private

Starts a wait process until the applier fulfills the necessary condition for the member to be acknowledge as being online.

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

◆ wait_for_recovery_metadata_gtid_executed()

Recovery_module::enum_recovery_metadata_error Recovery_module::wait_for_recovery_metadata_gtid_executed ( )
private

Starts a wait process until the recovery metadata is successfully send by the donor.

Returns
the error status. Check enum_recovery_metadata_error for details.

Member Data Documentation

◆ applier_module

Applier_module_interface* Recovery_module::applier_module
private

◆ group_name

std::string Recovery_module::group_name
private

◆ m_is_vcle_enable

bool Recovery_module::m_is_vcle_enable {false}
private

Flag to determine if recovery should use VCLE.

◆ m_max_metadata_wait_time

unsigned int Recovery_module::m_max_metadata_wait_time
private

◆ m_recovery_metadata_error_status

enum_recovery_metadata_error Recovery_module::m_recovery_metadata_error_status
private

Recovery metadata receive error status.

◆ m_recovery_metadata_message

Recovery_metadata_message* Recovery_module::m_recovery_metadata_message {nullptr}
private

Recovery metadata received on group members.

◆ m_recovery_metadata_receive_lock

mysql_mutex_t Recovery_module::m_recovery_metadata_receive_lock
private

◆ m_recovery_metadata_receive_waiting_condition

mysql_cond_t Recovery_module::m_recovery_metadata_receive_waiting_condition
private

◆ m_recovery_metadata_received

bool Recovery_module::m_recovery_metadata_received {false}
private

◆ m_recovery_metadata_received_error

bool Recovery_module::m_recovery_metadata_received_error {false}
private

Error while fetching Recovery metadata.

◆ m_state_transfer_return

State_transfer_status Recovery_module::m_state_transfer_return
private

◆ m_until_condition

enum_channel_until_condition Recovery_module::m_until_condition {CHANNEL_UNTIL_VIEW_ID}
private

◆ recovery_aborted

bool Recovery_module::recovery_aborted
private

◆ recovery_completion_policy

enum_recovery_completion_policies Recovery_module::recovery_completion_policy
private

◆ recovery_pthd

my_thread_handle Recovery_module::recovery_pthd
private

◆ recovery_state_transfer

Recovery_state_transfer Recovery_module::recovery_state_transfer
private

◆ recovery_thd

THD* Recovery_module::recovery_thd
private

◆ recovery_thd_state

thread_state Recovery_module::recovery_thd_state
private

◆ run_cond

mysql_cond_t Recovery_module::run_cond
private

◆ run_lock

mysql_mutex_t Recovery_module::run_lock
private

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