MySQL 8.3.0
Source Code Documentation
primary_election_validation_handler.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 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 PRIMARY_ELECTION_VALIDATION_HANDLER_INCLUDED
24#define PRIMARY_ELECTION_VALIDATION_HANDLER_INCLUDED
25
30
32 public:
33 /** Enum for the end results of validation */
35 VALID_PRIMARY = 0, // Primary / Group is valid
36 INVALID_PRIMARY = 1, // Primary is invalid
37 CURRENT_PRIMARY = 2, // Primary is the current one
38 GROUP_SOLO_PRIMARY = 3 // Only a member can become primary
39 };
40
41 /** Constructor */
43
44 /** Destructor */
46
47 /**
48 Initialize the group member structures and registers an observer
49
50 @note this method should be called in a GCS logical moment
51
52 @return true if some error happened, false otherwise
53 */
55
56 /**
57 Cleans the membership info, and pending notifications.
58 Deregister the observer for group events.
59 */
61
62 /**
63 Shares information among members about weights and channels in all members
64 */
65 bool prepare_election();
66
67 /**
68 Validate group for election
69 @param[in] uuid member to validate
70 @param[out] valid_uuid the only member valid for election
71 @param[out] error_msg the error message outputted by validation
72
73 @returns if the primary is valid or what is the solo valid primary
74 @retval VALID_PRIMARY if valid
75 @retval INVALID_PRIMARY if not valid
76 @retval CURRENT_PRIMARY if it is already the primary
77 @retval GROUP_SOLO_PRIMARY only one member is valid
78 */
80 std::string &valid_uuid,
81 std::string &error_msg);
82
83 /**
84 Check that the UUID is valid and present in the group
85 @param uuid member to validate
86
87 @retval INVALID_PRIMARY if not present in the group anymore
88 @retval CURRENT_PRIMARY if the uuid provided is already the primary
89 @retval VALID_PRIMARY if the uuid is valid in the group
90 */
92
93 /**
94 Check that the group members have valid versions
95 1. All support appointed elections
96 2. The appointed member is from the lowest version present in the group
97
98 @param[in] uuid member to validate
99 @param[out] error_msg the error message outputted by validation
100 */
102 std::string &uuid, std::string &error_msg);
103
104 /**
105 Interrupt the validation process in case of an abort
106 */
108
109 private:
110 /** Check which members have slave channels */
112 std::string &uuid);
113
114 // The listeners for group events
115
116 int after_view_change(const std::vector<Gcs_member_identifier> &joining,
117 const std::vector<Gcs_member_identifier> &leaving,
118 const std::vector<Gcs_member_identifier> &group,
119 bool is_leaving, bool *skip_election,
120 enum_primary_election_mode *election_mode,
121 std::string &suggested_primary) override;
123 std::string primary_uuid,
125 enum_primary_election_mode election_mode, int error) override;
127 const std::string &message_origin,
128 bool *skip_message) override;
129
130 /** Was the validation process aborted */
132
133 /** The number of members that sent info or left */
135
136 /** The information about the group members <address,member>*/
137 std::map<const std::string, Election_member_info *> group_members_info;
138
139 /** The lock for notifications*/
141 /** The condition for notifications*/
143};
144
145#endif /** PRIMARY_ELECTION_VALIDATION_HANDLER_INCLUDED */
Class that others can extend to receive notifications about views and primary elections.
Definition: group_event_observer.h:39
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
Definition: primary_election_validation_handler.h:31
enum_primary_validation_result validate_group_slave_channels(std::string &uuid)
Check which members have slave channels.
Definition: primary_election_validation_handler.cc:244
void terminates_validation_structures()
Cleans the membership info, and pending notifications.
Definition: primary_election_validation_handler.cc:78
uint number_of_responses
The number of members that sent info or left.
Definition: primary_election_validation_handler.h:134
bool prepare_election()
Shares information among members about weights and channels in all members.
Definition: primary_election_validation_handler.cc:158
bool validation_process_aborted
Was the validation process aborted.
Definition: primary_election_validation_handler.h:131
enum_primary_validation_result validate_primary_version(std::string &uuid, std::string &error_msg)
Check that the group members have valid versions.
Definition: primary_election_validation_handler.cc:105
int before_message_handling(const Plugin_gcs_message &message, const std::string &message_origin, bool *skip_message) override
Executed before the message is processed.
Definition: primary_election_validation_handler.cc:316
enum_primary_validation_result validate_election(std::string &uuid, std::string &valid_uuid, std::string &error_msg)
Validate group for election.
Definition: primary_election_validation_handler.cc:188
Primary_election_validation_handler()
Constructor.
Definition: primary_election_validation_handler.cc:38
mysql_cond_t notification_cond
The condition for notifications.
Definition: primary_election_validation_handler.h:142
enum_primary_validation_result validate_primary_uuid(std::string &uuid)
Check that the UUID is valid and present in the group.
Definition: primary_election_validation_handler.cc:88
bool initialize_validation_structures()
Initialize the group member structures and registers an observer.
Definition: primary_election_validation_handler.cc:51
void abort_validation_process()
Interrupt the validation process in case of an abort.
Definition: primary_election_validation_handler.cc:265
~Primary_election_validation_handler() override
Destructor.
Definition: primary_election_validation_handler.cc:46
enum_primary_validation_result
Enum for the end results of validation.
Definition: primary_election_validation_handler.h:34
@ CURRENT_PRIMARY
Definition: primary_election_validation_handler.h:37
@ INVALID_PRIMARY
Definition: primary_election_validation_handler.h:36
@ VALID_PRIMARY
Definition: primary_election_validation_handler.h:35
@ GROUP_SOLO_PRIMARY
Definition: primary_election_validation_handler.h:38
mysql_mutex_t notification_lock
The lock for notifications.
Definition: primary_election_validation_handler.h:140
std::map< const std::string, Election_member_info * > group_members_info
The information about the group members <address,member>
Definition: primary_election_validation_handler.h:137
int after_view_change(const std::vector< Gcs_member_identifier > &joining, const std::vector< Gcs_member_identifier > &leaving, const std::vector< Gcs_member_identifier > &group, bool is_leaving, bool *skip_election, enum_primary_election_mode *election_mode, std::string &suggested_primary) override
Executed after view install and before primary election.
Definition: primary_election_validation_handler.cc:274
int after_primary_election(std::string primary_uuid, enum_primary_election_primary_change_status primary_change_status, enum_primary_election_mode election_mode, int error) override
Executed after primary election.
Definition: primary_election_validation_handler.cc:310
enum_primary_election_mode
Enum for election types.
Definition: primary_election_include.h:32
enum_primary_election_primary_change_status
Enum for primary change status.
Definition: primary_election_include.h:49
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49