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