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