MySQL 8.3.0
Source Code Documentation
Replication_thread_api Class Reference

#include <replication_threads_api.h>

Public Member Functions

 Replication_thread_api (const char *channel_interface)
 
 Replication_thread_api ()
 
 ~Replication_thread_api ()=default
 
void set_channel_name (const char *channel_name)
 Set the channel name to be used on the interface method invocation. More...
 
int initialize_channel (char *hostname, uint port, char *user, char *password, bool use_ssl, char *ssl_ca, char *ssl_capath, char *ssl_cert, char *ssl_cipher, char *ssl_key, char *ssl_crl, char *ssl_crlpath, bool ssl_verify_server_cert, int priority, int retry_count, bool preserve_logs, char *public_key_path, bool get_public_key, char *compression_algorithm, uint zstd_compression_level, char *tls_version, char *tls_ciphersuites, bool ignore_ws_mem_limit, bool allow_drop_write_set)
 Initializes a channel connection in a similar way to a change master command. More...
 
int start_threads (bool start_receiver, bool start_applier, std::string *view_id, bool wait_for_connection, enum_channel_until_condition until_condition=CHANNEL_UNTIL_VIEW_ID)
 Start the Applier/Receiver threads according to the given options. More...
 
int stop_threads (bool stop_receiver, bool stop_applier)
 Stops the channel threads according to the given options. More...
 
int purge_logs (bool reset_all)
 Purges the relay logs. More...
 
bool is_receiver_thread_running ()
 Checks if the receiver thread is running. More...
 
bool is_receiver_thread_stopping ()
 Checks if the receiver thread is stopping. More...
 
bool is_applier_thread_running ()
 Checks if the applier thread is running. More...
 
bool is_applier_thread_stopping ()
 Checks if the applier thread is stopping. More...
 
int queue_packet (const char *buf, ulong event_len)
 Queues a event packet into the current active channel relay log. More...
 
bool is_applier_thread_waiting ()
 Checks if the applier, and its workers when parallel applier is enabled, has already consumed all relay log, that is, applier is waiting for transactions to be queued. More...
 
int wait_for_gtid_execution (double timeout)
 Checks if all the queued transactions were executed. More...
 
int wait_for_gtid_execution (std::string &retrieved_set, double timeout, bool update_THD_status=true)
 Checks if all the set transactions were executed. More...
 
int get_applier_thread_ids (unsigned long **thread_ids)
 Method to get applier ids from the configured channel. More...
 
bool is_own_event_applier (my_thread_id id, const char *channel_name=nullptr)
 Checks if the given id matches any of the event applying threads for the configured channel. More...
 
bool is_own_event_receiver (my_thread_id id)
 Checks if the given id matches the receiver thread for the configured channel. More...
 
rpl_gno get_last_delivered_gno (rpl_sidno sidno)
 Returns last GNO from the applier for a given UUID. More...
 
void set_stop_wait_timeout (ulong timeout)
 Sets the threads shutdown timeout. More...
 
bool get_retrieved_gtid_set (std::string &retrieved_set, const char *channel_name=nullptr)
 Returns the retrieved gtid set from the receiver thread. More...
 
bool is_partial_transaction_on_relay_log ()
 Checks if the channel's relay log contains partial transaction. More...
 
bool get_channel_credentials (std::string &username, std::string &password, const char *channel_name=nullptr)
 Method to get the credentials configured for a channel. More...
 
bool get_channel_network_namespace (std::string &net_ns, const char *channel_name=nullptr)
 Method to get the network namespace configured for a channel. More...
 
bool is_any_channel_using_uuid_for_assign_gtids_to_anonymous_transaction (const char *uuid_param)
 Checks if any channel uses the same UUID for assign_gtids_to_anonymous_transactions as the given uuid. More...
 

Static Public Member Functions

static int rpl_channel_stop_all (int threads_to_stop, long timeout)
 Interface to Channel Service Interface channel_stop_all method. More...
 
static int rpl_binlog_dump_thread_kill ()
 Interface to kill binlog dump thread. More...
 
static int delete_credential (const char *channel_name)
 Interface to remove stored credentials from thread api. More...
 

Private Attributes

ulong stop_wait_timeout
 
const char * interface_channel
 

Constructor & Destructor Documentation

◆ Replication_thread_api() [1/2]

Replication_thread_api::Replication_thread_api ( const char *  channel_interface)

◆ Replication_thread_api() [2/2]

Replication_thread_api::Replication_thread_api ( )

◆ ~Replication_thread_api()

Replication_thread_api::~Replication_thread_api ( )
default

Member Function Documentation

◆ delete_credential()

int Replication_thread_api::delete_credential ( const char *  channel_name)
static

Interface to remove stored credentials from thread api.

Removes credentials for the channel from thread api.

Parameters
channel_nameCredential associated channel name
Returns
the operation status
Return values
0OK
!=0Error

◆ get_applier_thread_ids()

int Replication_thread_api::get_applier_thread_ids ( unsigned long **  thread_ids)

