MySQL 8.0.40
Source Code Documentation
gcs_xcom_control_interface.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 GCS_XCOM_CONTROL_INTERFACE_INCLUDED
25#define GCS_XCOM_CONTROL_INTERFACE_INCLUDED
26
27#include <cstdlib>
28#include <cstring>
29#include <map>
30#include <set>
31
58#include "plugin/group_replication/libmysqlgcs/xdr_gen/xcom_vp.h"
59
61
62/**
63 @class Gcs_suspicions_manager
64
65 This class stores all node suspicions, as well as the timeout and period
66 parameters used by the thread that processes the suspicions.
67 Suspicions are added and removed upon reception of a new global view.
68*/
70 public:
71 /**
72 Constructor for Gcs_suspicions_manager, which sets m_proxy with the
73 received pointer parameter.
74 @param[in] proxy Pointer to Gcs_xcom_proxy
75 @param[in] ctrl Pointer to Gcs_xcom_control
76 */
77
79 Gcs_xcom_control *ctrl);
80
81 /**
82 Destructor for Gcs_suspicions_manager.
83 */
84
86
87 /**
88 Invoked by Gcs_xcom_control::xcom_receive_global_view, it invokes the
89 remove_suspicions method for the alive_nodes and left_nodes parameters,
90 if they're not empty, neither m_suspicions. It also invokes the
91 add_suspicions method if the non_member_suspect_nodes and
92 member_suspect_nodes parameter aren't empty.
93
94 @param[in] config_id Configuration ID of the subsequent node information
95 @param[in] xcom_nodes List of all nodes (i.e. alive or dead) with low level
96 information such as timestamp, unique identifier, etc
97 @param[in] alive_nodes List of the nodes that currently belong to the group
98 @param[in] left_nodes List of the nodes that have left the group
99 @param[in] non_member_suspect_nodes List of joining nodes to add to
100 m_suspicions
101 @param[in] member_suspect_nodes List of previously active nodes to add to
102 m_suspicions
103 @param[in] is_killer_node Indicates if node should remove suspect members
104 from the group
105 @param[in] max_synode XCom max synode
106 */
107
108 void process_view(
109 synode_no const config_id, Gcs_xcom_nodes *xcom_nodes,
110 std::vector<Gcs_member_identifier *> alive_nodes,
111 std::vector<Gcs_member_identifier *> left_nodes,
112 std::vector<Gcs_member_identifier *> member_suspect_nodes,
113 std::vector<Gcs_member_identifier *> non_member_suspect_nodes,
114 bool is_killer_node, synode_no max_synode);
115
116 /**
117 Invoked periodically by the suspicions processing thread, it picks a
118 timestamp and verifies which suspect nodes should be removed as they
119 have timed out.
120 */
121
122 void process_suspicions();
123
124 /**
125 Clear all suspicions. Invoked when node is leaving the group.
126 */
127
128 void clear_suspicions();
129
130 /**
131 Invoked periodically by the suspicions processing thread, it picks a
132 timestamp and verifies which suspect nodes should be removed as they
133 have timed out.
134
135 @param[in] lock Whether lock should be acquired or not
136 */
137
138 void run_process_suspicions(bool lock);
139
140 /**
141 Retrieves current list of suspicions.
142 */
143
144 const Gcs_xcom_nodes &get_suspicions() const;
145
146 /**
147 Retrieves suspicion thread period in seconds.
148 */
149
151
152 /**
153 Sets the period or sleep time, between iterations, for the suspicion
154 thread.
155 @param[in] sec Suspicion thread period
156 */
157
158 void set_suspicions_processing_period(unsigned int sec);
159
160 /**
161 Retrieves non-member expel timeout in 100s of nanoseconds.
162 @return Non-member expel timeout
163 */
164
166
167 /**
168 Sets the time interval to wait before removing non-member nodes marked to
169 be expelled from the cluster.
170 @param[in] sec Suspicions timeout in seconds
171 */
172
173 void set_non_member_expel_timeout_seconds(unsigned long sec);
174
175 /**
176 Retrieves member expel timeout in 100s of nanoseconds.
177 @return Member expel timeout
178 */
179
180 uint64_t get_member_expel_timeout();
181
182 /**
183 Sets the time interval to wait before removing member nodes marked to be
184 expelled from the cluster.
185 @param[in] sec Expel suspicions timeout in seconds
186 */
187
188 void set_member_expel_timeout_seconds(unsigned long sec);
189
190 /**
191 Sets the hash for the current group identifier.
192 @param[in] gid_h Group ID hash
193 */
194
195 void set_groupid_hash(unsigned int gid_h);
196
197 /**
198 Sets the information for this node
199 @param[in] node_info Information on this node
200 */
201
202 void set_my_info(Gcs_xcom_node_information *node_info);
203
204 /**
205 Auxiliary method to wake the suspicions processing thread and set if it
206 should terminate or not.
207 @param[in] terminate Signals if thread should terminate
208 */
209
211
212 /**
213 Auxiliary method to inform the suspicions manager that this node is in
214 a group with the majority of the configured nodes.
215 @param[in] majority Signals if the group has the majority of the nodes
216 alive
217 */
218
219 void inform_on_majority(bool majority);
220
221 /**
222 Auxiliary method to retrieve if the suspicions manager has the majority
223 enabled.
224 @return majority
225 */
226 bool has_majority();
227
228 /*
229 Updates the synode_no of the last message removed from the XCom cache.
230
231 @param[in] last_removed The synode_no of the last message removed from the
232 cache.
233 */
234 void update_last_removed(synode_no last_removed);
235
236 private:
237 /**
238 Invoked by Gcs_suspicions_manager::process_view, it verifies if any
239 of the nodes in the received list was a suspect and removes it from
240 m_suspicions.
241 @param[in] nodes List of nodes to remove from m_suspicions
242 */
243
244 void remove_suspicions(std::vector<Gcs_member_identifier *> nodes);
245
246 /**
247 Invoked by Gcs_suspicions_manager::process_view, it adds suspicions
248 for the nodes received as argument if they aren't already suspects.
249
250 @param[in] xcom_nodes List of all nodes (i.e. alive or dead) with low level
251 information such as timestamp, unique identifier, etc
252 @param[in] non_member_suspect_nodes List of joining nodes to add to
253 m_suspicions
254 @param[in] member_suspect_nodes List of previously active nodes to add to
255 m_suspicions
256 @param[in] max_synode XCom max synode
257 @return Indicates if new suspicions were added
258 */
259
260 bool add_suspicions(
261 Gcs_xcom_nodes *xcom_nodes,
262 std::vector<Gcs_member_identifier *> non_member_suspect_nodes,
263 std::vector<Gcs_member_identifier *> member_suspect_nodes,
264 synode_no max_synode);
265
266 /*
267 XCom proxy pointer
268 */
270
271 /*
272 XCom control interface pointer
273 */
275
276 /*
277 Suspicions processing thread period in seconds
278 */
280
281 /*
282 Non-member expel timeout stored in 100s of nanoseconds
283 */
285
286 /*
287 Member expel timeout stored in 100s of nanoseconds
288 */
290
291 /*
292 Group ID hash
293 */
294 unsigned int m_gid_hash;
295
296 /*
297 List of suspicions
298 */
300
301 /*
302 Mutex to control access to m_suspicions
303 */
305
306 /*
307 Condition used to wake up suspicions thread
308 */
310
311 /*
312 Mutex to control access to suspicions parameters
313 */
315
316 /*
317 Signals if node should remove suspect nodes from group.
318 */
320
321 /*
322 Pointer to this node's information
323 */
325
326 /*
327 Signals if group has a majority of alive nodes.
328 */
330
331 /*
332 The synode_no of the last message removed from the XCom cache.
333 The suspicions manager will use this to verify if a suspected node has
334 gone too far behind the group to be recoverable; when that happens, it
335 will print a warning message.
336 */
338
339 /*
340 The set of expels we have issued but that have not yet taken effect.
341 */
343
344 /*
345 The XCom configuration/membership ID of the last view we processed.
346 */
347 synode_no m_config_id;
348
349 /*
350 Disabling the copy constructor and assignment operator.
351 */
354};
355
356/**
357 @class Gcs_xcom_control_interface
358
359 This class implements the generic Gcs_control_interface. It relates with:
360 - Gcs_xcom_interface, since the view_changed registered callback will
361 delegate its calls to an instance of this class.
362 - Gcs_xcom_control_proxy in order to isolate xcom calls from their
363 actual implementation, to allow unit testing
364 - Gcs_xcom_view_change_control_interface that implements a structure
365 to allow View Safety. This ensures that, while the view installation
366 procedure is not finished, all applications are not allowed to execute
367 operations based upon a possible inconsistent state.
368*/
370 public:
371 static constexpr int CONNECTION_ATTEMPTS = 10;
372
373 /**
374 Gcs_xcom_control_interface constructor.
375
376 @param[in] xcom_node_address Information about the node's address
377 @param[in] xcom_peers Information about the nodes that it
378 should get in touch to enter a group
379
380 @param[in] group_identifier Group identifier object
381 @param[in] xcom_proxy Proxy implementation reference
382 @param[in] xcom_group_management Group management reference
383 @param[in] gcs_engine MySQL GCS engine
384 @param[in] state_exchange Reference to the State Exchange algorithm
385 implementation
386 @param[in] view_control View change control interface reference
387 @param[in] boot Whether the node will be used to bootstrap the group
388 @param[in] socket_util Reference to a socket utility
389 @param[in] comms_operation_interface an unique_ptr to a
390 Network_provider_operations_interface
391 */
392
393 explicit Gcs_xcom_control(
394 Gcs_xcom_node_address *xcom_node_address,
395 std::vector<Gcs_xcom_node_address *> &xcom_peers,
396 Gcs_group_identifier group_identifier, Gcs_xcom_proxy *xcom_proxy,
397 Gcs_xcom_group_management *xcom_group_management,
399 Gcs_xcom_state_exchange_interface *state_exchange,
401 My_xp_socket_util *socket_util,
402 std::unique_ptr<Network_provider_operations_interface>
403 comms_operation_interface);
404
405 ~Gcs_xcom_control() override;
406
407 // Gcs_control_interface implementation
408 enum_gcs_error join() override;
409
410 enum_gcs_error do_join(const bool retry = true);
411
412 /*
413 Responsible for doing the heavy lifting related to the join
414 operation.
415 */
417
418 enum_gcs_error leave() override;
419
420 /*
421 Responsible for doing the heavy lifting related to the leave operation.
422 Triggers and oversees the termination of XCom, then calls 'do_leave_gcs'.
423 */
425
426 /**
427 Sends a leave view message to informat that XCOM has already exited or
428 is about to do so.
429 */
430 void do_leave_view();
431
432 /**
433 Request other members to remove node from the group.
434 */
436
437 bool belongs_to_group() override;
438
439 Gcs_view *get_current_view() override;
440
442
444 const Gcs_control_event_listener &event_listener) override;
445
446 void remove_event_listener(int event_listener_handle) override;
447
448 /**
449 The purpose of this method is to be called when in Gcs_xcom_interface
450 callback method of View Changing is invoked.
451
452 This allows, in terms of software architecture, to concentrate all the
453 view change logic and processing in a single place. The view_change
454 callback that is registered in Gcs_xcom_interface should be a simple
455 pass-through.
456
457 @param[in] config_id The configuration ID that this view pertains to
458 @param[in] message_id the message that conveys the View Change
459 @param[in] xcom_nodes Set of nodes that participated in the consensus
460 to deliver the message
461 @param[in] do_not_deliver_to_client Whether to filter this view from being
462 delivered to the client
463 @param[in] max_synode XCom max synode
464 */
465
466 bool xcom_receive_global_view(synode_no const config_id, synode_no message_id,
467 Gcs_xcom_nodes *xcom_nodes,
468 bool do_not_deliver_to_client,
469 synode_no max_synode);
470
471 /*
472 This method is called in order to give a hint on what the node thinks
473 about other nodes.
474
475 The view is ignored if 1) it has no nodes, 2) the local node does not
476 have a view installed or 3) the local node is not present in its current
477 view (i.e., it has been expelled).
478
479 @param[in] config_id The configuration ID that this view pertains to
480 @param[in] xcom_nodes Set of nodes that participated in the consensus
481 to deliver the message
482 @param[in] max_synode XCom max synode
483
484 @return True if the view was processed;
485 False otherwise.
486 */
487 bool xcom_receive_local_view(synode_no const config_id,
488 Gcs_xcom_nodes *xcom_nodes,
489 synode_no max_synode);
490
491 /*
492 This method is called in order to inform that the node has left the
493 group or is about to do so.
494 */
496
497 /**
498 Process a message from the control interface and if necessary delegate it
499 to the state exchange.
500
501 @param[in] msg message
502 @param[in] maximum_supported_protocol_version maximum supported protocol
503 version
504 @param[in] used_protocol_version protocol version in use by control message,
505 i.e. state exchange message
506 */
507
509 Gcs_message *msg, Gcs_protocol_version maximum_supported_protocol_version,
510 Gcs_protocol_version used_protocol_version);
511
512 std::map<int, const Gcs_control_event_listener &> *get_event_listeners();
513
514 /**
515 Return the address associated with the current node.
516 */
518
519 /**
520 @returns the information about the local membership of this node.
521 */
523
524 /**
525 Return a pointer to the proxy object used to access XCOM.
526 */
528
530
531 // For testing purposes
532 void set_boot_node(bool boot);
533
534 /**
535 Set the address associated with the current node.
536 */
537 void set_node_address(Gcs_xcom_node_address *node_address);
538
539 /**
540 Inserts in m_initial_peers copies of the Gcs_xcom_node_address
541 objects whose addresses are in the xcom_peers vector.
542
543 @param[in] xcom_peers vector with peers' information
544 */
545
546 void set_peer_nodes(std::vector<Gcs_xcom_node_address *> &xcom_peers);
547
548 /**
549 Deletes all the Gcs_xcom_node_address objects pointed by the
550 elements of the m_initial_peers vector, clearing it at the end.
551 */
552
553 void clear_peer_nodes();
554
555 /**
556 Return a pointer to a socket utility.
557
558 @return a pointer to a socket utility
559 */
560
562
563 /**
564 This member function can be used to wait until xcom thread exits.
565 */
567
568 /**
569 Whether XCOM's Thread is running or not.
570 */
571 bool is_xcom_running();
572
573 /*
574 Configure how many times the node will try to join a group.
575
576 @param[in] join_attempts number of attempts to join
577 @param[in] join_sleep_time time between attempts to join
578 */
579 void set_join_behavior(unsigned int join_attempts,
580 unsigned int join_sleep_time);
581
582 /**
583 Sets a new value for the maximum size of the XCom cache.
584
585 @param[in] size the new maximum size of the XCom cache
586 @retval - GCS_OK if request was successfully scheduled in XCom,
587 GCS_NOK otherwise.
588 */
589 enum_gcs_error set_xcom_cache_size(uint64_t size) override;
590
591 /**
592 Notify that the current member has left the group and whether it left
593 gracefully or not.
594
595 @param[in] error_code that identifies whether there was any error
596 when the view was received.
597 */
599
600 private:
601 void init_me();
602
603 /*
604 Utility methods to build lists from the data that arrives with a view.
605 */
607 Gcs_xcom_nodes *xcom_nodes,
608 std::vector<Gcs_member_identifier *> &alive_members,
609 std::vector<Gcs_member_identifier *> &failed_members);
610
612 std::vector<Gcs_member_identifier *> &left_members,
613 std::vector<Gcs_member_identifier *> &alive_members,
614 std::vector<Gcs_member_identifier *> &failed_members,
615 const std::vector<Gcs_member_identifier> *current_members);
616
618 std::vector<Gcs_member_identifier *> &joined_members,
619 std::vector<Gcs_member_identifier *> &alive_members,
620 const std::vector<Gcs_member_identifier> *current_members);
621
623 std::vector<Gcs_member_identifier *> &member_suspect_nodes,
624 std::vector<Gcs_member_identifier *> &failed_members,
625 const std::vector<Gcs_member_identifier> *current_members);
626
628 std::vector<Gcs_member_identifier *> &non_member_suspect_nodes,
629 std::vector<Gcs_member_identifier *> &failed_members,
630 const std::vector<Gcs_member_identifier> *current_members);
631
632 /**
633 Decides if this node shall be the one to kill failed nodes. The algorithm
634 is: i am the highest node id alive.
635
636 @param alive_members Set of alive members.
637
638 @return true if i am the node responsible to call remove_node to expel
639 another member
640 */
641 bool is_killer_node(
642 const std::vector<Gcs_member_identifier *> &alive_members) const;
643
644 /**
645 Copies from a set to a vector of Gcs_member_identifier.
646
647 @param[in] origin original set
648 @param[in] to_fill destination vector
649 */
650
651 void build_member_list(std::set<Gcs_member_identifier *> *origin,
652 std::vector<Gcs_member_identifier> *to_fill);
653
654 /**
655 Makes all the necessary arrangements to install a new view in the binding
656 and in all registered client applications.
657
658 @param[in] new_view_id new view identifier
659 @param[in] group_id group id
660 @param[in] states collection of states to set in the new view
661 @param[in] total all the members
662 @param[in] left members that left the last view
663 @param[in] join members that joined from the last view
664 @param[in] error_code Error code to set in the new view
665 */
666 void install_view(
667 Gcs_xcom_view_identifier *new_view_id,
668 const Gcs_group_identifier &group_id,
669 std::map<Gcs_member_identifier, Xcom_member_state *> *states,
670 std::set<Gcs_member_identifier *> *total,
671 std::set<Gcs_member_identifier *> *left,
672 std::set<Gcs_member_identifier *> *join,
674
675 /**
676 Check whether the current member is in the received vector of members.
677
678 @param[in] members list of members
679 */
680 bool is_this_node_in(std::vector<Gcs_member_identifier *> *members);
681
682 /**
683 Cycle through peers_list and try to open a connection to the peer, if it
684 isn't the node itself.
685
686 @param[in] peers_list list of the peers
687
688 @return connection descriptor to a peer
689 */
691 std::vector<Gcs_xcom_node_address *> *peers_list);
692
693 /**
694 Attempts to send an add_node request to some initial peer from @c
695 m_initial_peers.
696 Performs up to @c s_connection_attempts attempts.
697
698 @param my_addresses The addresses of this node, used to filter our own
699 address from the initial peers.
700 @returns true if the add_node request was successfully sent, false
701 otherwise.
702 */
703 bool send_add_node_request(std::map<std::string, int> const &my_addresses);
704
705 /**
706 Attempts to send an add_node request to some initial peer from @c
707 m_initial_peers.
708
709 @param my_addresses The addresses of this node, used to filter our own
710 address from the initial peers.
711 @returns true if the add_node request was successfully sent, false
712 otherwise.
713 */
715 std::map<std::string, int> const &my_addresses);
716
717 /**
718 Connects to the given peer's XCom.
719
720 @param peer Peer to connect to.
721 @param my_addresses The addresses of this node, used to filter our own
722 address from the initial peers.
723 @retval {true, connection_descriptor*} If we connected successfully.
724 @retval {false, _} If we could not connect.
725 */
726 std::pair<bool, connection_descriptor *> connect_to_peer(
728 std::map<std::string, int> const &my_addresses);
729
730 /**
731 * Expel the given members from XCom.
732 *
733 * @param incompatible_members the members to expel
734 */
736 std::vector<Gcs_xcom_node_information> const &incompatible_members);
737
738 // The group that this interface pertains
740 unsigned int m_gid_hash;
741
742 // Reference to the proxy between xcom and this implementation
744
745 // Reference to the group management object.
747
748 // Map holding all the registered control event listeners
749 std::map<int, const Gcs_control_event_listener &> event_listeners;
750
751 // Information about the local membership of this node
753
754 // Reference to the local physical node information
756
757 // A reference of the State Exchange algorithm implementation
759
760 // XCom main loop
762
763 // Socket utility.
765
766 /*
767 Number of attempts to join a group before giving up and reporting
768 an error.
769 */
770 unsigned int m_join_attempts;
771
772 /*
773 Number of time in seconds to wait between attempts to join a group.
774 */
775 unsigned int m_join_sleep_time;
776
777 // Suspect nodes holding object
779
780 // Suspicions processing task
782
783 // Proxy to GCS Sock Probe
785
786 std::unique_ptr<Network_provider_operations_interface>
788
789 protected:
790 /*
791 Whether the XCOM was left running or not meaning that the join
792 operation was successfully executed. Note, however, that this
793 does not mean that any view was delivered yet.
794
795 This flag is only updated by the MySQL GCS engine when the join
796 and leave are processed.
797 */
799
800 /*
801 Whether it was requested to make the node leave the group or not.
802 */
804
805 /*
806 Whether a view saying that the node has voluntarily left the group
807 was delivered or not.
808 */
810
811 /* Whether this site boots the group or not. */
812 bool m_boot;
813
814 // Reference to the remote node to whom I shall connect
815 std::vector<Gcs_xcom_node_address *> m_initial_peers;
816
817 // Reference to the mechanism that ensures view safety
819
820 // Reference to the MySQL GCS Engine
822
823 private:
824 /*
825 Disabling the copy constructor and assignment operator.
826 */
829};
830#endif /* GCS_XCOM_CONTROL_INTERFACE_INCLUDED */
This interface is implemented by those who wish to receive Control Interface notifications.
Definition: gcs_control_event_listener.h:52
This interface represents all the control functionalities that a binding implementation must provide.
Definition: gcs_control_interface.h:111
This represents the unique identification of a group.
Definition: gcs_group_identifier.h:35
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:40
Class that represents the data that is exchanged within a group.
Definition: gcs_message.h:357
Interface to decouple XCom sock_probe implementation to allow unit testing.
Definition: gcs_xcom_networking.h:42
This class stores all node suspicions, as well as the timeout and period parameters used by the threa...
Definition: gcs_xcom_control_interface.h:69
void clear_suspicions()
Clear all suspicions.
Definition: gcs_xcom_control_interface.cc:1970
void set_groupid_hash(unsigned int gid_h)
Sets the hash for the current group identifier.
Definition: gcs_xcom_control_interface.cc:2304
uint64_t get_non_member_expel_timeout()
Retrieves non-member expel timeout in 100s of nanoseconds.
Definition: gcs_xcom_control_interface.cc:2269
My_xp_mutex_impl m_suspicions_parameters_mutex
Definition: gcs_xcom_control_interface.h:314
~Gcs_suspicions_manager()
Destructor for Gcs_suspicions_manager.
Definition: gcs_xcom_control_interface.cc:1946
void inform_on_majority(bool majority)
Auxiliary method to inform the suspicions manager that this node is in a group with the majority of t...
Definition: gcs_xcom_control_interface.cc:2333
Gcs_suspicions_manager & operator=(Gcs_suspicions_manager const &)
Gcs_xcom_nodes m_suspicions
Definition: gcs_xcom_control_interface.h:299
void remove_suspicions(std::vector< Gcs_member_identifier * > nodes)
Invoked by Gcs_suspicions_manager::process_view, it verifies if any of the nodes in the received list...
Definition: gcs_xcom_control_interface.cc:1952
const Gcs_xcom_nodes & get_suspicions() const
Retrieves current list of suspicions.
Definition: gcs_xcom_control_interface.cc:2308
bool m_has_majority
Definition: gcs_xcom_control_interface.h:329
void set_member_expel_timeout_seconds(unsigned long sec)
Sets the time interval to wait before removing member nodes marked to be expelled from the cluster.
Definition: gcs_xcom_control_interface.cc:2295
void process_view(synode_no const config_id, Gcs_xcom_nodes *xcom_nodes, std::vector< Gcs_member_identifier * > alive_nodes, std::vector< Gcs_member_identifier * > left_nodes, std::vector< Gcs_member_identifier * > member_suspect_nodes, std::vector< Gcs_member_identifier * > non_member_suspect_nodes, bool is_killer_node, synode_no max_synode)
Invoked by Gcs_xcom_control::xcom_receive_global_view, it invokes the remove_suspicions method for th...
Definition: gcs_xcom_control_interface.cc:1987
bool has_majority()
Auxiliary method to retrieve if the suspicions manager has the majority enabled.
Definition: gcs_xcom_control_interface.cc:2339
Gcs_xcom_expels_in_progress m_expels_in_progress
Definition: gcs_xcom_control_interface.h:342
synode_no m_cache_last_removed
Definition: gcs_xcom_control_interface.h:337
void set_my_info(Gcs_xcom_node_information *node_info)
Sets the information for this node.
Definition: gcs_xcom_control_interface.cc:2329
void set_non_member_expel_timeout_seconds(unsigned long sec)
Sets the time interval to wait before removing non-member nodes marked to be expelled from the cluste...
Definition: gcs_xcom_control_interface.cc:2278
synode_no m_config_id
Definition: gcs_xcom_control_interface.h:347
void process_suspicions()
Invoked periodically by the suspicions processing thread, it picks a timestamp and verifies which sus...
Definition: gcs_xcom_control_interface.cc:2120
Gcs_xcom_proxy * m_proxy
Definition: gcs_xcom_control_interface.h:269
Gcs_suspicions_manager(Gcs_xcom_proxy *proxy, Gcs_xcom_control *ctrl)
Constructor for Gcs_suspicions_manager, which sets m_proxy with the received pointer parameter.
Definition: gcs_xcom_control_interface.cc:1924
uint64_t m_non_member_expel_timeout
Definition: gcs_xcom_control_interface.h:284
Gcs_suspicions_manager(Gcs_suspicions_manager const &)
Gcs_xcom_control * m_control_if
Definition: gcs_xcom_control_interface.h:274
My_xp_mutex_impl m_suspicions_mutex
Definition: gcs_xcom_control_interface.h:304
uint64_t m_member_expel_timeout
Definition: gcs_xcom_control_interface.h:289
unsigned int get_suspicions_processing_period()
Retrieves suspicion thread period in seconds.
Definition: gcs_xcom_control_interface.cc:2252
void set_suspicions_processing_period(unsigned int sec)
Sets the period or sleep time, between iterations, for the suspicion thread.
Definition: gcs_xcom_control_interface.cc:2260
My_xp_cond_impl m_suspicions_cond
Definition: gcs_xcom_control_interface.h:309
unsigned int m_gid_hash
Definition: gcs_xcom_control_interface.h:294
bool add_suspicions(Gcs_xcom_nodes *xcom_nodes, std::vector< Gcs_member_identifier * > non_member_suspect_nodes, std::vector< Gcs_member_identifier * > member_suspect_nodes, synode_no max_synode)
Invoked by Gcs_suspicions_manager::process_view, it adds suspicions for the nodes received as argumen...
Definition: gcs_xcom_control_interface.cc:2060
unsigned int m_suspicions_processing_period
Definition: gcs_xcom_control_interface.h:279
uint64_t get_member_expel_timeout()
Retrieves member expel timeout in 100s of nanoseconds.
Definition: gcs_xcom_control_interface.cc:2287
Gcs_xcom_node_information * m_my_info
Definition: gcs_xcom_control_interface.h:324
void update_last_removed(synode_no last_removed)
Definition: gcs_xcom_control_interface.cc:2347
void run_process_suspicions(bool lock)
Invoked periodically by the suspicions processing thread, it picks a timestamp and verifies which sus...
Definition: gcs_xcom_control_interface.cc:2149
void wake_suspicions_processing_thread(bool terminate)
Auxiliary method to wake the suspicions processing thread and set if it should terminate or not.
Definition: gcs_xcom_control_interface.cc:2312
bool m_is_killer_node
Definition: gcs_xcom_control_interface.h:319
This represents the membership view that a member has from a group.
Definition: gcs_view.h:55
Gcs_view_error_code
Define error codes associated to the view.
Definition: gcs_view.h:60
@ OK
Definition: gcs_view.h:60
Definition: gcs_xcom_control_interface.h:369
Gcs_xcom_node_information const & get_node_information() const
Definition: gcs_xcom_control_interface.cc:189
bool m_leave_view_requested
Definition: gcs_xcom_control_interface.h:803
enum_gcs_error leave() override
Method that causes one to leave the group that this interface pertains.
Definition: gcs_xcom_control_interface.cc:651
Gcs_xcom_proxy * m_xcom_proxy
Definition: gcs_xcom_control_interface.h:743
void install_leave_view(Gcs_view::Gcs_view_error_code error_code)
Notify that the current member has left the group and whether it left gracefully or not.
Definition: gcs_xcom_control_interface.cc:1306
bool m_boot
Definition: gcs_xcom_control_interface.h:812
static constexpr int CONNECTION_ATTEMPTS
Definition: gcs_xcom_control_interface.h:371
Gcs_suspicions_manager * m_suspicions_manager
Definition: gcs_xcom_control_interface.h:778
My_xp_socket_util * m_socket_util
Definition: gcs_xcom_control_interface.h:764
void build_member_list(std::set< Gcs_member_identifier * > *origin, std::vector< Gcs_member_identifier > *to_fill)
Copies from a set to a vector of Gcs_member_identifier.
Definition: gcs_xcom_control_interface.cc:1849
Gcs_xcom_node_address * get_node_address()
Return the address associated with the current node.
Definition: gcs_xcom_control_interface.cc:185
Gcs_xcom_control(Gcs_xcom_node_address *xcom_node_address, std::vector< Gcs_xcom_node_address * > &xcom_peers, Gcs_group_identifier group_identifier, Gcs_xcom_proxy *xcom_proxy, Gcs_xcom_group_management *xcom_group_management, Gcs_xcom_engine *gcs_engine, Gcs_xcom_state_exchange_interface *state_exchange, Gcs_xcom_view_change_control_interface *view_control, bool boot, My_xp_socket_util *socket_util, std::unique_ptr< Network_provider_operations_interface > comms_operation_interface)
Gcs_xcom_control_interface constructor.
Definition: gcs_xcom_control_interface.cc:119
void set_join_behavior(unsigned int join_attempts, unsigned int join_sleep_time)
Definition: gcs_xcom_control_interface.cc:211
My_xp_socket_util * get_socket_util()
Return a pointer to a socket utility.
Definition: gcs_xcom_control_interface.cc:204
bool xcom_receive_local_view(synode_no const config_id, Gcs_xcom_nodes *xcom_nodes, synode_no max_synode)
Definition: gcs_xcom_control_interface.cc:1125
void process_control_message(Gcs_message *msg, Gcs_protocol_version maximum_supported_protocol_version, Gcs_protocol_version used_protocol_version)
Process a message from the control interface and if necessary delegate it to the state exchange.
Definition: gcs_xcom_control_interface.cc:1633
enum_gcs_error do_leave()
Definition: gcs_xcom_control_interface.cc:691
void remove_event_listener(int event_listener_handle) override
Removes a previously registered event listener.
Definition: gcs_xcom_control_interface.cc:941
void clear_peer_nodes()
Deletes all the Gcs_xcom_node_address objects pointed by the elements of the m_initial_peers vector,...
Definition: gcs_xcom_control_interface.cc:1894
void wait_for_xcom_thread()
This member function can be used to wait until xcom thread exits.
Definition: gcs_xcom_control_interface.cc:207
bool xcom_receive_leave()
const Gcs_member_identifier get_local_member_identifier() const override
Retrieves the local identifier of this member on a group.
Definition: gcs_xcom_control_interface.cc:924
bool xcom_receive_global_view(synode_no const config_id, synode_no message_id, Gcs_xcom_nodes *xcom_nodes, bool do_not_deliver_to_client, synode_no max_synode)
The purpose of this method is to be called when in Gcs_xcom_interface callback method of View Changin...
Definition: gcs_xcom_control_interface.cc:1367
void build_non_member_suspect_nodes(std::vector< Gcs_member_identifier * > &non_member_suspect_nodes, std::vector< Gcs_member_identifier * > &failed_members, const std::vector< Gcs_member_identifier > *current_members)
Definition: gcs_xcom_control_interface.cc:1078
void init_me()
Definition: gcs_xcom_control_interface.cc:1861
Gcs_xcom_control & operator=(const Gcs_xcom_control &)
void build_total_members(Gcs_xcom_nodes *xcom_nodes, std::vector< Gcs_member_identifier * > &alive_members, std::vector< Gcs_member_identifier * > &failed_members)
Definition: gcs_xcom_control_interface.cc:956
void build_left_members(std::vector< Gcs_member_identifier * > &left_members, std::vector< Gcs_member_identifier * > &alive_members, std::vector< Gcs_member_identifier * > &failed_members, const std::vector< Gcs_member_identifier > *current_members)
Definition: gcs_xcom_control_interface.cc:1009
bool send_add_node_request(std::map< std::string, int > const &my_addresses)
Attempts to send an add_node request to some initial peer from m_initial_peers.
Definition: gcs_xcom_control_interface.cc:538
unsigned int m_join_attempts
Definition: gcs_xcom_control_interface.h:770
std::vector< Gcs_xcom_node_address * > m_initial_peers
Definition: gcs_xcom_control_interface.h:815
void do_leave_view()
Sends a leave view message to informat that XCOM has already exited or is about to do so.
Definition: gcs_xcom_control_interface.cc:745
bool is_this_node_in(std::vector< Gcs_member_identifier * > *members)
Check whether the current member is in the received vector of members.
Definition: gcs_xcom_control_interface.cc:1353
Gcs_xcom_engine * m_gcs_engine
Definition: gcs_xcom_control_interface.h:821
connection_descriptor * get_connection_to_node(std::vector< Gcs_xcom_node_address * > *peers_list)
Cycle through peers_list and try to open a connection to the peer, if it isn't the node itself.
Definition: gcs_xcom_control_interface.cc:766
unsigned int m_join_sleep_time
Definition: gcs_xcom_control_interface.h:775
std::unique_ptr< Network_provider_operations_interface > m_comms_operation_interface
Definition: gcs_xcom_control_interface.h:787
bool is_killer_node(const std::vector< Gcs_member_identifier * > &alive_members) const
Decides if this node shall be the one to kill failed nodes.
Definition: gcs_xcom_control_interface.cc:1110
bool is_xcom_running()
Whether XCOM's Thread is running or not.
Definition: gcs_xcom_control_interface.cc:209
Gcs_xcom_group_management * m_xcom_group_management
Definition: gcs_xcom_control_interface.h:746
Gcs_xcom_node_information * m_local_node_info
Definition: gcs_xcom_control_interface.h:752
void expel_incompatible_members(std::vector< Gcs_xcom_node_information > const &incompatible_members)
Expel the given members from XCom.
Definition: gcs_xcom_control_interface.cc:1904
My_xp_thread_impl m_xcom_thread
Definition: gcs_xcom_control_interface.h:761
void set_peer_nodes(std::vector< Gcs_xcom_node_address * > &xcom_peers)
Inserts in m_initial_peers copies of the Gcs_xcom_node_address objects whose addresses are in the xco...
Definition: gcs_xcom_control_interface.cc:1883
void set_node_address(Gcs_xcom_node_address *node_address)
Set the address associated with the current node.
Definition: gcs_xcom_control_interface.cc:1866
Gcs_xcom_proxy * get_xcom_proxy()
Return a pointer to the proxy object used to access XCOM.
Definition: gcs_xcom_control_interface.cc:194
void do_remove_node_from_group()
Request other members to remove node from the group.
Definition: gcs_xcom_control_interface.cc:814
Gcs_suspicions_manager * get_suspicions_manager()
Definition: gcs_xcom_control_interface.cc:196
Gcs_sock_probe_interface * m_sock_probe_interface
Definition: gcs_xcom_control_interface.h:784
enum_gcs_error retry_do_join()
Definition: gcs_xcom_control_interface.cc:371
bool m_leave_view_delivered
Definition: gcs_xcom_control_interface.h:809
void install_view(Gcs_xcom_view_identifier *new_view_id, const Gcs_group_identifier &group_id, std::map< Gcs_member_identifier, Xcom_member_state * > *states, std::set< Gcs_member_identifier * > *total, std::set< Gcs_member_identifier * > *left, std::set< Gcs_member_identifier * > *join, Gcs_view::Gcs_view_error_code error_code=Gcs_view::OK)
Makes all the necessary arrangements to install a new view in the binding and in all registered clien...
Definition: gcs_xcom_control_interface.cc:1758
bool m_xcom_running
Definition: gcs_xcom_control_interface.h:798
int add_event_listener(const Gcs_control_event_listener &event_listener) override
Registers an implementation of a Gcs_control_event_listener that will receive Control Events.
Definition: gcs_xcom_control_interface.cc:929
std::map< int, const Gcs_control_event_listener & > event_listeners
Definition: gcs_xcom_control_interface.h:749
unsigned int m_gid_hash
Definition: gcs_xcom_control_interface.h:740
void build_member_suspect_nodes(std::vector< Gcs_member_identifier * > &member_suspect_nodes, std::vector< Gcs_member_identifier * > &failed_members, const std::vector< Gcs_member_identifier > *current_members)
Definition: gcs_xcom_control_interface.cc:1046
std::map< int, const Gcs_control_event_listener & > * get_event_listeners()
Definition: gcs_xcom_control_interface.cc:114
std::pair< bool, connection_descriptor * > connect_to_peer(Gcs_xcom_node_address &peer, std::map< std::string, int > const &my_addresses)
Connects to the given peer's XCom.
Definition: gcs_xcom_control_interface.cc:607
void set_boot_node(bool boot)
Definition: gcs_xcom_control_interface.cc:202
~Gcs_xcom_control() override
Definition: gcs_xcom_control_interface.cc:173
Gcs_xcom_control(const Gcs_xcom_control &)
enum_gcs_error do_join(const bool retry=true)
Definition: gcs_xcom_control_interface.cc:282
Gcs_xcom_node_address * m_local_node_address
Definition: gcs_xcom_control_interface.h:755
bool try_send_add_node_request_to_seeds(std::map< std::string, int > const &my_addresses)
Attempts to send an add_node request to some initial peer from m_initial_peers.
Definition: gcs_xcom_control_interface.cc:552
enum_gcs_error join() override
Method that causes one to join the group that this interface pertains.
Definition: gcs_xcom_control_interface.cc:235
Gcs_xcom_view_change_control_interface * m_view_control
Definition: gcs_xcom_control_interface.h:818
enum_gcs_error set_xcom_cache_size(uint64_t size) override
Sets a new value for the maximum size of the XCom cache.
Definition: gcs_xcom_control_interface.cc:222
Gcs_xcom_state_exchange_interface * m_state_exchange
Definition: gcs_xcom_control_interface.h:758
bool belongs_to_group() override
Reports if one has joined and belongs to a group.
Definition: gcs_xcom_control_interface.cc:916
Gcs_view * get_current_view() override
Returns the currently installed view.
Definition: gcs_xcom_control_interface.cc:920
Gcs_group_identifier * m_gid
Definition: gcs_xcom_control_interface.h:739
void build_joined_members(std::vector< Gcs_member_identifier * > &joined_members, std::vector< Gcs_member_identifier * > &alive_members, const std::vector< Gcs_member_identifier > *current_members)
Definition: gcs_xcom_control_interface.cc:981
My_xp_thread_impl m_suspicions_processing_thread
Definition: gcs_xcom_control_interface.h:781
Definition: gcs_xcom_notification.h:94
The set of expels we have issued but that have not yet taken effect.
Definition: gcs_xcom_expels_in_progress.h:56
Definition: gcs_xcom_group_management.h:37
Stores connection information associated with a node.
Definition: gcs_xcom_group_member_information.h:51
It represents a node within a group and is identified by the member identifier, unique identifier and...
Definition: gcs_xcom_group_member_information.h:193
This class contains information on the configuration, i.e set of nodes or simply site definition.
Definition: gcs_xcom_group_member_information.h:391
Definition: gcs_xcom_proxy.h:52
Definition: gcs_xcom_state_exchange.h:370
Definition: gcs_xcom_state_exchange.h:716
Definition: gcs_xcom_view_identifier.h:33
Definition: my_xp_cond.h:136
Definition: my_xp_mutex.h:123
Interface for socket utility methods.
Definition: my_xp_util.h:154
Definition: my_xp_thread.h:139
static struct my_cs_file_section_st sec[]
Definition: ctype.cc:162
enum_gcs_error
This enumeration describes errors which can occur during group communication operations.
Definition: gcs_types.h:41
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:128
static Gcs_xcom_engine * gcs_engine
Definition: gcs_xcom_interface.cc:144
Type total(const Shards< COUNT > &shards) noexcept
Get the total value of all shards.
Definition: ut0counter.h:333
bool terminate(THD *thd)
Drop all DD tables in case there is an error while upgrading server.
Definition: upgrade.cc:686
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
Definition: node_connection.h:47
Rudimentary task system in portable C, based on Tom Duff's switch-based coroutine trick and a stack o...
static task_env * retry
Definition: xcom_base.cc:436
task_env * boot
Definition: xcom_base.cc:407
static int majority(bit_set const *nodeset, site_def const *s, int all, int delay, int force)
Definition: xcom_base.cc:781
synode_no max_synode
Definition: xcom_base.cc:406