MySQL  8.0.17
Source Code Documentation
rpl_master.h
Go to the documentation of this file.
1 #ifndef RPL_MASTER_H_INCLUDED
2 #define RPL_MASTER_H_INCLUDED
3 
4 /* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License, version 2.0,
8  as published by the Free Software Foundation.
9 
10  This program is also distributed with certain software (including
11  but not limited to OpenSSL) that is licensed under separate terms,
12  as designated in a particular file or component or in included license
13  documentation. The authors of MySQL hereby grant you an additional
14  permission to link the program and your derivative works with the
15  separately licensed software that they have included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 #include <stddef.h>
27 
28 #include "my_hostname.h" // HOSTNAME_LENGTH
29 #include "my_inttypes.h"
30 #include "mysql_com.h" // USERNAME_LENGTH
31 #include "sql/sql_const.h" // MAX_PASSWORD_LENGTH
32 
33 class Gtid_set;
34 class String;
35 class THD;
36 
37 extern bool server_id_supplied;
38 extern int max_binlog_dump_events;
40 extern bool opt_show_slave_auth_info;
41 
42 struct SLAVE_INFO {
45  char host[HOSTNAME_LENGTH + 1];
46  char user[USERNAME_LENGTH + 1];
49  THD *thd;
50 };
51 
52 void init_slave_list();
53 void end_slave_list();
54 int register_slave(THD *thd, uchar *packet, size_t packet_length);
55 void unregister_slave(THD *thd, bool only_mine, bool need_lock_slave_list);
56 bool show_slave_hosts(THD *thd);
58 bool show_master_status(THD *thd);
59 bool show_binlogs(THD *thd);
60 void kill_zombie_dump_threads(THD *thd);
61 
62 /**
63  Process a COM_BINLOG_DUMP_GTID packet.
64 
65  This function parses the packet and then calls mysql_binlog_send.
66 
67  @param thd The dump thread.
68  @param packet The COM_BINLOG_DUMP_GTID packet.
69  @param packet_length The length of the packet in bytes.
70  @retval true Error
71  @retval false Success
72 */
73 bool com_binlog_dump_gtid(THD *thd, char *packet, size_t packet_length);
74 
75 /**
76  Process a COM_BINLOG_DUMP packet.
77 
78  This function parses the packet and then calls mysql_binlog_send.
79 
80  @param thd The dump thread.
81  @param packet The COM_BINLOG_DUMP packet.
82  @param packet_length The length of the packet in bytes.
83  @retval true Error
84  @retval false Success
85 */
86 bool com_binlog_dump(THD *thd, char *packet, size_t packet_length);
87 
88 /**
89  Low-level function where the dump thread iterates over the binary
90  log and sends events to the slave. This function is common for both
91  COM_BINLOG_DUMP and COM_BINLOG_DUMP_GTID.
92 
93  @param thd The dump thread.
94 
95  @param log_ident The filename of the binary log, as given in the
96  COM_BINLOG_DUMP[_GTID] packet. If this is is an empty string (first
97  character is '\0'), we start with the oldest binary log.
98 
99  @param pos The offset in the binary log, as given in the
100  COM_BINLOG_DUMP[_GTID] packet. This must be at least 4 and at most
101  the size of the binary log file.
102 
103  @param gtid_set The gtid_set that the slave sent, or NULL if the
104  protocol is COM_BINLOG_DUMP.
105 
106  @param flags flags in COM_BINLOG_DUMP[_GTID] packets.
107 
108  @note This function will start reading at the given (filename,
109  offset), or from the oldest log if filename[0]==0. It will send all
110  events from that position; but if gtid_set!=NULL, it will skip all
111  events in that set.
112 */
113 void mysql_binlog_send(THD *thd, char *log_ident, my_off_t pos,
114  Gtid_set *gtid_set, uint32 flags);
115 
116 bool reset_master(THD *thd, bool unlock_read_lock);
117 
118 #endif /* RPL_MASTER_H_INCLUDED */
bool show_binlogs(THD *thd)
Execute a SHOW BINARY LOGS statement.
Definition: rpl_master.cc:1271
#define USERNAME_LENGTH
Definition: mysql_com.h:66
unsigned char uchar
Definition: my_inttypes.h:51
uint16 port
Definition: rpl_master.h:48
char password[MAX_PASSWORD_LENGTH+1]
Definition: rpl_master.h:47
t pos
Definition: dbug_analyze.cc:148
THD * thd
Definition: rpl_master.h:49
void end_slave_list()
Definition: rpl_master.cc:126
bool reset_master(THD *thd, bool unlock_read_lock)
Execute a RESET MASTER statement.
Definition: rpl_master.cc:1139
File containing constants that can be used throughout the server.
Some integer typedefs for easier portability.
bool com_binlog_dump(THD *thd, char *packet, size_t packet_length)
Process a COM_BINLOG_DUMP packet.
Definition: rpl_master.cc:909
Definition: rpl_master.h:42
char user[USERNAME_LENGTH+1]
Definition: rpl_master.h:46
bool show_master_status(THD *thd)
Execute a SHOW MASTER STATUS statement.
Definition: rpl_master.cc:1210
bool com_binlog_dump_gtid(THD *thd, char *packet, size_t packet_length)
Process a COM_BINLOG_DUMP_GTID packet.
Definition: rpl_master.cc:949
bool show_slave_hosts(THD *thd)
Execute a SHOW SLAVE HOSTS statement.
Definition: rpl_master.cc:214
void init_slave_list()
Definition: rpl_master.cc:117
bool server_id_supplied
Definition: mysqld.cc:995
Common definition used by mysys, performance schema and server & client.
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:159
uint32 rpl_recovery_rank
Definition: rpl_master.h:44
Common definition between mysql server & client.
void kill_zombie_dump_threads(THD *thd)
Definition: rpl_master.cc:1098
uint32 server_id
Definition: rpl_master.h:43
bool opt_show_slave_auth_info
Definition: mysqld.cc:1035
String * get_slave_uuid(THD *thd, String *value)
An auxiliary function extracts slave UUID.
Definition: rpl_master.cc:1020
int max_binlog_dump_events
Definition: rpl_master.cc:77
uint32 master_id
Definition: rpl_master.h:44
uint16_t uint16
Definition: my_inttypes.h:60
static constexpr int HOSTNAME_LENGTH
Definition: my_hostname.h:42
uint32_t uint32
Definition: my_inttypes.h:62
bool opt_sporadic_binlog_dump_fail
Definition: rpl_master.cc:78
Represents a set of GTIDs.
Definition: rpl_gtid.h:1302
unsigned long my_off_t
Definition: my_inttypes.h:87
void unregister_slave(THD *thd, bool only_mine, bool need_lock_slave_list)
Definition: rpl_master.cc:190
int register_slave(THD *thd, uchar *packet, size_t packet_length)
Register slave in &#39;slave_list&#39; hash table.
Definition: rpl_master.cc:142
const string value("\alue\)
char host[HOSTNAME_LENGTH+1]
Definition: rpl_master.h:45
const int MAX_PASSWORD_LENGTH
Definition: validate_password_imp.cc:42
static int flags[50]
Definition: hp_test1.cc:39
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...
Definition: rpl_master.cc:1005
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:777