Method to get applier ids from the configured channel.

Parameters
[out]thread_idsThe retrieved thread ids.
Returns
the number of appliers
Return values
<=0 Some error occurred or the applier is not present
>0 Number of appliers

◆ get_channel_credentials()

bool Replication_thread_api::get_channel_credentials ( std::string &  username,
std::string &  password,
const char *  channel_name = nullptr 
)

Method to get the credentials configured for a channel.

Parameters
[out]usernameThe user to extract
[out]passwordThe password to extract
[in]channel_nameThe name of the channel to get the information.
Returns
the operation status
Return values
falseOK
trueError, channel not found

◆ get_channel_network_namespace()

bool Replication_thread_api::get_channel_network_namespace ( std::string &  net_ns,
const char *  channel_name = nullptr 
)

Method to get the network namespace configured for a channel.

Parameters
[out]net_nsThe network namespace to extract
[in]channel_nameThe name of the channel to get the information.
Returns
the operation status
Return values
falseOK
trueError, channel not found

◆ get_last_delivered_gno()

rpl_gno Replication_thread_api::get_last_delivered_gno ( rpl_sidno  sidno)

Returns last GNO from the applier for a given UUID.

Parameters
sidnothe SIDNO of the group UUID, so that we get the last GNO of group's already certified transactions on relay log.
Return values
GNOvalue

◆ get_retrieved_gtid_set()

bool Replication_thread_api::get_retrieved_gtid_set ( std::string &  retrieved_set,
const char *  channel_name = nullptr 
)

Returns the retrieved gtid set from the receiver thread.

Parameters
[out]retrieved_setthe set in string format.
channel_namethe name of the channel to get the information.
Return values
truethere was an error.
falsethe operation has succeeded.

◆ initialize_channel()

int Replication_thread_api::initialize_channel ( char *  hostname,
uint  port,
char *  user,
char *  password,
bool  use_ssl,
char *  ssl_ca,
char *  ssl_capath,
char *  ssl_cert,
char *  ssl_cipher,
char *  ssl_key,
char *  ssl_crl,
char *  ssl_crlpath,
bool  ssl_verify_server_cert,
int  priority,
int  retry_count,
bool  preserve_logs,
char *  public_key_path,
bool  get_public_key,
char *  compression_algorithm,
uint  zstd_compression_level,
char *  tls_version,
char *  tls_ciphersuites,
bool  ignore_ws_mem_limit,
bool  allow_drop_write_set 
)

Initializes a channel connection in a similar way to a change master command.

Parameters
hostnameThe channel hostname
portThe channel port
userThe user used in the receiver connection
passwordThe password used in the receiver connection
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
priorityThe channel priority on event application
retry_countThe number of retries when connecting
preserve_logsIf logs should be always preserved
public_key_pathThe file with public key path information
get_public_keyPreference to get public key if unavailable.
compression_algorithmThe compression algorithm
zstd_compression_levelThe compression level
tls_versionTLS versions
tls_ciphersuitesPermissible ciphersuites for TLS 1.3.
ignore_ws_mem_limitShall ignore write set mem limits
allow_drop_write_setShall not require write set to be preserved
Returns
the operation status
Return values
0OK
!=0Error on channel creation

◆ is_any_channel_using_uuid_for_assign_gtids_to_anonymous_transaction()

bool Replication_thread_api::is_any_channel_using_uuid_for_assign_gtids_to_anonymous_transaction ( const char *  uuid_param)

Checks if any channel uses the same UUID for assign_gtids_to_anonymous_transactions as the given uuid.

Parameters
[in]uuid_paramthe group name
Return values
trueat least one channel has the same uuid
falsenone of the the channels have the same uuid

◆ is_applier_thread_running()

bool Replication_thread_api::is_applier_thread_running ( )

Checks if the applier thread is running.

Returns
the thread status
Return values
truethe thread is running
falsethe thread is stopped

◆ is_applier_thread_stopping()

bool Replication_thread_api::is_applier_thread_stopping ( )

Checks if the applier thread is stopping.

Returns
the thread status
Return values
truethe thread is stopping
falsethe thread is not stopping

◆ is_applier_thread_waiting()

bool Replication_thread_api::is_applier_thread_waiting ( )

Checks if the applier, and its workers when parallel applier is enabled, has already consumed all relay log, that is, applier is waiting for transactions to be queued.

Returns
the applier status
Return values
truethe applier is waiting
falseotherwise

◆ is_own_event_applier()

bool Replication_thread_api::is_own_event_applier ( my_thread_id  id,
const char *  channel_name = nullptr 
)

Checks if the given id matches any of the event applying threads for the configured channel.

Parameters
idthe thread id
channel_namethe channel name which needs to be checked. It is an optional parameter.
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_own_event_receiver()

bool Replication_thread_api::is_own_event_receiver ( my_thread_id  id)

Checks if the given id matches the receiver thread for the configured channel.

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

◆ is_partial_transaction_on_relay_log()

