MySQL 8.0.40
Source Code Documentation
|
#include "sql/rpl_source.h"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <memory>
#include <unordered_map>
#include <utility>
#include "m_ctype.h"
#include "m_string.h"
#include "map_helpers.h"
#include "mutex_lock.h"
#include "my_byteorder.h"
#include "my_command.h"
#include "my_dbug.h"
#include "my_io.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_mutex_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/service_mysql_alloc.h"
#include "mysqld_error.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/binlog.h"
#include "sql/current_thd.h"
#include "sql/debug_sync.h"
#include "sql/item.h"
#include "sql/item_func.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/mysqld_thd_manager.h"
#include "sql/protocol.h"
#include "sql/protocol_classic.h"
#include "sql/psi_memory_key.h"
#include "sql/rpl_binlog_sender.h"
#include "sql/rpl_filter.h"
#include "sql/rpl_group_replication.h"
#include "sql/rpl_gtid.h"
#include "sql/rpl_handler.h"
#include "sql/rpl_utility.h"
#include "sql/sql_class.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/system_variables.h"
#include "sql_string.h"
#include "thr_mutex.h"
#include "typelib.h"
Classes | |
class | Find_zombie_dump_thread |
Callback function used by kill_zombie_dump_threads() function to to find zombie dump thread from the thd list. More... | |
Macros | |
#define | get_object(p, obj, msg) |
#define | CHECK_PACKET_SIZE(BYTES) |
If there are less than BYTES bytes left to read in the packet, report error. More... | |
#define | READ(DECODE, BYTES) |
Auxiliary macro used to define READ_INT and READ_STRING. More... | |
#define | READ_INT(VAR, BYTES) READ(VAR = uint##BYTES##korr(packet_position), BYTES) |
Check that there are at least BYTES more bytes to read, then read the bytes and decode them into the given integer VAR, then advance the reading position. More... | |
#define | READ_STRING(VAR, BYTES, BUFFER_SIZE) |
Check that there are at least BYTES more bytes to read and that BYTES+1 is not greater than BUFFER_SIZE, then read the bytes into the given variable VAR, then advance the reading position. More... | |
Functions | |
resource_blocker::Resource & | get_dump_thread_resource () |
static bool | check_and_report_dump_thread_blocked (resource_blocker::User &rpl_user) |
int | register_replica (THD *thd, uchar *packet, size_t packet_length) |
Register slave in 'slave_list' hash table. More... | |
void | unregister_replica (THD *thd, bool only_mine, bool need_lock_slave_list) |
bool | show_replicas (THD *thd) |
Execute a SHOW REPLICAS / SHOW SLAVE HOSTS statement. More... | |
bool | com_binlog_dump (THD *thd, char *packet, size_t packet_length) |
Process a COM_BINLOG_DUMP packet. More... | |
bool | com_binlog_dump_gtid (THD *thd, char *packet, size_t packet_length) |
Process a COM_BINLOG_DUMP_GTID packet. More... | |
void | mysql_binlog_send (THD *thd, char *log_ident, my_off_t pos, Gtid_set *slave_gtid_executed, uint32 flags) |
Low-level function where the dump thread iterates over the binary log and sends events to the slave. More... | |
const user_var_entry * | get_user_var_from_alternatives (const THD *thd, const std::string alt1, const std::string alt2) |
Read a user variable that may exist under two different names. More... | |
String * | get_replica_uuid (THD *thd, String *value) |
An auxiliary function extracts slave UUID. More... | |
void | kill_zombie_dump_threads (THD *thd) |
bool | reset_master (THD *thd, bool unlock_global_read_lock) |
Execute a RESET MASTER statement. More... | |
bool | show_master_status (THD *thd) |
Execute a SHOW MASTER STATUS statement. More... | |
bool | show_binlogs (THD *thd) |
Execute a SHOW BINARY LOGS statement. More... | |
Variables | |
int | max_binlog_dump_events = 0 |
bool | opt_sporadic_binlog_dump_fail = false |
malloc_unordered_map< uint32, unique_ptr_my_free< REPLICA_INFO > > | slave_list |
TYPELIB | binlog_checksum_typelib |
#define CHECK_PACKET_SIZE | ( | BYTES | ) |
If there are less than BYTES bytes left to read in the packet, report error.
#define get_object | ( | p, | |
obj, | |||
msg | |||
) |
#define READ | ( | DECODE, | |
BYTES | |||
) |
Auxiliary macro used to define READ_INT and READ_STRING.
Check that there are at least BYTES more bytes to read, then read the bytes using the given DECODER, then advance the reading position.
Check that there are at least BYTES more bytes to read, then read the bytes and decode them into the given integer VAR, then advance the reading position.
#define READ_STRING | ( | VAR, | |
BYTES, | |||
BUFFER_SIZE | |||
) |
Check that there are at least BYTES more bytes to read and that BYTES+1 is not greater than BUFFER_SIZE, then read the bytes into the given variable VAR, then advance the reading position.
|
static |
bool com_binlog_dump | ( | THD * | thd, |
char * | packet, | ||
size_t | packet_length | ||
) |
Process a COM_BINLOG_DUMP packet.
This function parses the packet and then calls mysql_binlog_send.
thd | The dump thread. |
packet | The COM_BINLOG_DUMP packet. |
packet_length | The length of the packet in bytes. |
true | Error |
false | Success |
bool com_binlog_dump_gtid | ( | THD * | thd, |
char * | packet, | ||
size_t | packet_length | ||
) |
Process a COM_BINLOG_DUMP_GTID packet.
This function parses the packet and then calls mysql_binlog_send.
thd | The dump thread. |
packet | The COM_BINLOG_DUMP_GTID packet. |
packet_length | The length of the packet in bytes. |
true | Error |
false | Success |
resource_blocker::Resource & get_dump_thread_resource | ( | ) |
An auxiliary function extracts slave UUID.
[in] | thd | THD to access a user variable |
[out] | value | String to return UUID value. |
const user_var_entry * get_user_var_from_alternatives | ( | const THD * | thd, |
const std::string | alt1, | ||
const std::string | alt2 | ||
) |
Read a user variable that may exist under two different names.
thd | The session to read from. |
alt1 | The first variable name alternative. |
alt2 | The second variable name alternative. |
If | there exists a user variable in the current session with the first name, return that. Otherwise, if the second one exists, return that. Otherwise, return NULL. |
void kill_zombie_dump_threads | ( | THD * | thd | ) |
void mysql_binlog_send | ( | THD * | thd, |
char * | log_ident, | ||
my_off_t | pos, | ||
Gtid_set * | gtid_set, | ||
uint32 | flags | ||
) |
Low-level function where the dump thread iterates over the binary log and sends events to the slave.
This function is common for both COM_BINLOG_DUMP and COM_BINLOG_DUMP_GTID.
thd | The dump thread. |
log_ident | The filename of the binary log, as given in the COM_BINLOG_DUMP[_GTID] packet. If this is is an empty string (first character is '\0'), we start with the oldest binary log. |
pos | The offset in the binary log, as given in the COM_BINLOG_DUMP[_GTID] packet. This must be at least 4 and at most the size of the binary log file. |
gtid_set | The gtid_set that the slave sent, or NULL if the protocol is COM_BINLOG_DUMP. |
flags | flags in COM_BINLOG_DUMP[_GTID] packets. |
Register slave in 'slave_list' hash table.
bool reset_master | ( | THD * | thd, |
bool | unlock_global_read_lock | ||
) |
Execute a RESET MASTER statement.
thd | Pointer to THD object of the client thread executing the statement. |
unlock_global_read_lock | Unlock the global read lock acquired by RESET MASTER. |
false | success |
true | error |
bool show_binlogs | ( | THD * | thd | ) |
Execute a SHOW BINARY LOGS statement.
thd | Pointer to THD object for the client thread executing the statement. |
false | success |
true | failure |
bool show_master_status | ( | THD * | thd | ) |
Execute a SHOW MASTER STATUS statement.
thd | Pointer to THD object for the client thread executing the statement. |
false | success |
true | failure |
bool show_replicas | ( | THD * | thd | ) |
Execute a SHOW REPLICAS / SHOW SLAVE HOSTS statement.
thd | Pointer to THD object for the client thread executing the statement. |
false | success |
true | failure |
void unregister_replica | ( | THD * | thd, |
bool | only_mine, | ||
bool | need_lock_slave_list | ||
) |
int max_binlog_dump_events = 0 |
bool opt_sporadic_binlog_dump_fail = false |
malloc_unordered_map<uint32, unique_ptr_my_free<REPLICA_INFO> > slave_list |