MySQL 8.0.37
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 int set_certification_info(std::map<std::string, std::string> *cert_info);
46
47 private:
49
51
53
56
57 /** View change information information stored for delay */
64 : view_change_pevent(vc_pevent),
65 view_change_gtid(gtid),
67 };
68
69 /** All the VC events pending application due to consistent transactions */
70 std::list<std::unique_ptr<View_change_stored_info>>
72
73 /**
74 Set transaction context for next event handler.
75
76 @param[in] pevent Pipeline event that wraps
77 Transaction_context_log_event.
78
79 @return Operation status
80 @retval 0 OK
81 @retval !=0 Error
82 */
84
85 /**
86 Get transaction context set on previous event handler.
87
88 @param[in] pevent Pipeline event that wraps
89 Gtid_log_event.
90 @param[out] tcle Transaction_context_log_event.
91
92 @return Operation status
93 @retval 0 OK
94 @retval !=0 Error
95 */
98
99 /**
100 Reset transaction context.
101 */
103
104 /**
105 This method handles transaction context events by storing them
106 so they can be used on next handler.
107
108 @param[in] pevent the event to be injected
109 @param[in] cont the object used to wait
110
111 @return the operation status
112 @retval 0 OK
113 @retval !=0 Error
114 */
116
117 /**
118 This methods handles transaction identifier events, it does two tasks:
119 1. Using transaction context previously processed and stored,
120 validate that this transaction does not conflict with any other;
121 2. If the transaction does not conflict and it is allowed to commit,
122 it does inform the server of that decision and does update the
123 transaction identifier if needed.
124
125 @param[in] pevent the event to be injected
126 @param[in] cont the object used to wait
127
128 @return the operation status
129 @retval 0 OK
130 @retval !=0 Error
131 */
133
134 /*
135 This method extracts the certification db and the sequence number from
136 the certifier injecting them in a View change event to be sent to a possible
137 joiner.
138 */
140
141 /**
142 Create a transactional block for the received log event
143 GTID
144 BEGIN
145 EVENT
146 COMMIT
147
148 @param[in] pevent the event to be injected
149 @param[in] gtid The transaction GTID
150 If {-1, -1}, one will be generated.
151 @param[in] bgc_ticket The commit ticket order for this transaction
152 on the binlog group commit.
153 If 0, one will be generated.
154 @param[in] cont the object used to wait
155
156
157 @return the operation status
158 @retval 0 OK
159 @retval !=0 Error
160 */
163 Continuation *cont);
164
165 /**
166 Try to log a view change event waiting for local certified transactions to
167 finish.
168
169 @param[in] view_pevent the event to be injected
170 @param[in] cont the object used to wait
171
172
173 @return the operation status
174 @retval 0 OK
175 @retval !=0 Error
176 */
178 Continuation *cont);
179
180 /**
181 Generate a commit order ticket for the View_change transaction.
182
183 More precisely it will:
184 1) increment the current ticket so that the all transactions
185 ordered before view will have a ticket smaller than the one
186 assigned to the view.
187 2) generate the ticket for the view.
188 3) increment again the current ticket so that all transactions
189 ordered after the view will have a ticket greater that the
190 one assigned to the view.
191
192 @return the ticket generated for the view
193 */
195};
196
197#endif /* CERTIFICATION_HANDLER_INCLUDE */
Definition: certification_handler.h:32
Pipeline_event * transaction_context_pevent
Definition: certification_handler.h:55
int get_role() override
This method returns the handler role.
Definition: certification_handler.cc:737
~Certification_handler() override
Definition: certification_handler.cc:42
Certification_handler()
Definition: certification_handler.cc:35
Certifier * cert_module
Definition: certification_handler.h:48
int handle_transaction_id(Pipeline_event *pevent, Continuation *cont)
This methods handles transaction identifier events, it does two tasks:
Definition: certification_handler.cc:234
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:71
void reset_transaction_context()
Reset transaction context.
Definition: certification_handler.cc:198
binlog::BgcTicket::ValueType generate_view_change_bgc_ticket()
Generate a commit order ticket for the View_change transaction.
Definition: certification_handler.cc:715
THD * applier_module_thd
Definition: certification_handler.h:50
int terminate() override
Terminate the execution as defined in the handler implementation.
Definition: certification_handler.cc:55
int get_transaction_context(Pipeline_event *pevent, Transaction_context_log_event **tcle)
Get transaction context set on previous event handler.
Definition: certification_handler.cc:159
int handle_event(Pipeline_event *ev, Continuation *cont) override
Handling of an event as defined in the handler implementation.
Definition: certification_handler.cc:108
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:48
Certifier_interface * get_certifier()
Definition: certification_handler.cc:739
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:220
int handle_action(Pipeline_action *action) override
Handling of an action as defined in the handler implementation.
Definition: certification_handler.cc:66
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:644
Data_packet * transaction_context_packet
Definition: certification_handler.h:54
bool is_unique() override
This method identifies the handler as being unique.
Definition: certification_handler.cc:735
rpl_sidno group_sidno
Definition: certification_handler.h:52
int set_transaction_context(Pipeline_event *pevent)
Set transaction context for next event handler.
Definition: certification_handler.cc:126
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:544
int extract_certification_info(Pipeline_event *pevent, Continuation *cont)
Definition: certification_handler.cc:503
Definition: certifier.h:174
Definition: certifier.h:195
Class used to wait on the execution of some action.
Definition: pipeline_interfaces.h:462
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:587
A wrapper for pipeline actions.
Definition: pipeline_interfaces.h:557
A wrapper for log events/packets.
Definition: pipeline_interfaces.h:128
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
This is the subclass of Transaction_context_event and Log_event This class encodes the transaction_co...
Definition: log_event.h:4130
std::uint64_t ValueType
Definition: bgc_ticket.h:56
repeated Action action
Definition: replication_group_member_actions.proto:43
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:96
View change information information stored for delay.
Definition: certification_handler.h:58
View_change_stored_info(Pipeline_event *vc_pevent, Gtid gtid, binlog::BgcTicket::ValueType bgc_ticket)
Definition: certification_handler.h:62
Pipeline_event * view_change_pevent
Definition: certification_handler.h:59
binlog::BgcTicket::ValueType bgc_ticket
Definition: certification_handler.h:61
Gtid view_change_gtid
Definition: certification_handler.h:60
TODO: Move this structure to libbinlogevents/include/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1066