bool Replication_thread_api::is_partial_transaction_on_relay_log ( )

Checks if the channel's relay log contains partial transaction.

Return values
trueIf relaylog contains partial transaction.
falseIf relaylog does not contain partial transaction.

◆ is_receiver_thread_running()

bool Replication_thread_api::is_receiver_thread_running ( )

Checks if the receiver thread is running.

Returns
the thread status
Return values
truethe thread is running
falsethe thread is stopped

◆ is_receiver_thread_stopping()

bool Replication_thread_api::is_receiver_thread_stopping ( )

Checks if the receiver thread is stopping.

Returns
the thread status
Return values
truethe thread is stopping
falsethe thread is not stopping

◆ purge_logs()

int Replication_thread_api::purge_logs ( bool  reset_all)

Purges the relay logs.

Parameters
reset_allIf true, the method will purge logs and remove the channel If false, the channel logs will be deleted and recreated but the channel info will be preserved.
Returns
the operation status
Return values
0OK
!=0Error purging channel logs

◆ queue_packet()

int Replication_thread_api::queue_packet ( const char *  buf,
ulong  event_len 
)

Queues a event packet into the current active channel relay log.

Parameters
bufthe event buffer
event_lenthe event buffer length
Returns
the operation status
Return values
0OK
!=0 Error on queue

◆ rpl_binlog_dump_thread_kill()

int Replication_thread_api::rpl_binlog_dump_thread_kill ( )
static

Interface to kill binlog dump thread.

Kills binlog dump thread thus killing all slave connections.

Note
binlog dump GTID thread is not killed as of now.
Returns
the operation status
Return values
0OK

◆ rpl_channel_stop_all()

int Replication_thread_api::rpl_channel_stop_all ( int  threads_to_stop,
long  timeout 
)
static

Interface to Channel Service Interface channel_stop_all method.

Stops all the running channel threads according to the given options.

Parameters
threads_to_stopThe types of threads to be stopped
timeoutThe max time in which the thread should stop
Returns
the operation status
Return values
0OK
!=0Error

◆ set_channel_name()

void Replication_thread_api::set_channel_name ( const char *  channel_name)
inline

Set the channel name to be used on the interface method invocation.

Parameters
channel_namethe name to be used.

◆ set_stop_wait_timeout()

void Replication_thread_api::set_stop_wait_timeout ( ulong  timeout)
inline

Sets the threads shutdown timeout.

Parameters
[in]timeoutthe timeout

◆ start_threads()

int Replication_thread_api::start_threads ( bool  start_receiver,
bool  start_applier,
std::string *  view_id,
bool  wait_for_connection,
enum_channel_until_condition  until_condition = CHANNEL_UNTIL_VIEW_ID 
)

Start the Applier/Receiver threads according to the given options.

If the receiver thread is to be started, connection credential must be supported.

Parameters
start_receiverIs the receiver thread to be started
start_applierIs the applier thread to be started
view_idThe view id, that can be used to activate the until view id clause.
wait_for_connectionIf when starting the receiver, the method should wait for the connection to succeed
until_conditionthe replication until condition that can be applied to channels for the recovery.
Returns
the operation status
Return values
0OK
REPLICATION_THREAD_START_ERRORError when launching on of the threads
REPLICATION_THREAD_START_IO_NOT_CONNECTEDError when the threads start, but the IO thread cannot connect

◆ stop_threads()

int Replication_thread_api::stop_threads ( bool  stop_receiver,
bool  stop_applier 
)

Stops the channel threads according to the given options.

Parameters
stop_receiverif the receiver thread should be stopped
stop_applierif the applier thread should be stopped
Returns
the operation status
Return values
0OK
!=0Error stopping channel thread

◆ wait_for_gtid_execution() [1/2]

int Replication_thread_api::wait_for_gtid_execution ( double  timeout)

Checks if all the queued transactions were executed.

Parameters
timeoutthe time (seconds) after which the method returns if the above condition was not satisfied
Returns
the operation status
Return values
0All transactions were executed
REPLICATION_THREAD_WAIT_TIMEOUT_ERRORA timeout occurred
REPLICATION_THREAD_WAIT_NO_INFO_ERRORAn error occurred

◆ wait_for_gtid_execution() [2/2]

int Replication_thread_api::wait_for_gtid_execution ( std::string &  retrieved_set,
double  timeout,
bool  update_THD_status = true 
)

Checks if all the set transactions were executed.

Parameters
retrieved_setthe set in string format of transaction to wait for
timeoutthe time (seconds) after which the method returns if the above condition was not satisfied
update_THD_statusShall the method update the THD stage
Returns
the operation status
Return values
0All transactions were executed
REPLICATION_THREAD_WAIT_TIMEOUT_ERRORA timeout occurred
REPLICATION_THREAD_WAIT_NO_INFO_ERRORAn error occurred

Member Data Documentation

◆ interface_channel

const char* Replication_thread_api::interface_channel
private

◆ stop_wait_timeout

ulong Replication_thread_api::stop_wait_timeout
private

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