MySQL  8.0.16
Source Code Documentation
rpl_channel_service_interface.h File Reference
#include <string>

Go to the source code of this file.

Classes

struct  Channel_ssl_info
 
SSL information to be used when creating a channel. More...
 
struct  Channel_creation_info
 
Creation information for a channel. More...
 
struct  Channel_connection_info
 Channel information to connect to a receiver. More...
 

Macros

#define RPL_CHANNEL_SERVICE_RECEIVER_CONNECTION_ERROR   -1
 
#define RPL_CHANNEL_SERVICE_DEFAULT_CHANNEL_CREATION_ERROR   -2
 
#define RPL_CHANNEL_SERVICE_SLAVE_SKIP_COUNTER_ACTIVE   -3
 
#define RPL_CHANNEL_SERVICE_CHANNEL_DOES_NOT_EXISTS_ERROR   -4
 
#define REPLICATION_THREAD_WAIT_TIMEOUT_ERROR   -1
 
#define REPLICATION_THREAD_WAIT_NO_INFO_ERROR   -2
 
#define RPL_SERVICE_SERVER_DEFAULT   -1
 

Enumerations

enum  enum_channel_type { SLAVE_REPLICATION_CHANNEL, GROUP_REPLICATION_CHANNEL }
 Types of channels. More...
 
enum  enum_multi_threaded_workers_type { CHANNEL_MTS_PARALLEL_TYPE_DB_NAME, CHANNEL_MTS_PARALLEL_TYPE_LOGICAL_CLOCK }
 Know parallelization options that can be applied to channel appliers. More...
 
enum  enum_channel_thread_types { CHANNEL_NO_THD = 0, CHANNEL_RECEIVER_THREAD = 1, CHANNEL_APPLIER_THREAD = 2 }
 The known types of channel threads. More...
 
enum  enum_channel_until_condition {
  CHANNEL_NO_UNTIL_CONDITION, CHANNEL_UNTIL_APPLIER_BEFORE_GTIDS, CHANNEL_UNTIL_APPLIER_AFTER_GTIDS, CHANNEL_UNTIL_APPLIER_AFTER_GAPS,
  CHANNEL_UNTIL_VIEW_ID
}
 The known until conditions that can be applied to channels. More...
 
enum  enum_slave_channel_status { SLAVE_CHANNEL_NO_APPLIER_RUNNING_AND_NO_OPEN_TEMPORARY_TABLE = 0, SLAVE_CHANNEL_APPLIER_IS_RUNNING, SLAVE_CHANNEL_HAS_OPEN_TEMPORARY_TABLE }
 Return type for function has_any_slave_channel_open_temp_table_or_is_its_applier_running() More...
 

Functions

void initialize_channel_ssl_info (Channel_ssl_info *channel_ssl_info)
 
void initialize_channel_creation_info (Channel_creation_info *channel_info)
 
void initialize_channel_connection_info (Channel_connection_info *channel_info)
 
int channel_create (const char *channel, Channel_creation_info *channel_information)
 Initializes a channel connection in a similar way to a change master command. More...
 
int channel_start (const char *channel, Channel_connection_info *connection_info, int threads_to_start, int wait_for_connection)
 Start the Applier/Receiver threads according to the given options. More...
 
int channel_stop (const char *channel, int threads_to_stop, long timeout)
 Stops the channel threads according to the given options. More...
 
int channel_stop_all (int threads_to_stop, long timeout, std::string *error_message)
 Stops all the running channel threads according to the given options. More...
 
int channel_purge_queue (const char *channel, bool reset_all)
 Purges the channel logs. More...
 
bool channel_is_active (const char *channel, enum_channel_thread_types type)
 Tells if the selected component of the channel is active or not. More...
 
int channel_get_thread_id (const char *channel, enum_channel_thread_types thread_type, unsigned long **thread_id)
 Returns the id(s) of the channel threads: receiver or applier. More...
 
