MySQL  8.0.19
Source Code Documentation
certification_handler.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
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  virtual ~Certification_handler();
36  int handle_action(Pipeline_action *action);
37  int initialize();
38  int terminate();
39  bool is_unique();
40  int get_role();
41 
43 
44  int set_certification_info(std::map<std::string, std::string> *cert_info);
45 
46  private:
48 
50 
52 
55 
56  /** Are view change on wait for application */
58 
59  /** View change information information stored for delay */
62  std::string local_gtid_certified;
65  std::string &local_gtid_string, rpl_gno gno)
66  : view_change_pevent(vc_pevent),
67  local_gtid_certified(local_gtid_string),
68  view_change_event_gno(gno) {}
69  };
70 
71  /** All the VC events pending application due to timeout */
72  std::list<View_change_stored_info *> pending_view_change_events;
73 
74  /**
75  Set transaction context for next event handler.
76 
77  @param[in] pevent Pipeline event that wraps
78  Transaction_context_log_event.
79 
80  @return Operation status
81  @retval 0 OK
82  @retval !=0 Error
83  */
85 
86  /**
87  Get transaction context set on previous event handler.
88 
89  @param[in] pevent Pipeline event that wraps
90  Gtid_log_event.
91  @param[out] tcle Transaction_context_log_event.
92 
93  @return Operation status
94  @retval 0 OK
95  @retval !=0 Error
96  */
99 
100  /**
101  Reset transaction context.
102  */
104 
105  /**
106  This method handles transaction context events by storing them
107  so they can be used on next handler.
108 
109  @param[in] pevent the event to be injected
110  @param[in] cont the object used to wait
111 
112  @return the operation status
113  @retval 0 OK
114  @retval !=0 Error
115  */
117 
118  /**
119  This methods handles transaction identifier events, it does two tasks:
120  1. Using transaction context previously processed and stored,
121  validate that this transaction does not conflict with any other;
122  2. If the transaction does not conflict and it is allowed to commit,
123  it does inform the server of that decision and does update the
124  transaction identifier if needed.
125 
126  @param[in] pevent the event to be injected
127  @param[in] cont the object used to wait
128 
129  @return the operation status
130  @retval 0 OK
131  @retval !=0 Error
132  */
134 
135  /*
136  This method extracts the certification db and the sequence number from
137  the certifier injecting them in a View change event to be sent to a possible
138  joiner.
139  */
141 
142  /**
143  This methods guarantees that the view change event is logged after local
144  transactions are executed.
145 
146  @param local_gtid_certified_string The set to wait.
147  If not defined, it extracts the current
148  certified set
149 
150  @retval 0 OK
151  @retval LOCAL_WAIT_TIMEOUT_ERROR Timeout error on wait
152  @retval !=0 Wait or interface error
153  */
155  std::string &local_gtid_certified_string);
156 
157  /**
158  Create a transactional block for the received log event
159  GTID
160  BEGIN
161  EVENT
162  COMMIT
163 
164  @param[in] pevent the event to be injected
165  @param[in, out] event_gno The transaction GTID gno
166  If -1, one will be generated.
167  @param[in] cont the object used to wait
168 
169 
170  @return the operation status
171  @retval 0 OK
172  @retval !=0 Error
173  */
174  int inject_transactional_events(Pipeline_event *pevent, rpl_gno *event_gno,
175  Continuation *cont);
176 
177  /**
178  Try to log a view change event waiting for local certified transactions to
179  finish.
180 
181  @param[in] view_pevent the event to be injected
182  @param[in, out] local_gtid_string The local certified transaction set to
183  wait If empty, one will be assigned even on timeout
184  @param[in, out] event_gno The transaction GTID gno
185  If -1, one will be generated.
186  @param[in] cont the object used to wait
187 
188 
189  @return the operation status
190  @retval 0 OK
191  @retval LOCAL_WAIT_TIMEOUT_ERROR Timeout error on wait for local
192  transactions
193  @retval !=0 Error
194  */
196  std::string &local_gtid_string,
197  rpl_gno *event_gno, Continuation *cont);
198 
199  /**
200  Store the event for future logging as a timeout occurred.
201  This method does 2 things:
202  1. If not stored in the past, it stores the Pipeline event to
203  be logged in the future
204  2. It queues again in the applier a fake View change log event
205  to ensure the logging method will be invoked eventually
206 
207  @param[in] pevent The event to be stored
208  @param[in] local_gtid_certified_string The local certified transaction set
209  to wait
210  @param[in] event_gno The transaction GTID gno
211  @param[in] cont Used to discard or not the transaction
212 
213 
214  @return the operation status
215  @retval 0 OK
216  @retval !=0 Error
217  */
219  Pipeline_event *pevent, std::string &local_gtid_certified_string,
220  rpl_gno event_gno, Continuation *cont);
221 
222  /**
223  Logs all the delayed View Change log events stored.
224 
225  @param[in] cont the object used to mark error or success
226 
227  @return the operation status
228  @retval 0 OK
229  @retval LOCAL_WAIT_TIMEOUT_ERROR Timeout error on wait for local
230  transactions
231  @retval !=0 Error
232  */
234 };
235 
236 #endif /* CERTIFICATION_HANDLER_INCLUDE */
THD
Definition: sql_class.h:764
Certification_handler::handle_transaction_id
int handle_transaction_id(Pipeline_event *pevent, Continuation *cont)
This methods handles transaction identifier events, it does two tasks:
Definition: certification_handler.cc:219
Certification_handler::handle_transaction_context
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:205
Certification_handler::set_certification_info
int set_certification_info(std::map< std::string, std::string > *cert_info)
Certification_handler::get_transaction_context
int get_transaction_context(Pipeline_event *pevent, Transaction_context_log_event **tcle)
Get transaction context set on previous event handler.
Definition: certification_handler.cc:155
Pipeline_event
Definition: pipeline_interfaces.h:122
Certification_handler::pending_view_change_events
std::list< View_change_stored_info * > pending_view_change_events
All the VC events pending application due to timeout.
Definition: certification_handler.h:72
Certifier_interface
Definition: certifier.h:174
Certification_handler::is_unique
bool is_unique()
This method identifies the handler as being unique.
Definition: certification_handler.cc:802
Certification_handler::cert_module
Certifier * cert_module
Definition: certification_handler.h:47
Certification_handler::group_sidno
rpl_sidno group_sidno
Definition: certification_handler.h:51
Certification_handler::~Certification_handler
virtual ~Certification_handler()
Definition: certification_handler.cc:44
rpl_sidno
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:94
Certification_handler::transaction_context_pevent
Pipeline_event * transaction_context_pevent
Definition: certification_handler.h:54
Certification_handler::View_change_stored_info::view_change_pevent
Pipeline_event * view_change_pevent
Definition: certification_handler.h:61
Certification_handler::get_role
int get_role()
This method returns the handler role.
Definition: certification_handler.cc:804
Certification_handler::get_certifier
Certifier_interface * get_certifier()
Definition: certification_handler.cc:806
certifier.h
Event_handler
Definition: pipeline_interfaces.h:532
Certification_handler
Definition: certification_handler.h:31
Certification_handler::handle_event
int handle_event(Pipeline_event *ev, Continuation *cont)
Handling of an event as defined in the handler implementation.
Definition: certification_handler.cc:117
Certification_handler::inject_transactional_events
int inject_transactional_events(Pipeline_event *pevent, rpl_gno *event_gno, Continuation *cont)
Create a transactional block for the received log event GTID BEGIN EVENT COMMIT.
Definition: certification_handler.cc:640
Certification_handler::wait_for_local_transaction_execution
int wait_for_local_transaction_execution(std::string &local_gtid_certified_string)
This methods guarantees that the view change event is logged after local transactions are executed.
Definition: certification_handler.cc:601
Certification_handler::Certification_handler
Certification_handler()
Definition: certification_handler.cc:36
Certification_handler::View_change_stored_info::local_gtid_certified
std::string local_gtid_certified
Definition: certification_handler.h:62
Certification_handler::View_change_stored_info::view_change_event_gno
rpl_gno view_change_event_gno
Definition: certification_handler.h:63
Data_packet
Definition: pipeline_interfaces.h:70
Certification_handler::m_view_change_event_on_wait
bool m_view_change_event_on_wait
Are view change on wait for application.
Definition: certification_handler.h:57
Transaction_context_log_event
Definition: log_event.h:4047
rpl_gno
long long int rpl_gno
Type of GNO, the second (numeric) component of GTID.
Definition: rpl_gtid.h:100
Certification_handler::handle_action
int handle_action(Pipeline_action *action)
Handling of an action as defined in the handler implementation.
Definition: certification_handler.cc:75
Certification_handler::reset_transaction_context
void reset_transaction_context()
Reset transaction context.
Definition: certification_handler.cc:194
Certification_handler::View_change_stored_info
View change information information stored for delay.
Definition: certification_handler.h:60
Certification_handler::extract_certification_info
int extract_certification_info(Pipeline_event *pevent, Continuation *cont)
Definition: certification_handler.cc:479
Pipeline_action
Definition: pipeline_interfaces.h:502
Certification_handler::store_view_event_for_delayed_logging
int store_view_event_for_delayed_logging(Pipeline_event *pevent, std::string &local_gtid_certified_string, rpl_gno event_gno, Continuation *cont)
Store the event for future logging as a timeout occurred.
Definition: certification_handler.cc:563
Certification_handler::applier_module_thd
THD * applier_module_thd
Definition: certification_handler.h:49
Certification_handler::terminate
int terminate()
Terminate the execution as defined in the handler implementation.
Definition: certification_handler.cc:64
Certification_handler::set_transaction_context
int set_transaction_context(Pipeline_event *pevent)
Set transaction context for next event handler.
Definition: certification_handler.cc:135
Certification_handler::log_view_change_event_in_order
int log_view_change_event_in_order(Pipeline_event *view_pevent, std::string &local_gtid_string, rpl_gno *event_gno, Continuation *cont)
Try to log a view change event waiting for local certified transactions to finish.
Definition: certification_handler.cc:738
Certifier
Definition: certifier.h:193
Certification_handler::log_delayed_view_change_events
int log_delayed_view_change_events(Continuation *cont)
Logs all the delayed View Change log events stored.
Definition: certification_handler.cc:541
Certification_handler::transaction_context_packet
Data_packet * transaction_context_packet
Definition: certification_handler.h:53
Continuation
Definition: pipeline_interfaces.h:407
Certification_handler::View_change_stored_info::View_change_stored_info
View_change_stored_info(Pipeline_event *vc_pevent, std::string &local_gtid_string, rpl_gno gno)
Definition: certification_handler.h:64
group_replication_priv.h
Certification_handler::initialize
int initialize()
Initialization as defined in the handler implementation.
Definition: certification_handler.cc:57