MySQL 8.3.0
Source Code Documentation
gcs_xcom_control_interface.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef GCS_XCOM_CONTROL_INTERFACE_INCLUDED
24#define GCS_XCOM_CONTROL_INTERFACE_INCLUDED
25
26#include <cstdlib>
27#include <cstring>
28#include <map>
29#include <set>
30
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 @param[in] stats_mgr Reference to statistics storage
392 */
393
394 explicit Gcs_xcom_control(
395 Gcs_xcom_node_address *xcom_node_address,
396 std::vector<Gcs_xcom_node_address *> &xcom_peers,
397 Gcs_group_identifier group_identifier, Gcs_xcom_proxy *xcom_proxy,
398 Gcs_xcom_group_management *xcom_group_management,
400 Gcs_xcom_state_exchange_interface *state_exchange,
402 My_xp_socket_util *socket_util,
403 std::unique_ptr<Network_provider_operations_interface>
404 comms_operation_interface,
406
407 ~Gcs_xcom_control() override;
408
409 // Gcs_control_interface implementation
410 enum_gcs_error join() override;
411
412 enum_gcs_error do_join(const bool retry = true);
413
414 /*
415 Responsible for doing the heavy lifting related to the join
416 operation.
417 */
419
420 enum_gcs_error leave() override;
421
422 /*
423 Responsible for doing the heavy lifting related to the leave operation.
424 Triggers and oversees the termination of XCom, then calls 'do_leave_gcs'.
425 */
427
428 /**
429 Sends a leave view message to informat that XCOM has already exited or
430 is about to do so.
431 */
432 void do_leave_view();
433
434 /**
435 Request other members to remove node from the group.
436 */
438
439 bool belongs_to_group() override;
440
441 Gcs_view *get_current_view() override;
442
444
446 const Gcs_control_event_listener &event_listener) override;
447
448 void remove_event_listener(int event_listener_handle) override;
449
450 /**
451 The purpose of this method is to be called when in Gcs_xcom_interface
452 callback method of View Changing is invoked.
453
454 This allows, in terms of software architecture, to concentrate all the
455 view change logic and processing in a single place. The view_change
456 callback that is registered in Gcs_xcom_interface should be a simple
457 pass-through.
458
459 @param[in] config_id The configuration ID that this view pertains to
460 @param[in] message_id the message that conveys the View Change
461 @param[in] xcom_nodes Set of nodes that participated in the consensus
462 to deliver the message
463 @param[in] do_not_deliver_to_client Whether to filter this view from being
464 delivered to the client
465 @param[in] max_synode XCom max synode
466 */
467
468 bool xcom_receive_global_view(synode_no const config_id, synode_no message_id,
469 Gcs_xcom_nodes *xcom_nodes,
470 bool do_not_deliver_to_client,
471 synode_no max_synode);
472
473 /*
474 This method is called in order to give a hint on what the node thinks
475 about other nodes.
476
477 The view is ignored if 1) it has no nodes, 2) the local node does not
478 have a view installed or 3) the local node is not present in its current
479 view (i.e., it has been expelled).
480
481 @param[in] config_id The configuration ID that this view pertains to
482 @param[in] xcom_nodes Set of nodes that participated in the consensus
483 to deliver the message
484 @param[in] max_synode XCom max synode
485
486 @return True if the view was processed;
487 False otherwise.
488 */
489 bool xcom_receive_local_view(synode_no const config_id,
490 Gcs_xcom_nodes *xcom_nodes,
491 synode_no max_synode);
492
493 /*
494 This method is called in order to inform that the node has left the
495 group or is about to do so.
496 */
498
499 /**
500 Process a message from the control interface and if necessary delegate it
501 to the state exchange.
502
503 @param[in] msg message
504 @param[in] maximum_supported_protocol_version maximum supported protocol
505 version
506 @param[in] used_protocol_version protocol version in use by control message,
507 i.e. state exchange message
508 */
509
511 Gcs_message *msg, Gcs_protocol_version maximum_supported_protocol_version,
512 Gcs_protocol_version used_protocol_version);
513
514 std::map<int, const Gcs_control_event_listener &> *get_event_listeners();
515
516 /**
517 Return the address associated with the current node.
518 */
520
521 /**
522 @returns the information about the local membership of this node.
523 */
525
526 /**
527 Return a pointer to the proxy object used to access XCOM.
528 */
530
532
533 // For testing purposes
534 void set_boot_node(bool boot);
535
536 /**
537 Set the address associated with the current node.
538 */
539 void set_node_address(Gcs_xcom_node_address *node_address);
540
541 /**
542 Inserts in m_initial_peers copies of the Gcs_xcom_node_address
543 objects whose addresses are in the xcom_peers vector.
544
545 @param[in] xcom_peers vector with peers' information
546 */
547
548 void set_peer_nodes(std::vector<Gcs_xcom_node_address *> &xcom_peers);
549
550 /**
551 Deletes all the Gcs_xcom_node_address objects pointed by the
552 elements of the m_initial_peers vector, clearing it at the end.
553 */
554
555 void clear_peer_nodes();
556
557 /**
558 Return a pointer to a socket utility.
559
560 @return a pointer to a socket utility
561 */
562
564
565 /**
566 This member function can be used to wait until xcom thread exits.
567 */
569
570 /**
571 Whether XCOM's Thread is running or not.
572 */
573 bool is_xcom_running();
574
575 /*
576 Configure how many times the node will try to join a group.
577
578 @param[in] join_attempts number of attempts to join
579 @param[in] join_sleep_time time between attempts to join
580 */
581 void set_join_behavior(unsigned int join_attempts,
582 unsigned int join_sleep_time);
583
584 /**
585 Sets a new value for the maximum size of the XCom cache.
586
587 @param[in] size the new maximum size of the XCom cache
588 @retval - GCS_OK if request was successfully scheduled in XCom,
589 GCS_NOK otherwise.
590 */
591 enum_gcs_error set_xcom_cache_size(uint64_t size) override;
592
593 /**
594 Notify that the current member has left the group and whether it left
595 gracefully or not.
596
597 @param[in] error_code that identifies whether there was any error
598 when the view was received.
599 */
601
602 private:
603 void init_me();
604
605 /*
606 Utility methods to build lists from the data that arrives with a view.
607 */
609 Gcs_xcom_nodes *xcom_nodes,
610 std::vector<Gcs_member_identifier *> &alive_members,
611 std::vector<Gcs_member_identifier *> &failed_members);
612
614 std::vector<Gcs_member_identifier *> &left_members,
615 std::vector<Gcs_member_identifier *> &alive_members,
616 std::vector<Gcs_member_identifier *> &failed_members,
617 const std::vector<Gcs_member_identifier> *current_members);
618
620 std::vector<Gcs_member_identifier *> &joined_members,
621 std::vector<Gcs_member_identifier *> &alive_members,
622 const std::vector<Gcs_member_identifier> *current_members);
623
625 std::vector<Gcs_member_identifier *> &member_suspect_nodes,
626 std::vector<Gcs_member_identifier *> &failed_members,
627 const std::vector<Gcs_member_identifier> *current_members);
628
630 std::vector<Gcs_member_identifier *> &non_member_suspect_nodes,
631 std::vector<Gcs_member_identifier *> &failed_members,
632 const std::vector<Gcs_member_identifier> *current_members);
633
634 /**
635 Decides if this node shall be the one to kill failed nodes. The algorithm
636 is: i am the highest node id alive.
637
638 @param alive_members Set of alive members.
639
640 @return true if i am the node responsible to call remove_node to expel
641 another member
642 */
643 bool is_killer_node(
644 const std::vector<Gcs_member_identifier *> &alive_members) const;
645
646 /**
647 Copies from a set to a vector of Gcs_member_identifier.
648
649 @param[in] origin original set
650 @param[in] to_fill destination vector
651 */
652
653 void build_member_list(std::set<Gcs_member_identifier *> *origin,
654 std::vector<Gcs_member_identifier> *to_fill);
655
656 /**
657 Makes all the necessary arrangements to install a new view in the binding
658 and in all registered client applications.
659
660 @param[in] new_view_id new view identifier
661 @param[in] group_id group id
662 @param[in] states collection of states to set in the new view
663 @param[in] total all the members
664 @param[in] left members that left the last view
665 @param[in] join members that joined from the last view
666 @param[in] error_code Error code to set in the new view
667 */
668 void install_view(
669 Gcs_xcom_view_identifier *new_view_id,
670 const Gcs_group_identifier &group_id,
671 std::map<Gcs_member_identifier, Xcom_member_state *> *states,
672 std::set<Gcs_member_identifier *> *total,
673 std::set<Gcs_member_identifier *> *left,
674 std::set<Gcs_member_identifier *> *join,
676
677 /**
678 Check whether the current member is in the received vector of members.
679
680 @param[in] members list of members
681 */
682 bool is_this_node_in(std::vector<Gcs_member_identifier *> *members);
683
684 /**
685 Cycle through peers_list and try to open a connection to the peer, if it
686 isn't the node itself.
687
688 @param[in] peers_list list of the peers
689
690 @return connection descriptor to a peer
691 */
693 std::vector<Gcs_xcom_node_address *> *peers_list);
694
695 /**
696 Attempts to send an add_node request to some initial peer from @c
697 m_initial_peers.
698 Performs up to @c s_connection_attempts attempts.
699
700 @param my_addresses The addresses of this node, used to filter our own
701 address from the initial peers.
702 @returns true if the add_node request was successfully sent, false
703 otherwise.
704 */
705 bool send_add_node_request(std::map<std::string, int> const &my_addresses);
706
707 /**
708 Attempts to send an add_node request to some initial peer from @c
709 m_initial_peers.
710
711 @param my_addresses The addresses of this node, used to filter our own
712 address from the initial peers.
713 @returns true if the add_node request was successfully sent, false
714 otherwise.
715 */
717 std::map<std::string, int> const &my_addresses);
718
719 /**
720 Connects to the given peer's XCom.
721
722 @param peer Peer to connect to.
723 @param my_addresses The addresses of this node, used to filter our own
724 address from the initial peers.
725 @retval {true, connection_descriptor*} If we connected successfully.
726 @retval {false, _} If we could not connect.
727 */
728 std::pair<bool, connection_descriptor *> connect_to_peer(
730 std::map<std::string, int> const &my_addresses);
731
732 /**
733 * Expel the given members from XCom.
734 *
735 * @param incompatible_members the members to expel
736 */
738 std::vector<Gcs_xcom_node_information> const &incompatible_members);
739
740 // The group that this interface pertains
742 unsigned int m_gid_hash;
743
744 // Reference to the proxy between xcom and this implementation
746
747 // Reference to the group management object.
749
750 // Map holding all the registered control event listeners
751 std::map<int, const Gcs_control_event_listener &> event_listeners;
752
753 // Information about the local membership of this node
755
756 // Reference to the local physical node information
758
759 // A reference of the State Exchange algorithm implementation
761
762 // XCom main loop
764
765 // Socket utility.
767
768 /*
769 Number of attempts to join a group before giving up and reporting
770 an error.
771 */
772 unsigned int m_join_attempts;
773
774 /*
775 Number of time in seconds to wait between attempts to join a group.
776 */
777 unsigned int m_join_sleep_time;
778
779 // Suspect nodes holding object
781
782 // Suspicions processing task
784
785 // Proxy to GCS Sock Probe
787
788 std::unique_ptr<Network_provider_operations_interface>
790
791 // Reference to the statistics manager interface
793
794 protected:
795 /*
796 Whether the XCOM was left running or not meaning that the join
797 operation was successfully executed. Note, however, that this
798 does not mean that any view was delivered yet.
799
800 This flag is only updated by the MySQL GCS engine when the join
801 and leave are processed.
802 */
804
805 /*
806 Whether it was requested to make the node leave the group or not.
807 */
809
810 /*
811 Whether a view saying that the node has voluntarily left the group
812 was delivered or not.
813 */
815
816 /* Whether this site boots the group or not. */
817 bool m_boot;
818
819 // Reference to the remote node to whom I shall connect
820 std::vector<Gcs_xcom_node_address *> m_initial_peers;
821
822 // Reference to the mechanism that ensures view safety
824
825 // Reference to the MySQL GCS Engine
827
828 private:
829 /*
830 Disabling the copy constructor and assignment operator.
831 */
834};
835#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:51
This interface represents all the control functionalities that a binding implementation must provide.
Definition: gcs_control_interface.h:110
This represents the unique identification of a group.
Definition: gcs_group_identifier.h:34
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:39
Class that represents the data that is exchanged within a group.
Definition: gcs_message.h:356
Interface to decouple XCom sock_probe implementation to allow unit testing.
Definition: gcs_xcom_networking.h:41
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:1976
void set_groupid_hash(unsigned int gid_h)
Sets the hash for the current group identifier.
Definition: gcs_xcom_control_interface.cc:2310
uint64_t get_non_member_expel_timeout()
Retrieves non-member expel timeout in 100s of nanoseconds.
Definition: gcs_xcom_control_interface.cc:2275
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:1952
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:2339
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:1958
const Gcs_xcom_nodes & get_suspicions() const
Retrieves current list of suspicions.
Definition: gcs_xcom_control_interface.cc:2314
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:2301
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:1993
bool has_majority()
Auxiliary method to retrieve if the suspicions manager has the majority enabled.
Definition: gcs_xcom_control_interface.cc:2345
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:2335
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:2284
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:2126
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:1930
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:2258
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:2266
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:2066
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:2293
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:2353
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:2155
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:2318
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:54
Gcs_view_error_code
Define error codes associated to the view.
Definition: gcs_view.h:59
@ OK
Definition: gcs_view.h:59
Definition: gcs_xcom_control_interface.h:369
Gcs_xcom_node_information const & get_node_information() const
Definition: gcs_xcom_control_interface.cc:190
bool m_leave_view_requested
Definition: gcs_xcom_control_interface.h:808
enum_gcs_error leave() override
Method that causes one to leave the group that this interface pertains.
Definition: gcs_xcom_control_interface.cc:652
Gcs_xcom_proxy * m_xcom_proxy
Definition: gcs_xcom_control_interface.h:745
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:1312
bool m_boot
Definition: gcs_xcom_control_interface.h:817
static constexpr int CONNECTION_ATTEMPTS
Definition: gcs_xcom_control_interface.h:371
Gcs_suspicions_manager * m_suspicions_manager
Definition: gcs_xcom_control_interface.h:780
My_xp_socket_util * m_socket_util
Definition: gcs_xcom_control_interface.h:766
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:1855
Gcs_xcom_node_address * get_node_address()
Return the address associated with the current node.
Definition: gcs_xcom_control_interface.cc:186
void set_join_behavior(unsigned int join_attempts, unsigned int join_sleep_time)
Definition: gcs_xcom_control_interface.cc:212
My_xp_socket_util * get_socket_util()
Return a pointer to a socket utility.
Definition: gcs_xcom_control_interface.cc:205
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:1126
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:1639
enum_gcs_error do_leave()
Definition: gcs_xcom_control_interface.cc:692
void remove_event_listener(int event_listener_handle) override
Removes a previously registered event listener.
Definition: gcs_xcom_control_interface.cc:942
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:1900
void wait_for_xcom_thread()
This member function can be used to wait until xcom thread exits.
Definition: gcs_xcom_control_interface.cc:208
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:925
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:1373
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:1079
void init_me()
Definition: gcs_xcom_control_interface.cc:1867
Gcs_xcom_control & operator=(const Gcs_xcom_control &)
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_statistics_manager_interface *stats_mgr)
Gcs_xcom_control_interface constructor.
Definition: gcs_xcom_control_interface.cc:118
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:957
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:1010
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:539
unsigned int m_join_attempts
Definition: gcs_xcom_control_interface.h:772
std::vector< Gcs_xcom_node_address * > m_initial_peers
Definition: gcs_xcom_control_interface.h:820
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:746
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:1359
Gcs_xcom_engine * m_gcs_engine
Definition: gcs_xcom_control_interface.h:826
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:767
unsigned int m_join_sleep_time
Definition: gcs_xcom_control_interface.h:777
std::unique_ptr< Network_provider_operations_interface > m_comms_operation_interface
Definition: gcs_xcom_control_interface.h:789
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:1111
bool is_xcom_running()
Whether XCOM's Thread is running or not.
Definition: gcs_xcom_control_interface.cc:210
Gcs_xcom_group_management * m_xcom_group_management
Definition: gcs_xcom_control_interface.h:748
Gcs_xcom_node_information * m_local_node_info
Definition: gcs_xcom_control_interface.h:754
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:1910
My_xp_thread_impl m_xcom_thread
Definition: gcs_xcom_control_interface.h:763
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:1889
void set_node_address(Gcs_xcom_node_address *node_address)
Set the address associated with the current node.
Definition: gcs_xcom_control_interface.cc:1872
Gcs_xcom_proxy * get_xcom_proxy()
Return a pointer to the proxy object used to access XCOM.
Definition: gcs_xcom_control_interface.cc:195
void do_remove_node_from_group()
Request other members to remove node from the group.
Definition: gcs_xcom_control_interface.cc:815
Gcs_suspicions_manager * get_suspicions_manager()
Definition: gcs_xcom_control_interface.cc:197
Gcs_sock_probe_interface * m_sock_probe_interface
Definition: gcs_xcom_control_interface.h:786
enum_gcs_error retry_do_join()
Definition: gcs_xcom_control_interface.cc:372
bool m_leave_view_delivered
Definition: gcs_xcom_control_interface.h:814
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:1764
bool m_xcom_running
Definition: gcs_xcom_control_interface.h:803
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:930
std::map< int, const Gcs_control_event_listener & > event_listeners
Definition: gcs_xcom_control_interface.h:751
unsigned int m_gid_hash
Definition: gcs_xcom_control_interface.h:742
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:1047
std::map< int, const Gcs_control_event_listener & > * get_event_listeners()
Definition: gcs_xcom_control_interface.cc:113
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:608
void set_boot_node(bool boot)
Definition: gcs_xcom_control_interface.cc:203
~Gcs_xcom_control() override
Definition: gcs_xcom_control_interface.cc:174
Gcs_xcom_control(const Gcs_xcom_control &)
Gcs_xcom_statistics_manager_interface * m_stats_mgr
Definition: gcs_xcom_control_interface.h:792
enum_gcs_error do_join(const bool retry=true)
Definition: gcs_xcom_control_interface.cc:283
Gcs_xcom_node_address * m_local_node_address
Definition: gcs_xcom_control_interface.h:757
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:553
enum_gcs_error join() override
Method that causes one to join the group that this interface pertains.
Definition: gcs_xcom_control_interface.cc:236
Gcs_xcom_view_change_control_interface * m_view_control
Definition: gcs_xcom_control_interface.h:823
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:223
Gcs_xcom_state_exchange_interface * m_state_exchange
Definition: gcs_xcom_control_interface.h:760
bool belongs_to_group() override
Reports if one has joined and belongs to a group.
Definition: gcs_xcom_control_interface.cc:917
Gcs_view * get_current_view() override
Returns the currently installed view.
Definition: gcs_xcom_control_interface.cc:921
Gcs_group_identifier * m_gid
Definition: gcs_xcom_control_interface.h:741
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:982
My_xp_thread_impl m_suspicions_processing_thread
Definition: gcs_xcom_control_interface.h:783
Definition: gcs_xcom_notification.h:93
The set of expels we have issued but that have not yet taken effect.
Definition: gcs_xcom_expels_in_progress.h:55
Definition: gcs_xcom_group_management.h:36
Stores connection information associated with a node.
Definition: gcs_xcom_group_member_information.h:50
It represents a node within a group and is identified by the member identifier, unique identifier and...
Definition: gcs_xcom_group_member_information.h:192
This class contains information on the configuration, i.e set of nodes or simply site definition.
Definition: gcs_xcom_group_member_information.h:390
Definition: gcs_xcom_proxy.h:52
Definition: gcs_xcom_state_exchange.h:369
This class is the storage and provider of all statistics coming from either XCom and GCS.
Definition: gcs_xcom_statistics_manager.h:64
Definition: gcs_xcom_state_exchange.h:715
Definition: gcs_xcom_view_identifier.h:32
Definition: my_xp_cond.h:135
Definition: my_xp_mutex.h:122
Interface for socket utility methods.
Definition: my_xp_util.h:153
Definition: my_xp_thread.h:138
static struct my_cs_file_section_st sec[]
Definition: ctype.cc:165
enum_gcs_error
This enumeration describes errors which can occur during group communication operations.
Definition: gcs_types.h:40
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:127
static Gcs_xcom_engine * gcs_engine
Definition: gcs_xcom_interface.cc:143
Type total(const Shards< COUNT > &shards) noexcept
Get the total value of all shards.
Definition: ut0counter.h:332
bool terminate(THD *thd)
Drop all DD tables in case there is an error while upgrading server.
Definition: upgrade.cc:685
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
Definition: node_connection.h:46
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:435
task_env * boot
Definition: xcom_base.cc:406
static int majority(bit_set const *nodeset, site_def const *s, int all, int delay, int force)
Definition: xcom_base.cc:780
synode_no max_synode
Definition: xcom_base.cc:405