MySQL 9.1.0
Source Code Documentation
recovery_metadata.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 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 GR_RECOVERY_METADATA_INCLUDE
25#define GR_RECOVERY_METADATA_INCLUDE
26
27#include <map>
28#include <string>
29
33
34/**
35 @class Recovery_metadata_module
36 This class handles the recovery metadata.
37 For safety, processing of add or delete recovery metadata or any processing of
38 recovery metadata like removing group members should be done from pipeline.
39 This class also handles some joiner related information, which is processed
40 from GCS thread directly. This is temporary information and is deleted as soon
41 as recovery metadata is received.
42*/
44 public:
45 /**
46 Recovery_metadata_module constructor
47 */
49
50 /**
51 Recovery_metadata_module Destructor
52 */
54
55 /**
56 Inserts a new recovery_view_metadata entry for the given VIEW_ID.
57
58 @param view_id View ID of metadata
59
60 @return the insert success status
61 @retval true returns a pair of an iterator to the newly inserted
62 element and a value of true
63 @retval false returns a pair of an iterator pointing to map end()
64 and a value of false
65 */
66 std::pair<std::map<const std::string, Recovery_metadata_message *>::iterator,
67 bool>
68 add_recovery_view_metadata(const std::string &view_id);
69
70 /**
71 Deletes all recovery_view_metadata_table elements.
72 */
74
75 /**
76 Remove members not present in given list from all the stored
77 recovery_view_metadata_table records.
78 If post cleanup there is no valid sender or joiner for the view-id this
79 function will do the cleanup for such view-ids.
80 Also, the function does the cleanup of the view-ids mentioned in the
81 parameter view_id_delete_list.
82
83 @param members_left remove members left from the joining member
84 and online member list.
85 @param view_id_delete_list List of VIEW-IDs of which metadata is no longer
86 required
87 */
88 void
90 std::vector<Gcs_member_identifier> &members_left,
91 std::vector<std::string> &view_id_delete_list);
92
93 /**
94 Broadcast message to group members for particular VIEW_ID.
95
96 @param recovery_metadata_msg pointer to Recovery metadata message store.
97
98 @return the send status
99 @retval true Error
100 @retval false Success
101 */
103 Recovery_metadata_message *recovery_metadata_msg);
104
105 /**
106 Broadcast recovery metadata error message to the group members for
107 particular VIEW_ID.
108 This message means recovery metadata message cannot be successfully provided
109 to the joiner, so joiner should leave the group and valid senders should
110 cleanup the recovery metadata if saved.
111
112 @param view_id View-id for which error has to be send.
113
114 @return the send status
115 @retval true Error
116 @retval false Success
117 */
118 enum_gcs_error send_error_message(const std::string &view_id);
119
120 // Joiner related information
121 /**
122 Store view-id in which joiner joined along with all the members that were
123 ONLINE at the time of joining.
124
125 @param view_id view-id in which joiner joined the group
126 @param valid_senders ONLINE members at the time of joining
127 */
129 const std::string &view_id,
130 const std::vector<Gcs_member_identifier> &valid_senders);
131
132 /**
133 Deleted the joiner information i.e. view-id and valid sender list.
134 m_recovery_metadata_joiner_information object will be deleted.
135 */
137
138 /**
139 When member leaves the group, we need to cleanup those members and remove
140 them from valid sender list. If post cleanup there are no members that have
141 joiner recovery metadata, joiner leaves the group.
142
143 @param leaving list of members that have left the group
144 @param is_leaving if joiner is also leaving the group
145 */
147 const std::vector<Gcs_member_identifier> &leaving, bool is_leaving);
148
149 /**
150 Returns if recovery metadata view belongs to the joiner.
151
152 @param view_id view-id of which metadata has been received
153
154 @return the send status
155 @retval true Yes, joiner metadata
156 @retval false No, other joiner metadata
157 */
158 bool is_joiner_recovery_metadata(const std::string &view_id);
159
160 private:
161 /**
162 Broadcast error message to group members for particular VIEW_ID.
163
164 @param recovery_metadata_msg pointer to Recovery metadata message store.
165
166 @return the send status
167 @retval true Error
168 @retval false Success
169 */
171 Recovery_metadata_message *recovery_metadata_msg);
172
173 /**
174 Remove members that have left the group from valid-sender and valid-joiner
175 list.
176 This function is called from
177 delete_members_from_all_recovery_view_metadata_send_metadata_if_sender_left.
178 If post cleanup there is no valid sender or joiner for the view-id, that
179 view is added to the list of view_id_delete_list for cleanup.
180
181 @param members_left remove members left from the joining member
182 and online member list.
183 @param view_id_delete_list List of VIEW-IDs of which metadata is no longer
184 required
185 */
187 std::vector<Gcs_member_identifier> &members_left,
188 std::vector<std::string> &view_id_delete_list);
189
190 /**
191 Remove recovery_view_metadata_table element for the given VIEW_ID.
192 This function is called from
193 delete_members_from_all_recovery_view_metadata_send_metadata_if_sender_left.
194
195 @param view_id View ID of metadata
196
197 @return the key delete status
198 @retval true Key was not found
199 @retval false Key was found and deleted
200 */
201 bool delete_recovery_view_metadata_internal(const std::string view_id);
202
203 /**
204 Leaves the group.
205
206 @param err_msg Details of why member is leaving the group.
207 */
208 void leave_the_group_internal(std::string err_msg);
209
210 private:
211 /**
212 Stores recovery_view_metadata entry for the given view_id.
213 The record is kept on sender till it is successfully broadcasted.
214 */
215 std::map<const std::string, Recovery_metadata_message *>
217
218 /**
219 Stores the joiner related information i.e. view-id and the list of all the
220 members that were ONLINE at the time of joining. The scope of this object is
221 limited, when member joins the group it needs to store it's metadata.
222 Because when recovery metadata is being received joiner needs to identify
223 which recovery metadata it can use to come ONLINE. So joiner temporary
224 stores it view-id and valid sender list in this object till the time it
225 receives it metadata. Post receiving the metadata, this information is not
226 relevant for the joiner, so joiner immediately deletes this information.
227 */
229 nullptr};
230};
231
232#endif /* GR_RECOVERY_METADATA_INCLUDE */
Definition: recovery_metadata_joiner_information.h:32
Definition: recovery_metadata_message.h:36
This class handles the recovery metadata.
Definition: recovery_metadata.h:43
enum_gcs_error send_recovery_metadata(Recovery_metadata_message *recovery_metadata_msg)
Broadcast message to group members for particular VIEW_ID.
Definition: recovery_metadata.cc:38
enum_gcs_error send_error_message_internal(Recovery_metadata_message *recovery_metadata_msg)
Broadcast error message to group members for particular VIEW_ID.
Definition: recovery_metadata.cc:184
std::pair< std::map< const std::string, Recovery_metadata_message * >::iterator, bool > add_recovery_view_metadata(const std::string &view_id)
Inserts a new recovery_view_metadata entry for the given VIEW_ID.
Definition: recovery_metadata.cc:239
void delete_leaving_members_from_joiner_and_leave_group_if_no_valid_sender(const std::vector< Gcs_member_identifier > &leaving, bool is_leaving)
When member leaves the group, we need to cleanup those members and remove them from valid sender list...
Definition: recovery_metadata.cc:361
void store_joiner_view_id_and_valid_senders(const std::string &view_id, const std::vector< Gcs_member_identifier > &valid_senders)
Store view-id in which joiner joined along with all the members that were ONLINE at the time of joini...
Definition: recovery_metadata.cc:327
void delete_joiner_view_id()
Deleted the joiner information i.e.
Definition: recovery_metadata.cc:339
bool delete_recovery_view_metadata_internal(const std::string view_id)
Remove recovery_view_metadata_table element for the given VIEW_ID.
Definition: recovery_metadata.cc:246
enum_gcs_error send_error_message(const std::string &view_id)
Broadcast recovery metadata error message to the group members for particular VIEW_ID.
Definition: recovery_metadata.cc:207
Recovery_metadata_module()
Recovery_metadata_module constructor.
Definition: recovery_metadata.cc:31
void delete_members_from_all_recovery_view_metadata_internal(std::vector< Gcs_member_identifier > &members_left, std::vector< std::string > &view_id_delete_list)
Remove members that have left the group from valid-sender and valid-joiner list.
Definition: recovery_metadata.cc:316
bool is_joiner_recovery_metadata(const std::string &view_id)
Returns if recovery metadata view belongs to the joiner.
Definition: recovery_metadata.cc:344
std::map< const std::string, Recovery_metadata_message * > recovery_view_metadata_table
Stores recovery_view_metadata entry for the given view_id.
Definition: recovery_metadata.h:216
void delete_members_from_all_recovery_view_metadata_send_metadata_if_sender_left(std::vector< Gcs_member_identifier > &members_left, std::vector< std::string > &view_id_delete_list)
Remove members not present in given list from all the stored recovery_view_metadata_table records.
Definition: recovery_metadata.cc:283
void leave_the_group_internal(std::string err_msg)
Leaves the group.
Definition: recovery_metadata.cc:352
virtual ~Recovery_metadata_module()
Recovery_metadata_module Destructor.
Definition: recovery_metadata.cc:33
void delete_all_recovery_view_metadata()
Deletes all recovery_view_metadata_table elements.
Definition: recovery_metadata.cc:268
Recovery_metadata_joiner_information * m_recovery_metadata_joiner_information
Stores the joiner related information i.e.
Definition: recovery_metadata.h:228
enum_gcs_error
This enumeration describes errors which can occur during group communication operations.
Definition: gcs_types.h:41