MySQL 8.4.2
Source Code Documentation
group_replication_priv.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef GROUP_REPLICATION_PRIV_INCLUDE
25#define GROUP_REPLICATION_PRIV_INCLUDE
26
27/**
28 @file include/mysql/group_replication_priv.h
29*/
30
31#include "my_sys.h"
32#include "my_thread.h"
34#include "sql/binlog_ostream.h"
35#include "sql/binlog_reader.h"
36#include "sql/debug_sync.h"
37#include "sql/log_event.h"
38#include "sql/replication.h"
41#include "sql/rpl_gtid.h"
43
44namespace gr {
48} // namespace gr
49
50/**
51 Server side initializations.
52*/
54
55/**
56 Returns the server connection attribute
57
58 @note This method implementation is on sql_class.cc
59
60 @return the pthread for the connection attribute.
61*/
63
64/**
65 Returns the server hostname, port and uuid.
66
67 @param[out] hostname hostname
68 @param[out] port port
69 @param[out] uuid uuid
70 @param[out] server_version server version
71 @param[out] admin_port mysqld admin port
72*/
73void get_server_parameters(char **hostname, uint *port, char **uuid,
74 unsigned int *server_version, uint *admin_port);
75
76/**
77 Returns the server's client-server interface's ssl configuration values.
78
79 @param[out] server_ssl_variables server's ssl_variables
80*/
82 st_server_ssl_variables *server_ssl_variables);
83
84/**
85 Returns the server's admin interface's ssl configuration values.
86
87 @param[out] server_ssl_variables server's ssl_variables
88*/
90 st_server_ssl_variables *server_ssl_variables);
91
92/**
93 Returns the server_id.
94
95 @return server_id
96*/
97ulong get_server_id();
98
99/**
100 Returns the server auto_increment_increment
101
102 @return auto_increment_increment
103*/
105
106/**
107 Returns the server auto_increment_offset
108
109 @return auto_increment_offset
110*/
112
113/**
114 Set server auto_increment_increment
115
116 @param[in] auto_increment_increment auto-increment increment
117*/
118void set_auto_increment_increment(ulong auto_increment_increment);
119
120/**
121 Set server auto_increment_offset
122
123 @param[in] auto_increment_offset auto-increment offset
124*/
125void set_auto_increment_offset(ulong auto_increment_offset);
126
127/**
128 Returns a struct containing all server startup information needed to evaluate
129 if one has conditions to proceed executing master-master replication.
130
131 @param[out] requirements requirements
132*/
134
135/**
136 Returns the server GTID_EXECUTED encoded as a binary string.
137
138 @note Memory allocated to encoded_gtid_executed must be release by caller.
139
140 @param[out] encoded_gtid_executed binary string
141 @param[out] length binary string length
142*/
143bool get_server_encoded_gtid_executed(uchar **encoded_gtid_executed,
144 size_t *length);
145
146#if !defined(NDEBUG)
147/**
148 Returns a text representation of a encoded GTID set.
149
150 @note Memory allocated to returned pointer must be release by caller.
151
152 @param[in] encoded_gtid_set binary string
153 @param[in] length binary string length
154
155 @return a pointer to text representation of the encoded set
156*/
157char *encoded_gtid_set_to_string(uchar *encoded_gtid_set, size_t length);
158#endif
159
160/**
161 Return last gno for a given sidno, see
162 Gtid_state::get_last_executed_gno() for details.
163*/
165
166/**
167 Return sidno for a given tsid, see Tsid_map::add_tsid() for details.
168*/
170
171/**
172 Return Tsid for a given sidno on the global_tsid_map.
173 See Tsid_map::sidno_to_tsid() for details.
174*/
176
177/**
178 Set slave thread default options.
179
180 @param[in] thd The thread
181*/
183
184/**
185 Add thread to Global_THD_manager singleton.
186
187 @param[in] thd The thread
188*/
190
191/**
192 Remove thread from Global_THD_manager singleton.
193
194 @param[in] thd The thread
195*/
197
198/**
199 Function that returns the write set extraction algorithm name.
200
201 @param[in] algorithm The algorithm value
202
203 @return the algorithm name
204*/
205const char *get_write_set_algorithm_string(unsigned int algorithm);
206
207/**
208 Returns true if the given transaction is committed.
209
210 @param[in] gtid The transaction identifier
211
212 @return true the transaction is committed
213 false otherwise
214*/
215bool is_gtid_committed(const Gtid &gtid);
216
217/**
218 Returns the value of replica_max_allowed_packet.
219
220 @return replica_max_allowed_packet
221*/
222unsigned long get_replica_max_allowed_packet();
223
224/**
225 Wait until the given Gtid_set is included in @@GLOBAL.GTID_EXECUTED.
226
227 @param[in] gtid_set_text Gtid_set to wait for.
228 @param[in] timeout The maximum number of seconds that the
229 function should wait, or 0 to wait indefinitely.
230 @param[in] update_thd_status
231 when true updates the stage info with
232 the new wait condition, when false keeps the
233 current stage info.
234
235 @retval false the Gtid_set is included in @@GLOBAL.GTID_EXECUTED
236 @retval true otherwise
237*/
238bool wait_for_gtid_set_committed(const char *gtid_set_text, double timeout,
239 bool update_thd_status);
240
241/**
242 @returns the maximum value of replica_max_allowed_packet.
243 */
245
246/**
247 @returns if the server is restarting after a clone
248*/
250
251/**
252 @returns if the server already dropped its data when cloning
253*/
255
256/**
257 Copy to datetime_str parameter the date in the format
258 'YYYY-MM-DD hh:mm:ss.ffffff' of the moment in time
259 represented by micro-seconds elapsed since the Epoch,
260 1970-01-01 00:00:00 +0000 (UTC).
261
262 @param[in] microseconds_since_epoch micro-seconds since Epoch.
263 @param[out] datetime_str The string pointer to print at. This
264 function is guaranteed not to write
265 more than MAX_DATE_STRING_REP_LENGTH
266 characters.
267 @param[in] decimal_precision decimal precision, in the range 0..6
268*/
269void microseconds_to_datetime_str(uint64_t microseconds_since_epoch,
270 char *datetime_str, uint decimal_precision);
271
272#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:36
Representation of the GTID tag.
Definition: tag.h:51
Represents Transaction Source Identifier which is composed of source UUID and transaction tag.
Definition: tsid.h:47
void set_slave_thread_options(THD *thd)
Set slave thread default options.
Definition: rpl_replica.cc:3964
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:303
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:447
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:554
ulong get_server_id()
Returns the server_id.
Definition: rpl_group_replication.cc:470
ulong get_auto_increment_increment()
Returns the server auto_increment_increment.
Definition: rpl_group_replication.cc:472
const mysql::gtid::Tsid & get_tsid_from_global_tsid_map(rpl_sidno sidno)
Return Tsid for a given sidno on the global_tsid_map.
Definition: rpl_gtid_misc.cc:297
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:488
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:697
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:372
bool is_server_data_dropped()
Definition: rpl_group_replication.cc:597
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:424
bool is_server_restarting_after_clone()
Definition: rpl_group_replication.cc:595
int group_replication_init()
Server side initializations.
Definition: rpl_group_replication.cc:111
void global_thd_manager_add_thd(THD *thd)
Add thread to Global_THD_manager singleton.
Definition: rpl_group_replication.cc:534
ulong get_auto_increment_offset()
Returns the server auto_increment_offset.
Definition: rpl_group_replication.cc:476
void global_thd_manager_remove_thd(THD *thd)
Remove thread from Global_THD_manager singleton.
Definition: rpl_group_replication.cc:538
bool is_gtid_committed(const Gtid &gtid)
Returns true if the given transaction is committed.
Definition: rpl_group_replication.cc:542
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:503
unsigned long get_replica_max_allowed_packet()
Returns the value of replica_max_allowed_packet.
Definition: rpl_group_replication.cc:587
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:287
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:484
my_thread_attr_t * get_connection_attrib()
Returns the server connection attribute.
Definition: sql_thd_api.cc:294
unsigned long get_max_replica_max_allowed_packet()
Definition: rpl_group_replication.cc:591
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:520
void set_auto_increment_increment(ulong auto_increment_increment)
Set server auto_increment_increment.
Definition: rpl_group_replication.cc:480
Binary log event definitions.
unsigned char uchar
Definition: my_inttypes.h:52
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:49
static char * server_version
Definition: mysql.cc:120
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:76
Definition: group_replication_priv.h:44
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:498
Gtid_format
Gtid binary format indicator.
Definition: gtid_format.h:38
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
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:112
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:108
mysql::gtid::Tsid Tsid
Definition: rpl_gtid_state.cc:56
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:1100
This represents some of the context in which a transaction is running It summarizes all necessary req...
Definition: replication.h:100
Struct to share server ssl variables.
Definition: replication.h:49