long long channel_get_last_delivered_gno (const char *channel, int sidno)
 Returns last GNO from applier from a given UUID. More...
 
int channel_add_executed_gtids_to_received_gtids (const char *channel)
 Adds server executed GTID set to channel received GTID set. More...
 
int channel_queue_packet (const char *channel, const char *buf, unsigned long len)
 Queues a event packet into the current active channel. More...
 
int channel_wait_until_apply_queue_applied (const char *channel, double timeout)
 Checks if all the queued transactions were executed. More...
 
int channel_wait_until_transactions_applied (const char *channel, const char *gtid_set, double timeout, bool update_THD_status=true)
 Checks if all the transactions in the given set were executed. More...
 
int channel_is_applier_waiting (const char *channel)
 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 channel_is_applier_thread_waiting (unsigned long thread_id, bool worker=false)
 Checks if the applier thread, and its workers when parallel applier is enabled, has already consumed all relay log, that is, applier thread is waiting for transactions to be queued. More...
 
int channel_flush (const char *channel)
 Flush the channel. More...
 
int initialize_channel_service_interface ()
 Initializes channel structures if needed. More...
 
int channel_get_retrieved_gtid_set (const char *channel, char **retrieved_set)
 Returns the receiver thread retrieved GTID set in string format. More...
 
bool channel_is_stopping (const char *channel, enum_channel_thread_types type)
 Tells if the selected component of the channel is stopping or not. More...
 
bool is_partial_transaction_on_channel_relay_log (const char *channel)
 Checks if the given channel's relaylog contains a partial transaction. More...
 
bool is_any_slave_channel_running (int thread_mask)
 Checks if any slave threads of any channel is running. More...
 
enum_slave_channel_status has_any_slave_channel_open_temp_table_or_is_its_applier_running ()
 Checks if any slave channel applier is running or any slave channel has open temporary table(s). More...
 

Macro Definition Documentation

◆ REPLICATION_THREAD_WAIT_NO_INFO_ERROR

#define REPLICATION_THREAD_WAIT_NO_INFO_ERROR   -2

◆ REPLICATION_THREAD_WAIT_TIMEOUT_ERROR

#define REPLICATION_THREAD_WAIT_TIMEOUT_ERROR   -1

◆ RPL_CHANNEL_SERVICE_CHANNEL_DOES_NOT_EXISTS_ERROR

#define RPL_CHANNEL_SERVICE_CHANNEL_DOES_NOT_EXISTS_ERROR   -4

◆ RPL_CHANNEL_SERVICE_DEFAULT_CHANNEL_CREATION_ERROR

#define RPL_CHANNEL_SERVICE_DEFAULT_CHANNEL_CREATION_ERROR   -2

◆ RPL_CHANNEL_SERVICE_RECEIVER_CONNECTION_ERROR

#define RPL_CHANNEL_SERVICE_RECEIVER_CONNECTION_ERROR   -1

◆ RPL_CHANNEL_SERVICE_SLAVE_SKIP_COUNTER_ACTIVE

#define RPL_CHANNEL_SERVICE_SLAVE_SKIP_COUNTER_ACTIVE   -3

◆ RPL_SERVICE_SERVER_DEFAULT

#define RPL_SERVICE_SERVER_DEFAULT   -1

Enumeration Type Documentation

◆ enum_channel_thread_types

The known types of channel threads.

All new types should be power of 2

Enumerator
CHANNEL_NO_THD 
CHANNEL_RECEIVER_THREAD 
CHANNEL_APPLIER_THREAD 

◆ enum_channel_type

Types of channels.

Enumerator
SLAVE_REPLICATION_CHANNEL 
GROUP_REPLICATION_CHANNEL 

◆ enum_channel_until_condition

The known until conditions that can be applied to channels.

Enumerator
CHANNEL_NO_UNTIL_CONDITION 
CHANNEL_UNTIL_APPLIER_BEFORE_GTIDS 
CHANNEL_UNTIL_APPLIER_AFTER_GTIDS 
CHANNEL_UNTIL_APPLIER_AFTER_GAPS 
CHANNEL_UNTIL_VIEW_ID 

