MySQL 8.3.0
Source Code Documentation
group_replication_priv.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef GROUP_REPLICATION_PRIV_INCLUDE
24#define GROUP_REPLICATION_PRIV_INCLUDE
25
26/**
27 @file include/mysql/group_replication_priv.h
28*/
29
30#include "my_sys.h"
31#include "my_thread.h"
33#include "sql/binlog_ostream.h"
34#include "sql/binlog_reader.h"
35#include "sql/debug_sync.h"
36#include "sql/log_event.h"
37#include "sql/replication.h"
40#include "sql/rpl_gtid.h"
42
43namespace gr {
47} // namespace gr
48
49/**
50 Server side initializations.
51*/
53
54/**
55 Returns the server connection attribute
56
57 @note This method implementation is on sql_class.cc
58
59 @return the pthread for the connection attribute.
60*/
62
63/**
64 Returns the server hostname, port and uuid.
65
66 @param[out] hostname hostname
67 @param[out] port port
68 @param[out] uuid uuid
69 @param[out] server_version server version
70 @param[out] admin_port mysqld admin port
71*/
72void get_server_parameters(char **hostname, uint *port, char **uuid,
73 unsigned int *server_version, uint *admin_port);
74
75/**
76 Returns the server's client-server interface's ssl configuration values.
77
78 @param[out] server_ssl_variables server's ssl_variables
79*/
81 st_server_ssl_variables *server_ssl_variables);
82
83/**
84 Returns the server's admin interface's ssl configuration values.
85
86 @param[out] server_ssl_variables server's ssl_variables
87*/
89 st_server_ssl_variables *server_ssl_variables);
90
91/**
92 Returns the server_id.
93
94 @return server_id
95*/
96ulong get_server_id();
97
98/**
99 Returns the server auto_increment_increment
100
101 @return auto_increment_increment
102*/
104
105/**
106 Returns the server auto_increment_offset
107
108 @return auto_increment_offset
109*/
111
112/**
113 Set server auto_increment_increment
114
115 @param[in] auto_increment_increment auto-increment increment
116*/
117void set_auto_increment_increment(ulong auto_increment_increment);
118
119/**
120 Set server auto_increment_offset
121
122 @param[in] auto_increment_offset auto-increment offset
123*/
124void set_auto_increment_offset(ulong auto_increment_offset);
125
126/**
127 Returns a struct containing all server startup information needed to evaluate
128 if one has conditions to proceed executing master-master replication.
129
130 @param[out] requirements requirements
131*/
133
134/**
135 Returns the server GTID_EXECUTED encoded as a binary string.
136
137 @note Memory allocated to encoded_gtid_executed must be release by caller.
138
139 @param[out] encoded_gtid_executed binary string
140 @param[out] length binary string length
141*/
142bool get_server_encoded_gtid_executed(uchar **encoded_gtid_executed,
143 size_t *length);
144
145#if !defined(NDEBUG)
146/**
147 Returns a text representation of a encoded GTID set.
148
149 @note Memory allocated to returned pointer must be release by caller.
150
151 @param[in] encoded_gtid_set binary string
152 @param[in] length binary string length
153
154 @return a pointer to text representation of the encoded set
155*/
156char *encoded_gtid_set_to_string(uchar *encoded_gtid_set, size_t length);
157#endif
158
159/**
160 Return last gno for a given sidno, see
161 Gtid_state::get_last_executed_gno() for details.
162*/
164
165/**
166 Return sidno for a given tsid, see Tsid_map::add_tsid() for details.
167*/
169
170/**
171 Set slave thread default options.
172
173 @param[in] thd The thread
174*/
176
177/**
178 Add thread to Global_THD_manager singleton.
179
180 @param[in] thd The thread
181*/
183
184/**
185 Remove thread from Global_THD_manager singleton.
186
187 @param[in] thd The thread
188*/
190
191/**
192 Function that returns the write set extraction algorithm name.
193
194 @param[in] algorithm The algorithm value
195
196 @return the algorithm name
197*/
198const char *get_write_set_algorithm_string(unsigned int algorithm);
199
200/**
201 Returns true if the given transaction is committed.
202
203 @param[in] gtid The transaction identifier
204
205 @return true the transaction is committed
206 false otherwise
207*/
208bool is_gtid_committed(const Gtid &gtid);
209
210/**
211 Returns the value of replica_max_allowed_packet.
212
213 @return replica_max_allowed_packet
214*/
215unsigned long get_replica_max_allowed_packet();
216
217/**
218 Wait until the given Gtid_set is included in @@GLOBAL.GTID_EXECUTED.
219
220 @param[in] gtid_set_text Gtid_set to wait for.
221 @param[in] timeout The maximum number of seconds that the
222 function should wait, or 0 to wait indefinitely.
223 @param[in] update_thd_status
224 when true updates the stage info with
225 the new wait condition, when false keeps the
226 current stage info.
227
228 @retval false the Gtid_set is included in @@GLOBAL.GTID_EXECUTED
229 @retval true otherwise
230*/
231bool wait_for_gtid_set_committed(const char *gtid_set_text, double timeout,
232 bool update_thd_status);
233
234/**
235 @returns the maximum value of replica_max_allowed_packet.
236 */
238
239/**
240 @returns if the server is restarting after a clone
241*/
243
244/**
245 @returns if the server already dropped its data when cloning
246*/
248
249/**
250 Copy to datetime_str parameter the date in the format
251 'YYYY-MM-DD hh:mm:ss.ffffff' of the moment in time
252 represented by micro-seconds elapsed since the Epoch,
253 1970-01-01 00:00:00 +0000 (UTC).
254
255 @param[in] microseconds_since_epoch micro-seconds since Epoch.
256 @param[out] datetime_str The string pointer to print at. This
257 function is guaranteed not to write
258 more than MAX_DATE_STRING_REP_LENGTH
259 characters.
260 @param[in] decimal_precision decimal precision, in the range 0..6
261*/
262void microseconds_to_datetime_str(uint64_t microseconds_since_epoch,
263 char *datetime_str, uint decimal_precision);
264
265#endif /* GROUP_REPLICATION_PRIV_INCLUDE */
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
Representation of the GTID tag.
Definition: tag.h:50
Represents Transaction Source Identifier which is composed of source UUID and transaction tag.
Definition: tsid.h:46
void set_slave_thread_options(THD *thd)
Set slave thread default options.
Definition: rpl_replica.cc:3973
rpl_gno get_last_executed_gno(rpl_sidno sidno)
Return last gno for a given sidno, see Gtid_state::get_last_executed_gno() for details.
Definition: rpl_gtid_misc.cc:296
void get_server_admin_ssl_parameters(st_server_ssl_variables *server_ssl_variables)
Returns the server's admin interface's ssl configuration values.
Definition: rpl_group_replication.cc:446
bool wait_for_gtid_set_committed(const char *gtid_set_text, double timeout, bool update_thd_status)
Wait until the given Gtid_set is included in @GLOBAL.GTID_EXECUTED.
Definition: rpl_group_replication.cc:553
ulong get_server_id()
Returns the server_id.
Definition: rpl_group_replication.cc:469
ulong get_auto_increment_increment()
Returns the server auto_increment_increment.
Definition: rpl_group_replication.cc:471
void get_server_startup_prerequirements(Trans_context_info &requirements)
Returns a struct containing all server startup information needed to evaluate if one has conditions t...
Definition: rpl_group_replication.cc:487
void microseconds_to_datetime_str(uint64_t microseconds_since_epoch, char *datetime_str, uint decimal_precision)
Copy to datetime_str parameter the date in the format 'YYYY-MM-DD hh:mm:ss.ffffff' of the moment in t...
Definition: rpl_group_replication.cc:696
void get_server_parameters(char **hostname, uint *port, char **uuid, unsigned int *server_version, uint *admin_port)
Returns the server hostname, port and uuid.
Definition: rpl_group_replication.cc:371
bool is_server_data_dropped()
Definition: rpl_group_replication.cc:596
void get_server_main_ssl_parameters(st_server_ssl_variables *server_ssl_variables)
Returns the server's client-server interface's ssl configuration values.
Definition: rpl_group_replication.cc:423
bool is_server_restarting_after_clone()
Definition: rpl_group_replication.cc:594
int group_replication_init()
Server side initializations.
Definition: rpl_group_replication.cc:110
void global_thd_manager_add_thd(THD *thd)
Add thread to Global_THD_manager singleton.
Definition: rpl_group_replication.cc:533
ulong get_auto_increment_offset()
Returns the server auto_increment_offset.
Definition: rpl_group_replication.cc:475
void global_thd_manager_remove_thd(THD *thd)
Remove thread from Global_THD_manager singleton.
Definition: rpl_group_replication.cc:537
bool is_gtid_committed(const Gtid &gtid)
Returns true if the given transaction is committed.
Definition: rpl_group_replication.cc:541
bool get_server_encoded_gtid_executed(uchar **encoded_gtid_executed, size_t *length)
Returns the server GTID_EXECUTED encoded as a binary string.
Definition: rpl_group_replication.cc:502
unsigned long get_replica_max_allowed_packet()
Returns the value of replica_max_allowed_packet.
Definition: rpl_group_replication.cc:586
rpl_sidno get_sidno_from_global_tsid_map(const mysql::gtid::Tsid &tsid)
Return sidno for a given tsid, see Tsid_map::add_tsid() for details.
Definition: rpl_gtid_misc.cc:286
const char * get_write_set_algorithm_string(unsigned int algorithm)
Function that returns the write set extraction algorithm name.
void set_auto_increment_offset(ulong auto_increment_offset)
Set server auto_increment_offset.
Definition: rpl_group_replication.cc:483
my_thread_attr_t * get_connection_attrib()
Returns the server connection attribute.
Definition: sql_thd_api.cc:293
unsigned long get_max_replica_max_allowed_packet()
Definition: rpl_group_replication.cc:590
char * encoded_gtid_set_to_string(uchar *encoded_gtid_set, size_t length)
Returns a text representation of a encoded GTID set.
Definition: rpl_group_replication.cc:519
void set_auto_increment_increment(ulong auto_increment_increment)
Set server auto_increment_increment.
Definition: rpl_group_replication.cc:479
Binary log event definitions.
unsigned char uchar
Definition: my_inttypes.h:51
Common header for many mysys elements.
Defines to make different thread packages compatible.
pthread_attr_t my_thread_attr_t
Definition: my_thread_bits.h:48
static char * server_version
Definition: mysql.cc:119
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
Definition: group_replication_priv.h:43
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:497
Gtid_format
Gtid binary format indicator.
Definition: gtid_format.h:37
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:32
mysql::gtid::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of mysql::gtid::gno_t.
Definition: rpl_gtid.h:111
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:107
mysql::gtid::Tsid Tsid
Definition: rpl_gtid_state.cc:55
Declarations for the Debug Sync Facility.
TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1099
This represents some of the context in which a transaction is running It summarizes all necessary req...
Definition: replication.h:99
Struct to share server ssl variables.
Definition: replication.h:48