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