MySQL 8.3.0
Source Code Documentation
certification_handler.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 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 CERTIFICATION_HANDLER_INCLUDE
24#define CERTIFICATION_HANDLER_INCLUDE
25
27#include <string>
28
30
32 public:
34 ~Certification_handler() override;
35 int handle_event(Pipeline_event *ev, Continuation *cont) override;
37 int initialize() override;
38 int terminate() override;
39 bool is_unique() override;
40 int get_role() override;
41
43
44 int set_certification_info(std::map<std::string, std::string> *cert_info);
45
46 private:
48
50
52
55
56 /** View change information information stored for delay */
63 : view_change_pevent(vc_pevent),
64 view_change_gtid(gtid),
66 };
67
68 /** All the VC events pending application due to consistent transactions */
69 std::list<std::unique_ptr<View_change_stored_info>>
71
72 /**
73 Set transaction context for next event handler.
74
75 @param[in] pevent Pipeline event that wraps
76 Transaction_context_log_event.
77
78 @return Operation status
79 @retval 0 OK
80 @retval !=0 Error
81 */
83
84 /**
85 Get transaction context set on previous event handler.
86
87 @param[in] pevent Pipeline event that wraps
88 Gtid_log_event.
89 @param[out] tcle Transaction_context_log_event.
90
91 @return Operation status
92 @retval 0 OK
93 @retval !=0 Error
94 */
97
98 /**
99 Reset transaction context.
100 */
102
103 /**
104 This method handles transaction context events by storing them
105 so they can be used on next handler.
106
107 @param[in] pevent the event to be injected
108 @param[in] cont the object used to wait
109
110 @return the operation status
111 @retval 0 OK
112 @retval !=0 Error
113 */
115
116 /**
117 This method handles binary log events by storing them so they can be used on
118 next handler.
119
120 @param[in] pevent the event to be injected
121 @param[in] cont the object used to wait
122
123 @return the operation status
124 @retval 0 OK
125 @retval !=0 Error
126 */
128
129 /**
130 This method handles applier context events by storing them so they can be
131 used on next handler.
132
133 @param[in] pevent the event to be injected
134 @param[in] cont the object used to wait
135
136 @return the operation status
137 @retval 0 OK
138 @retval !=0 Error
139 */
141
142 /**
143 This method handles applier view change packet.
144
145 @param[in] pevent the event to be injected
146 @param[in] cont the object used to wait
147
148 @return the operation status
149 @retval 0 OK
150 @retval !=0 Error
151 */
153 Continuation *cont);
154
155 /**
156 This method saves the recovery metadata. It needs to be stored because if
157 metadata sender crashes another member need to send the metadata. If member
158 is the sender, this method also initiate the metadata send request.
159
160 @param[in] pevent the event to be injected
161 @param[in] cont the object used to wait
162
163 @return the operation status
164 @retval 0 OK
165 @retval !=0 Error
166 */
168
169 /**
170 If VC is delayed this method pushes the metadata for later processing else
171 it processes the VC Packet.
172
173 @param[in] pevent the event to be injected
174 @param[in] cont the object used to wait
175
176 @return the operation status
177 @retval 0 OK
178 @retval !=0 Error
179 */
181 Continuation *cont);
182
183 /**
184 This methods handles transaction identifier events, it does two tasks:
185 1. Using transaction context previously processed and stored,
186 validate that this transaction does not conflict with any other;
187 2. If the transaction does not conflict and it is allowed to commit,
188 it does inform the server of that decision and does update the
189 transaction identifier if needed.
190
191 @param[in] pevent the event to be injected
192 @param[in] cont the object used to wait
193
194 @return the operation status
195 @retval 0 OK
196 @retval !=0 Error
197 */
199
200 /*
201 This method extracts the certification db and the sequence number from
202 the certifier injecting them in a View change event to be sent to a possible
203 joiner.
204 */
206
207 /**
208 Create a transactional block for the received log event
209 GTID
210 BEGIN
211 EVENT
212 COMMIT
213
214 @param[in] pevent the event to be injected
215 @param[in] gtid The transaction GTID
216 If {-1, -1}, one will be generated.
217 @param[in] bgc_ticket The commit ticket order for this transaction
218 on the binlog group commit.
219 If 0, one will be generated.
220 @param[in] cont the object used to wait
221
222
223 @return the operation status
224 @retval 0 OK
225 @retval !=0 Error
226 */
229 Continuation *cont);
230
231 /**
232 Try to log a view change event waiting for local certified transactions to
233 finish.
234
235 @param[in] view_pevent the event to be injected
236 @param[in] cont the object used to wait
237
238
239 @return the operation status
240 @retval 0 OK
241 @retval !=0 Error
242 */
244 Continuation *cont);
245
246 /**
247 Generate a commit order ticket for the View_change transaction.
248
249 More precisely it will:
250 1) increment the current ticket so that the all transactions
251 ordered before view will have a ticket smaller than the one
252 assigned to the view.
253 2) generate the ticket for the view.
254 3) increment again the current ticket so that all transactions
255 ordered after the view will have a ticket greater that the
256 one assigned to the view.
257
258 @return the ticket generated for the view
259 */
261
262 /**
263 Increment a commit order ticket for the View_change transaction.
264
265 More precisely it will:
266 1) NOT generate the ticket for the view.
267 2) increment the current ticket so that all transactions ordered after the
268 view will have a ticket greater that the one assigned to the view.
269 */
271};
272
273#endif /* CERTIFICATION_HANDLER_INCLUDE */
Definition: certification_handler.h:31
Pipeline_event * transaction_context_pevent
Definition: certification_handler.h:54
int get_role() override
This method returns the handler role.
Definition: certification_handler.cc:919
int handle_recovery_metadata(Pipeline_event *pevent, Continuation *cont)
This method saves the recovery metadata.
Definition: certification_handler.cc:169
int handle_view_change_packet_without_vcle(Pipeline_event *pevent, Continuation *cont)
If VC is delayed this method pushes the metadata for later processing else it processes the VC Packet...
Definition: certification_handler.cc:247
~Certification_handler() override
Definition: certification_handler.cc:45
Certification_handler()
Definition: certification_handler.cc:38
binlog::BgcTicket::ValueType increment_bgc_ticket()
Increment a commit order ticket for the View_change transaction.
Definition: certification_handler.cc:904
Certifier * cert_module
Definition: certification_handler.h:47
int handle_binary_log_event(Pipeline_event *pevent, Continuation *cont)
This method handles binary log events by storing them so they can be used on next handler.
Definition: certification_handler.cc:129
int handle_transaction_id(Pipeline_event *pevent, Continuation *cont)
This methods handles transaction identifier events, it does two tasks:
Definition: certification_handler.cc:445
std::list< std::unique_ptr< View_change_stored_info > > pending_view_change_events_waiting_for_consistent_transactions
All the VC events pending application due to consistent transactions.
Definition: certification_handler.h:70
void reset_transaction_context()
Reset transaction context.
Definition: certification_handler.cc:353
int handle_applier_event(Pipeline_event *pevent, Continuation *cont)
This method handles applier context events by storing them so they can be used on next handler.
Definition: certification_handler.cc:148
binlog::BgcTicket::ValueType generate_view_change_bgc_ticket()
Generate a commit order ticket for the View_change transaction.
Definition: certification_handler.cc:884
THD * applier_module_thd
Definition: certification_handler.h:49
int terminate() override
Terminate the execution as defined in the handler implementation.
Definition: certification_handler.cc:58
int get_transaction_context(Pipeline_event *pevent, Transaction_context_log_event **tcle)
Get transaction context set on previous event handler.
Definition: certification_handler.cc:314
int handle_event(Pipeline_event *ev, Continuation *cont) override
Handling of an event as defined in the handler implementation.
Definition: certification_handler.cc:111
int set_certification_info(std::map< std::string, std::string > *cert_info)
int initialize() override
Initialization as defined in the handler implementation.
Definition: certification_handler.cc:51
Certifier_interface * get_certifier()
Definition: certification_handler.cc:921
int handle_transaction_context(Pipeline_event *pevent, Continuation *cont)
This method handles transaction context events by storing them so they can be used on next handler.
Definition: certification_handler.cc:375
int handle_action(Pipeline_action *action) override
Handling of an action as defined in the handler implementation.
Definition: certification_handler.cc:69
int log_view_change_event_in_order(Pipeline_event *view_pevent, Continuation *cont)
Try to log a view change event waiting for local certified transactions to finish.
Definition: certification_handler.cc:813
Data_packet * transaction_context_packet
Definition: certification_handler.h:53
int handle_applier_view_change_packet(Pipeline_event *pevent, Continuation *cont)
This method handles applier view change packet.
Definition: certification_handler.cc:161
bool is_unique() override
This method identifies the handler as being unique.
Definition: certification_handler.cc:917
rpl_sidno group_sidno
Definition: certification_handler.h:51
int set_transaction_context(Pipeline_event *pevent)
Set transaction context for next event handler.
Definition: certification_handler.cc:281
int inject_transactional_events(Pipeline_event *pevent, Gtid gtid, binlog::BgcTicket::ValueType bgc_ticket, Continuation *cont)
Create a transactional block for the received log event GTID BEGIN EVENT COMMIT.
Definition: certification_handler.cc:706
int extract_certification_info(Pipeline_event *pevent, Continuation *cont)
Definition: certification_handler.cc:663
Definition: certifier.h:192
Definition: certifier.h:218
Class used to wait on the execution of some action.
Definition: pipeline_interfaces.h:535
A wrapper for raw network packets.
Definition: pipeline_interfaces.h:75
Interface for the application of events, them being packets or log events.
Definition: pipeline_interfaces.h:660
A wrapper for pipeline actions.
Definition: pipeline_interfaces.h:630
A wrapper for log events/packets.
Definition: pipeline_interfaces.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
This is the subclass of Transaction_context_event and Log_event This class encodes the transaction_co...
Definition: log_event.h:4321
std::uint64_t ValueType
Definition: bgc_ticket.h:55
repeated Action action
Definition: replication_group_member_actions.proto:42
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:107
View change information information stored for delay.
Definition: certification_handler.h:57
View_change_stored_info(Pipeline_event *vc_pevent, Gtid gtid, binlog::BgcTicket::ValueType bgc_ticket)
Definition: certification_handler.h:61
Pipeline_event * view_change_pevent
Definition: certification_handler.h:58
binlog::BgcTicket::ValueType bgc_ticket
Definition: certification_handler.h:60
Gtid view_change_gtid
Definition: certification_handler.h:59
TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1099