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