◆ enum_multi_threaded_workers_type

Know parallelization options that can be applied to channel appliers.

Enumerator
CHANNEL_MTS_PARALLEL_TYPE_DB_NAME 
CHANNEL_MTS_PARALLEL_TYPE_LOGICAL_CLOCK 

◆ enum_slave_channel_status

Return type for function has_any_slave_channel_open_temp_table_or_is_its_applier_running()

Enumerator
SLAVE_CHANNEL_NO_APPLIER_RUNNING_AND_NO_OPEN_TEMPORARY_TABLE 
SLAVE_CHANNEL_APPLIER_IS_RUNNING 
SLAVE_CHANNEL_HAS_OPEN_TEMPORARY_TABLE 

Function Documentation

◆ channel_add_executed_gtids_to_received_gtids()

int channel_add_executed_gtids_to_received_gtids ( const char *  channel)

Adds server executed GTID set to channel received GTID set.

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

◆ channel_create()

int channel_create ( const char *  channel,
Channel_creation_info channel_information 
)

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

Note
If the channel exists, it is reconfigured with the new options. About the logs, the preserve_relay_logs option allows the user to maintain them untouched.
Parameters
channelThe channel name
channel_informationChannel creation information.
Returns
the operation status
Return values
0OK
!=0Error on channel creation

◆ channel_flush()

int channel_flush ( const char *  channel)

Flush the channel.

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

◆ channel_get_last_delivered_gno()

long long channel_get_last_delivered_gno ( const char *  channel,
int  sidno 
)

Returns last GNO from applier from a given UUID.

Parameters
channelthe channel name
sidnothe uuid associated to the desired gno
Returns
the last applier gno
Return values
<0the channel does no exists, or the applier is not present
>0the gno

◆ channel_get_retrieved_gtid_set()

int channel_get_retrieved_gtid_set ( const char *  channel,
char **  retrieved_set 
)

Returns the receiver thread retrieved GTID set in string format.

Parameters
channelThe channel name.
[out]retrieved_setPointer to pointer to string. The function will set it to point to a newly allocated buffer, or NULL on out of memory.
Returns
the operation status
Return values
0OK
!=0Error on retrieval

◆ channel_get_thread_id()

int channel_get_thread_id ( const char *  channel,
enum_channel_thread_types  thread_type,
unsigned long **  thread_id 
)

Returns the id(s) of the channel threads: receiver or applier.

If more than one applier exists, an array is returned, on which first index is coordinator thread id.

Parameters
[in]channelThe channel name
[in]thread_typeThe thread type (receiver or applier)
[out]thread_idThe array of id(s)
Returns
the number of returned ids
Return values
-1the channel does no exists, or the thread is not present
>0the number of thread ids returned.

◆ channel_is_active()

bool channel_is_active ( const char *  channel,
enum_channel_thread_types  type 
)

Tells if the selected component of the channel is active or not.

If no component is passed, this method returns if the channel exists or not

Parameters
channelThe channel name
typeThe thread that should be checked. If 0, this method applies to the channel existence.
Returns
is the channel (component) active
Return values
trueYes
falseNo

◆ channel_is_applier_thread_waiting()

int channel_is_applier_thread_waiting ( unsigned long  thread_id,
bool  worker = false 
)

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

Parameters
thread_idthe applier thread id to check
workerflag to indicate if thread is a parallel worker
Returns
the operation status
Return values
-1Unable to find applier thread
0Applier thread is not waiting
1Applier thread is waiting

◆ channel_is_applier_waiting()

int channel_is_applier_waiting ( const char *  channel)

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.

Parameters
channelThe channel name
Returns
the operation status
Return values
<0Error
0Applier is not waiting
1Applier is waiting

◆ channel_is_stopping()

bool channel_is_stopping ( const char *  channel,
enum_channel_thread_types  type 
)

Tells if the selected component of the channel is stopping or not.

