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