![]() |
MySQL 26.10.0
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 "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_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/my_loglevel.h"#include "mysql/psi/mysql_file.h"#include "mysql/psi/mysql_mutex.h"#include "mysql/service_mysql_alloc.h"#include "mysql/strings/m_ctype.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 "strmake.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 | |
| static std::unique_ptr< uchar[]> | build_debug_com_binlog_dump_gtid_encoding (size_t *buffer_size, uint32 *declared_data_size) |
| resource_blocker::Resource & | get_dump_thread_resource () |
| static bool | check_and_report_dump_thread_blocked (resource_blocker::User &rpl_user) |
| static bool | same_authenticated_source_account (const THD *lhs, const THD *rhs) |
| Check whether two dump-thread connections belong to the same authenticated replication account. More... | |
| static void | report_conflicting_dump_thread_owner (const char *replica_uuid, uint32 replica_server_id) |
| Report that a dump thread with the requested replica identity belongs to a different authenticated account. More... | |
| static bool | reject_conflicting_dump_thread_owner (THD *thd, const THD *existing_dump_thread, const char *replica_uuid) |
| Reject a dump-thread identity owned by a different authenticated account. More... | |
| static THD_ptr | find_dump_thread_with_same_replica_identity (const String &replica_uuid) |
| Find an existing dump thread with the same replica identity as the current connection. More... | |
| 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 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... | |
| bool | kill_zombie_dump_threads (THD *thd) |
| bool | reset_binary_logs_and_gtids (THD *thd, bool unlock_global_read_lock) |
| Execute a RESET BINARY LOGS AND GTIDS statement. More... | |
| bool | show_binary_log_status (THD *thd) |
| Execute a SHOW BINARY LOG 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 |
|
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 |
Find an existing dump thread with the same replica identity as the current connection.
A replica provides its UUID through the replica_uuid or legacy slave_uuid session user variable. An empty UUID occurs for direct dump clients that do not initialize either variable; those clients are matched by server ID.
| replica_uuid | Replica UUID, or an empty string when unavailable. |
| THD_ptr | holding the matching dump thread and its LOCK_thd_data. |
| THD_ptr{nullptr} | if no dump thread has the same identity. |
| 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. |
| bool 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.
|
static |
Reject a dump-thread identity owned by a different authenticated account.
| thd | New connection requesting the replica identity. |
| existing_dump_thread | Existing dump thread with the same identity. |
| replica_uuid | Null-terminated replica UUID, or an empty string when unavailable. |
| true | The existing dump thread belongs to a different account and an error was reported. |
| false | Account affinity is disabled or the authenticated accounts match. |
|
static |
Report that a dump thread with the requested replica identity belongs to a different authenticated account.
| replica_uuid | Null-terminated replica UUID. This is empty when the client did not provide a UUID. |
| replica_server_id | Replica server ID used as the identity fallback when replica_uuid is empty. |
| bool reset_binary_logs_and_gtids | ( | THD * | thd, |
| bool | unlock_global_read_lock | ||
| ) |
Execute a RESET BINARY LOGS AND GTIDS statement.
| thd | Pointer to THD object of the client thread executing the statement. |
| unlock_global_read_lock | Unlock the global read lock aquired by RESET BINARY LOGS AND GTIDS. |
| false | success |
| true | error |
Check whether two dump-thread connections belong to the same authenticated replication account.
| lhs | First connection to compare. |
| rhs | Second connection to compare. |
| true | The authenticated account matches on both connections. |
| false | The authenticated account differs or is unavailable. |
| bool show_binary_log_status | ( | THD * | thd | ) |
Execute a SHOW BINARY LOG STATUS statement.
| thd | Pointer to THD object for the client thread executing the statement. |
| false | success |
| true | failure |
| 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_replicas | ( | THD * | thd | ) |
Execute a SHOW REPLICAS 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 |