Parameters
channelThe channel name
typeThe thread that should be checked.
Returns
is the channel (component) stopping
Return values
trueYes
falseNo, no type was specified or the channel does not exist.

◆ channel_purge_queue()

int channel_purge_queue ( const char *  channel,
bool  reset_all 
)

Purges the channel logs.

Parameters
channelThe channel name
reset_allIf true, the method will purge logs and remove the channel If false, only the channel information will be reset.
Returns
the operation status
Return values
0OK
!=0Error

◆ channel_queue_packet()

int channel_queue_packet ( const char *  channel,
const char *  buf,
unsigned long  len 
)

Queues a event packet into the current active channel.

Parameters
channelthe channel name
bufthe event buffer
lenthe event buffer length
Returns
the operation status
Return values
0OK
!=0 Error on queue

◆ channel_start()

int channel_start ( const char *  channel,
Channel_connection_info connection_info,
int  threads_to_start,
int  wait_for_connection 
)

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

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

Parameters
channelThe channel name
connection_infoChannel connection information
threads_to_startThe types of threads to be started
wait_for_connectionIf when starting the receiver, the method should wait for the connection to succeed
Returns
the operation status
Return values
0OK
!=0Error

◆ channel_stop()

int channel_stop ( const char *  channel,
int  threads_to_stop,
long  timeout 
)

Stops the channel threads according to the given options.

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

◆ channel_stop_all()

int channel_stop_all ( int  threads_to_stop,
long  timeout,
std::string *  error_message 
)

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

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

◆ channel_wait_until_apply_queue_applied()

int channel_wait_until_apply_queue_applied ( const char *  channel,
double  timeout 
)

Checks if all the queued transactions were executed.

Note
This method assumes that the channel is not receiving any more events. If it is still receiving, then the method should wait for execution of transactions that were present when this method was invoked.
Parameters
channelthe channel name
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

◆ channel_wait_until_transactions_applied()

int channel_wait_until_transactions_applied ( const char *  channel,
const char *  gtid_set,
double  timeout,
bool  update_THD_status = true 
)

Checks if all the transactions in the given set were executed.

Parameters
channelthe channel name
gtid_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

◆ has_any_slave_channel_open_temp_table_or_is_its_applier_running()

enum_slave_channel_status has_any_slave_channel_open_temp_table_or_is_its_applier_running ( )

Checks if any slave channel applier is running or any slave channel has open temporary table(s).

This holds handled appliers' run_locks until finding a running slave channel applier or a slave channel which has open temporary table(s), or handling all slave channels.

Returns
SLAVE_CHANNEL_NO_APPLIER_RUNNING_AND_NO_OPEN_TEMPORARY_TABLE, SLAVE_CHANNEL_APPLIER_IS_RUNNING or SLAVE_CHANNEL_HAS_OPEN_TEMPORARY_TABLE.

◆ initialize_channel_connection_info()

void initialize_channel_connection_info ( Channel_connection_info channel_info)

◆ initialize_channel_creation_info()

void initialize_channel_creation_info ( Channel_creation_info channel_info)

◆ initialize_channel_service_interface()

int initialize_channel_service_interface ( )

Initializes channel structures if needed.

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

◆ initialize_channel_ssl_info()

void initialize_channel_ssl_info ( Channel_ssl_info channel_ssl_info)

◆ is_any_slave_channel_running()

bool is_any_slave_channel_running ( int  thread_mask)

Checks if any slave threads of any channel is running.

Parameters
[in]thread_masktype of slave thread- IO/SQL or any
Returns
Return values
trueatleast one channel threads are running.
falsenone of the the channels are running.

◆ is_partial_transaction_on_channel_relay_log()

bool is_partial_transaction_on_channel_relay_log ( const char *  channel)

Checks if the given channel's relaylog contains a partial transaction.

Parameters
channelThe channel name
Returns
Return values
trueIf relaylog contains partial transcation.
falseIf relaylog does not contain partial transaction.