MySQL 8.4.2
Source Code Documentation
rpl_async_conn_failover_configuration_propagation.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 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 RPL_ASYNC_CONN_FAILOVER_CONFIGURATION_PROPAGATION_INCLUDED
25#define RPL_ASYNC_CONN_FAILOVER_CONFIGURATION_PROPAGATION_INCLUDED
26
27#include <map>
28#include <string>
29#include <vector>
30#include "sql/protobuf/generated/protobuf_lite/replication_asynchronous_connection_failover.pb.h"
32
33/**
34 Memory storage of the replication failover channel status
35 configuration propagated to Group Replication members.
36*/
38 public:
40
42
43 /**
44 Status keys propagated with the group.
45 */
47
48 /**
49 Clears the status configuration.
50
51 @return function return value which determines:
52 false Successful
53 true Error
54 */
55 bool reset();
56
57 /**
58 Reloads the status configuration from runtime information.
59 */
60 void reload();
61
62 /**
63 Delete the status configuration value.
64
65 @param[in] channel the channel name.
66 @param[in] key the variable whose status to set and increment
67 version.
68 */
69 void delete_channel_status(const std::string &channel,
71
72 /**
73 Sets the status configuration value and increment version value.
74
75 @param[in] channel the channel name.
76 @param[in] key the variable whose status to set and increment
77 version.
78 @param[in] value the variable status value to set.
79 @param[in] configuration the configuration in protobuf
80 */
83 int value,
86
87 /**
88 Sets the status configuration with the one received from the
89 group.
90
91 @param[in] configuration the configuration in protobuf
92
93 @return function return value which determines:
94 false Successful
95 true Error
96 */
99
100 /**
101 Sets the status configuration with the one received from the
102 group.
103
104 @param[in] configuration the configuration in protobuf
105
106 @return function return value which determines:
107 false Successful
108 true Error
109 */
112
113 /**
114 Gets the status configuration to send to the group.
115
116 @param[out] configuration the configuration in protobuf
117 */
120
121 private:
123
125
126 /*
127 Stores replication failover channel status propagated to Group
128 Replication members.
129 map(<channel,key>, value)
130 */
131 std::map<std::pair<std::string, std::string>, int> m_status;
132
133 static const std::vector<std::string> m_key_names;
134
136};
137
138/*
139 Class provides functions to send and receive
140 replication_asynchronous_connection_failover and
141 replication_asynchronous_connection_failover_managed table data, and
142 SOURCE_CONNECTION_AUTO_FAILOVER value of CHANGE REPLICATION SOURCE command.
143*/
145 public:
146 /**
147 Construction.
148 */
150
151 /**
152 Destruction.
153 */
155
156 /**
157 Initialize and configure group_replication_message_service_recv service
158 so member can receive and process data from group members.
159
160 @return function return value which determines if was:
161 false Successful
162 true Error
163 */
164 bool init();
165
166 /**
167 Receive data sent by group replication group member.
168
169 @param[in] tag identifier which determine type of data received.
170 @param[in] data data received.
171 @param[in] data_length size of data received.
172
173 @return function return value which determines if read was:
174 false Successful
175 true Error
176 */
177 bool receive(const char *tag, const unsigned char *data, size_t data_length);
178
179 /**
180 Send variable status to its group replication group members.
181
182 @param[in] channel the channel name.
183 @param[in] key the variable whose status to be send.
184 @param[in] status the variable status to be send.
185
186 @return function return value which determines:
187 false Successful
188 true Error
189 */
192 int status);
193
194 /**
195 Delete channel status.
196
197 @param[in] channel the channel name.
198 @param[in] key the variable whose status to be send.
199 */
200 void delete_channel_status(const std::string &channel,
202
203 /**
204 Get stored data in
205 mysql.replication_asynchronous_connection_failover or
206 mysql.replication_asynchronous_connection_failover_managed table and send
207 to its group replication group members.
208
209 @param[in] table_op Rpl_sys_table_access class object.
210
211 @return function return value which determines:
212 false Successful
213 true Error
214 */
216
217 /**
218 Get stored data in
219 mysql.replication_asynchronous_connection_failover table and send
220 to its group replication group members.
221
222 @param[in] table_op Rpl_sys_table_access class object.
223
224 @return function return value which determines:
225 false Successful
226 true Error
227 */
229
230 /**
231 Reload the failover channel status from runtime information.
232 */
234
235 /**
236 Get data stored in
237 mysql.replication_asynchronous_connection_failover or
238 mysql.replication_asynchronous_connection_failover_managed table
239 in protobuf serialized string format.
240
241 @param[out] serialized_configuration save in protobuf serialized string
242 format.
243
244 @return function return value which determines:
245 false Successful
246 true Error
247 */
248 bool get_configuration(std::string &serialized_configuration);
249
250 /**
251 Save data in
252 mysql.replication_asynchronous_connection_failover or
253 mysql.replication_asynchronous_connection_failover_managed table.
254
255 @param[in] exchanged_replication_failover_channels_serialized_configuration
256 save data from serialized string format.
257
258 @return function return value which determines:
259 false Successful
260 true Error
261 */
263 const std::vector<std::string>
264 &exchanged_replication_failover_channels_serialized_configuration);
265
266 /**
267 Collect and broadcast the replication failover channels configuration
268 in a serialized
269 protobuf_replication_asynchronous_connection_failover::SourceAndManagedAndStatusList
270 message, that will override the configuration on all group members.
271
272 @return the operation status
273 @retval false OK
274 @retval true Error
275 */
277
278 private:
279 /* The list of tag identfiers which type of data sent. */
280 const std::vector<std::string> m_message_tag{
281 "mysql_replication_asynchronous_connection_failover",
282 "mysql_replication_asynchronous_connection_managed",
283 "mysql_replication_asynchronous_connection_variable_status",
284 "mysql_replication_asynchronous_connection_failover_and_managed_and_"
285 "status"};
286
287 /*
288 The database replication_asynchronous_connection_failover and
289 replication_asynchronous_connection_failover_managed table belongs to.
290 */
291 const std::string m_db{"mysql"};
292
293 /* replication_asynchronous_connection_failover table name */
294 const std::string m_table_failover{
295 "replication_asynchronous_connection_failover"};
296
297 /* number of fields in replication_asynchronous_connection_failover table */
299
300 /* replication_asynchronous_connection_failover_managed table name */
301 const std::string m_table_managed{
302 "replication_asynchronous_connection_failover_managed"};
303 /*
304 number of fields in replication_asynchronous_connection_failover_managed
305 table
306 */
308
309 /*
310 Stores replication failover channel status propagated to Group
311 Replication members.
312 */
314
315 /**
316 Unregister group_replication_message_service_recv service.
317
318 @return function return value which determines if was:
319 false Successful
320 true Error
321 */
322 bool deinit();
323
324 /**
325 Receive mysql.replication_asynchronous_connection_failover table data sent
326 by group replication group member.
327
328 @param[in] data data received.
329 @param[in] data_length size of data received.
330
331 @return function return value which determines if read was:
332 false Successful
333 true Error
334 */
335 bool receive_failover(const unsigned char *data, size_t data_length);
336
337 /**
338 Receive mysql.replication_asynchronous_connection_failover_managed table
339 data sent by group replication group member.
340
341 @param[in] data data received.
342 @param[in] data_length size of data received.
343
344 @return function return value which determines if read was:
345 false Successful
346 true Error
347 */
348 bool receive_managed(const unsigned char *data, size_t data_length);
349
350 /**
351 Receive SOURCE_CONNECTION_AUTO_FAILOVER value of CHANGE REPLICATION SOURCE
352 command data sent by group replication group member.
353
354 @param[in] data data received.
355 @param[in] data_length size of data received.
356
357 @return function return value which determines if read was:
358 false Successful
359 true Error
360 */
361 bool receive_channel_status(const unsigned char *data, size_t data_length);
362
363 /**
364 Receive mysql.replication_asynchronous_connection_failover and
365 mysql.replication_asynchronous_connection_failover_managed table
366 data sent by group replication group member.
367
368 @param[in] data data received.
369 @param[in] data_length size of data received.
370
371 @return function return value which determines if read was:
372 false Successful
373 true Error
374 */
375 bool receive_failover_and_managed_and_status(const unsigned char *data,
376 size_t data_length);
377
378 /**
379 Send data to all group replication group members.
380
381 @param[in] tag identifier which determine type of data.
382 @param[in] data data to be send
383 @param[in] data_length size of data to be send.
384
385 @return function return value which determines if read was:
386 false Successful
387 true Error
388 */
389 bool send(const char *tag, const char *data, size_t data_length);
390
391 /**
392 Send mysql.replication_asynchronous_connection_failover table data
393 to group replication group members.
394
395 @param[in] data data to be send
396 @param[in] data_length size of data to be send.
397
398 @return function return value which determines if read was:
399 false Successful
400 true Error
401 */
402 bool send_failover(const char *data, size_t data_length);
403
404 /**
405 Send mysql.replication_asynchronous_connection_failover_managed table data
406 to group replication group members.
407
408 @param[in] data data to be send
409 @param[in] data_length size of data to be send.
410
411 @return function return value which determines if read was:
412 false Successful
413 true Error
414 */
415 bool send_managed(const char *data, size_t data_length);
416
417 /**
418 Get stored data in
419 mysql.replication_asynchronous_connection_failover_managed table and send
420 to its group replication group members.
421
422 @param[in] table_op Rpl_sys_table_access class object.
423
424 @return function return value which determines:
425 false Successful
426 true Error
427 */
429
430 /**
431 Send SOURCE_CONNECTION_AUTO_FAILOVER value of CHANGE REPLICATION SOURCE
432 command data to group replication group members.
433
434 @param[in] data data to be send
435 @param[in] data_length size of data to be send.
436
437 @return function return value which determines if read was:
438 false Successful
439 true Error
440 */
441 bool send_channel_status(const char *data, size_t data_length);
442
443 /**
444 Save data in
445 mysql.replication_asynchronous_connection_failover table.
446
447 @param[in] configuration the configuration in protobuf
448
449 @return function return value which determines:
450 false Successful
451 true Error
452 */
456
457 /**
458 Save data in
459 mysql.replication_asynchronous_connection_failover_managed table.
460
461 @param[in] configuration the configuration in protobuf
462
463 @return function return value which determines:
464 false Successful
465 true Error
466 */
470};
471
472#endif /* RPL_ASYNC_CONN_FAILOVER_CONFIGURATION_PROPAGATION_INCLUDED */
Definition: rpl_async_conn_failover_configuration_propagation.h:144
bool get_configuration(std::string &serialized_configuration)
Get data stored in mysql.replication_asynchronous_connection_failover or mysql.replication_asynchrono...
Definition: rpl_async_conn_failover_configuration_propagation.cc:702
bool set_configuration(const std::vector< std::string > &exchanged_replication_failover_channels_serialized_configuration)
Save data in mysql.replication_asynchronous_connection_failover or mysql.replication_asynchronous_con...
Definition: rpl_async_conn_failover_configuration_propagation.cc:793
bool receive(const char *tag, const unsigned char *data, size_t data_length)
Receive data sent by group replication group member.
Definition: rpl_async_conn_failover_configuration_propagation.cc:310
void reload_failover_channels_status()
Reload the failover channel status from runtime information.
Definition: rpl_async_conn_failover_configuration_propagation.cc:697
bool send_failover(const char *data, size_t data_length)
Send mysql.replication_asynchronous_connection_failover table data to group replication group members...
Definition: rpl_async_conn_failover_configuration_propagation.cc:483
bool send_failover_data(Rpl_sys_table_access &table_op)
Get stored data in mysql.replication_asynchronous_connection_failover table and send to its group rep...
Definition: rpl_async_conn_failover_configuration_propagation.cc:643
bool receive_channel_status(const unsigned char *data, size_t data_length)
Receive SOURCE_CONNECTION_AUTO_FAILOVER value of CHANGE REPLICATION SOURCE command data sent by group...
Definition: rpl_async_conn_failover_configuration_propagation.cc:460
bool send(const char *tag, const char *data, size_t data_length)
Send data to all group replication group members.
Definition: rpl_async_conn_failover_configuration_propagation.cc:501
bool send_channel_status(const char *data, size_t data_length)
Send SOURCE_CONNECTION_AUTO_FAILOVER value of CHANGE REPLICATION SOURCE command data to group replica...
Definition: rpl_async_conn_failover_configuration_propagation.cc:495
bool init()
Initialize and configure group_replication_message_service_recv service so member can receive and pro...
Definition: rpl_async_conn_failover_configuration_propagation.cc:278
bool receive_failover_and_managed_and_status(const unsigned char *data, size_t data_length)
Receive mysql.replication_asynchronous_connection_failover and mysql.replication_asynchronous_connect...
Definition: rpl_async_conn_failover_configuration_propagation.cc:902
virtual ~Rpl_acf_configuration_handler()
Destruction.
Definition: rpl_async_conn_failover_configuration_propagation.cc:276
Rpl_acf_configuration_handler()
Construction.
Definition: rpl_async_conn_failover_configuration_propagation.cc:274
const std::string m_db
Definition: rpl_async_conn_failover_configuration_propagation.h:291
Rpl_acf_status_configuration m_rpl_failover_channels_status
Definition: rpl_async_conn_failover_configuration_propagation.h:313
const std::string m_table_failover
Definition: rpl_async_conn_failover_configuration_propagation.h:294
bool set_failover_managed_internal(const protobuf_replication_asynchronous_connection_failover::SourceAndManagedAndStatusList &configuration)
Save data in mysql.replication_asynchronous_connection_failover_managed table.
Definition: rpl_async_conn_failover_configuration_propagation.cc:987
bool set_failover_sources_internal(const protobuf_replication_asynchronous_connection_failover::SourceAndManagedAndStatusList &configuration)
Save data in mysql.replication_asynchronous_connection_failover table.
Definition: rpl_async_conn_failover_configuration_propagation.cc:935
const uint m_table_failover_num_field
Definition: rpl_async_conn_failover_configuration_propagation.h:298
bool send_managed_data(Rpl_sys_table_access &table_op)
Get stored data in mysql.replication_asynchronous_connection_failover_managed table and send to its g...
Definition: rpl_async_conn_failover_configuration_propagation.cc:588
bool receive_managed(const unsigned char *data, size_t data_length)
Receive mysql.replication_asynchronous_connection_failover_managed table data sent by group replicati...
Definition: rpl_async_conn_failover_configuration_propagation.cc:389
bool send_table_data(Rpl_sys_table_access &table_op)
Get stored data in mysql.replication_asynchronous_connection_failover or mysql.replication_asynchrono...
Definition: rpl_async_conn_failover_configuration_propagation.cc:686
const std::string m_table_managed
Definition: rpl_async_conn_failover_configuration_propagation.h:301
bool receive_failover(const unsigned char *data, size_t data_length)
Receive mysql.replication_asynchronous_connection_failover table data sent by group replication group...
Definition: rpl_async_conn_failover_configuration_propagation.cc:328
bool send_channel_status_and_version_data(const std::string &channel, Rpl_acf_status_configuration::enum_key key, int status)
Send variable status to its group replication group members.
Definition: rpl_async_conn_failover_configuration_propagation.cc:550
bool force_my_replication_failover_channels_configuration_on_all_members()
Collect and broadcast the replication failover channels configuration in a serialized protobuf_replic...
Definition: rpl_async_conn_failover_configuration_propagation.cc:889
const std::vector< std::string > m_message_tag
Definition: rpl_async_conn_failover_configuration_propagation.h:280
void delete_channel_status(const std::string &channel, Rpl_acf_status_configuration::enum_key key)
Delete channel status.
Definition: rpl_async_conn_failover_configuration_propagation.cc:582
bool deinit()
Unregister group_replication_message_service_recv service.
Definition: rpl_async_conn_failover_configuration_propagation.cc:300
bool send_managed(const char *data, size_t data_length)
Send mysql.replication_asynchronous_connection_failover_managed table data to group replication group...
Definition: rpl_async_conn_failover_configuration_propagation.cc:489
const uint m_table_managed_num_field
Definition: rpl_async_conn_failover_configuration_propagation.h:307
Memory storage of the replication failover channel status configuration propagated to Group Replicati...
Definition: rpl_async_conn_failover_configuration_propagation.h:37
void reload()
Reloads the status configuration from runtime information.
Definition: rpl_async_conn_failover_configuration_propagation.cc:92
virtual ~Rpl_acf_status_configuration()
Definition: rpl_async_conn_failover_configuration_propagation.cc:63
static std::string get_key_name(Rpl_acf_status_configuration::enum_key key)
Definition: rpl_async_conn_failover_configuration_propagation.cc:67
void delete_channel_status(const std::string &channel, Rpl_acf_status_configuration::enum_key key)
Delete the status configuration value.
Definition: rpl_async_conn_failover_configuration_propagation.cc:122
enum_key
Status keys propagated with the group.
Definition: rpl_async_conn_failover_configuration_propagation.h:46
@ SOURCE_CONNECTION_AUTO_FAILOVER
Definition: rpl_async_conn_failover_configuration_propagation.h:46
mysql_mutex_t m_lock
Definition: rpl_async_conn_failover_configuration_propagation.h:122
bool set(const protobuf_replication_asynchronous_connection_failover::VariableStatusList &configuration)
Sets the status configuration with the one received from the group.
Definition: rpl_async_conn_failover_configuration_propagation.cc:166
std::map< std::pair< std::string, std::string >, int > m_status
Definition: rpl_async_conn_failover_configuration_propagation.h:131
void set_value_and_increment_version(const std::string &channel, Rpl_acf_status_configuration::enum_key key, int value, protobuf_replication_asynchronous_connection_failover::VariableStatusList &configuration)
Sets the status configuration value and increment version value.
Definition: rpl_async_conn_failover_configuration_propagation.cc:138
Rpl_acf_status_configuration()
Definition: rpl_async_conn_failover_configuration_propagation.cc:59
bool reset()
Clears the status configuration.
Definition: rpl_async_conn_failover_configuration_propagation.cc:73
static const std::vector< std::string > m_key_names
Definition: rpl_async_conn_failover_configuration_propagation.h:133
ulonglong m_version
Definition: rpl_async_conn_failover_configuration_propagation.h:124
void get(protobuf_replication_asynchronous_connection_failover::SourceAndManagedAndStatusList &configuration)
Gets the status configuration to send to the group.
Definition: rpl_async_conn_failover_configuration_propagation.cc:254
The class are wrappers for handler index and random scan functions to simplify their usage.
Definition: rpl_sys_table_access.h:45
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Definition: rpl_async_conn_failover_table_operations.h:37
required string key
Definition: replication_asynchronous_connection_failover.proto:60
required string configuration
Definition: replication_asynchronous_connection_failover.proto:49
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
message SourceAndManagedAndStatusList
Definition: replication_asynchronous_connection_failover.proto:70
message VariableStatusList
Definition: replication_asynchronous_connection_failover.proto:64
Definition: task.h:427
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50