MySQL  8.0.18
Source Code Documentation
certifier.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 CERTIFIER_INCLUDE
24 #define CERTIFIER_INCLUDE
25 
27 #include <list>
28 #include <map>
29 #include <string>
30 #include <unordered_map>
31 #include <vector>
32 
33 #include "my_dbug.h"
34 #include "my_inttypes.h"
42 
43 /**
44  This class extends Gtid_set to include a reference counter.
45 
46  It is for Certifier only, so it is single-threaded and no locks
47  are needed since Certifier already ensures sequential use.
48 
49  It is to be used to share by multiple entries in the
50  certification info and released when the last reference to it
51  needs to be freed.
52 */
53 class Gtid_set_ref : public Gtid_set {
54  public:
56  : Gtid_set(sid_map),
59 
60  virtual ~Gtid_set_ref() {}
61 
62  /**
63  Increment the number of references by one.
64 
65  @return the number of references
66  */
67  size_t link() { return ++reference_counter; }
68 
69  /**
70  Decrement the number of references by one.
71 
72  @return the number of references
73  */
74  size_t unlink() {
76  return --reference_counter;
77  }
78 
81  }
82 
83  private:
86 };
87 
88 /**
89  This class is a core component of the database state machine
90  replication protocol. It implements conflict detection based
91  on a certification procedure.
92 
93  Snapshot Isolation is based on assigning logical timestamp to optimistic
94  transactions, i.e. the ones which successfully meet certification and
95  are good to commit on all members in the group. This timestamp is a
96  monotonically increasing counter, and is same across all members in the group.
97 
98  This timestamp, which in our algorithm is the snapshot version, is further
99  used to update the certification info.
100  The snapshot version maps the items in a transaction to the GTID_EXECUTED
101  that this transaction saw when it was executed, that is, on which version
102  the transaction was executed.
103 
104  If the incoming transaction snapshot version is a subset of a
105  previous certified transaction for the same write set, the current
106  transaction was executed on top of outdated data, so it will be
107  negatively certified. Otherwise, this transaction is marked
108  certified and goes into applier.
109 */
110 typedef std::unordered_map<std::string, Gtid_set_ref *> Certification_info;
111 
113  public:
114  /**
115  Certifier_broadcast_thread constructor
116  */
118  virtual ~Certifier_broadcast_thread();
119 
120  /**
121  Initialize broadcast thread.
122 
123  @return the operation status
124  @retval 0 OK
125  @retval !=0 Error
126  */
127  int initialize();
128 
129  /**
130  Terminate broadcast thread.
131 
132  @return the operation status
133  @retval 0 OK
134  @retval !=0 Error
135  */
136  int terminate();
137 
138  /**
139  Broadcast thread worker method.
140  */
141  void dispatcher();
142 
143  /**
144  Period (in seconds) between stable transactions set
145  broadcast.
146  */
147  static const int BROADCAST_GTID_EXECUTED_PERIOD = 60; // seconds
148 
149  private:
150  /**
151  Thread control.
152  */
153  bool aborted;
163 
164  /**
165  Broadcast local GTID_EXECUTED to group.
166 
167  @return the operation status
168  @retval 0 OK
169  @retval !=0 Error
170  */
172 };
173 
175  public:
176  virtual ~Certifier_interface() {}
177  virtual void handle_view_change() = 0;
178  virtual int handle_certifier_data(
179  const uchar *data, ulong len,
180  const Gcs_member_identifier &gcs_member_id) = 0;
181 
182  virtual void get_certification_info(
183  std::map<std::string, std::string> *cert_info) = 0;
184  virtual int set_certification_info(
185  std::map<std::string, std::string> *cert_info) = 0;
187  Gtid_set *executed_gtid_set) = 0;
188  virtual void enable_conflict_detection() = 0;
189  virtual void disable_conflict_detection() = 0;
190  virtual bool is_conflict_detection_enable() = 0;
191 };
192 
194  public:
195  Certifier();
196  virtual ~Certifier();
197 
198  /**
199  Key used to store errors in the certification info
200  on View_change_log_event.
201  */
202  static const std::string CERTIFICATION_INFO_ERROR_NAME;
203 
204  /**
205  Initialize certifier.
206 
207  @param gtid_assignment_block_size the group gtid assignment block size
208 
209  @return the operation status
210  @retval 0 OK
211  @retval !=0 Error
212  */
214 
215  /**
216  Terminate certifier.
217 
218  @return the operation status
219  @retval 0 OK
220  @retval !=0 Error
221  */
222  int terminate();
223 
224  /**
225  Handle view changes on certifier.
226  */
227  virtual void handle_view_change();
228 
229  /**
230  Queues the packet coming from the reader for future processing.
231 
232  @param[in] data the packet data
233  @param[in] len the packet length
234  @param[in] gcs_member_id the member_id which sent the message
235 
236  @return the operation status
237  @retval 0 OK
238  @retval !=0 Error on queue
239  */
240  virtual int handle_certifier_data(const uchar *data, ulong len,
241  const Gcs_member_identifier &gcs_member_id);
242 
243  /**
244  This member function SHALL certify the set of items against transactions
245  that have already passed the certification test.
246 
247  @param snapshot_version The incoming transaction snapshot version.
248  @param write_set The incoming transaction write set.
249  @param generate_group_id Flag that indicates if transaction group id
250  must be generated.
251  @param member_uuid The UUID of the member from which this
252  transaction originates.
253  @param gle The incoming transaction global identifier
254  event.
255  @param local_transaction True if this transaction did originate from
256  this member, false otherwise.
257 
258  @retval >0 transaction identifier (positively certified).
259  If generate_group_id is false and certification
260  positive a 1 is returned;
261  @retval 0 negatively certified;
262  @retval -1 error.
263  */
264  rpl_gno certify(Gtid_set *snapshot_version,
265  std::list<const char *> *write_set, bool generate_group_id,
266  const char *member_uuid, Gtid_log_event *gle,
267  bool local_transaction);
268 
269  /**
270  Returns the transactions in stable set in text format, that is, the set of
271  transactions already applied on all group members.
272 
273  @param[out] buffer Pointer to pointer to string. The method will set it to
274  point to the newly allocated buffer, or NULL on out of
275  memory.
276  Caller must free the allocated memory.
277  @param[out] length Length of the generated string.
278 
279  @return the operation status
280  @retval 0 OK
281  @retval !=0 Out of memory error
282  */
284 
285  /**
286  Retrieves the current certification info.
287 
288  @note if concurrent access is introduce to these variables,
289  locking is needed in this method
290 
291  @param[out] cert_info a pointer to retrieve the certification info
292  */
293  virtual void get_certification_info(
294  std::map<std::string, std::string> *cert_info);
295 
296  /**
297  Sets the certification info according to the given value.
298 
299  @note if concurrent access is introduce to these variables,
300  locking is needed in this method
301 
302  @param[in] cert_info certification info retrieved from recovery procedure
303 
304  @retval > 0 Error during setting certification info.
305  @retval = 0 Everything went fine.
306  */
307  virtual int set_certification_info(
308  std::map<std::string, std::string> *cert_info);
309 
310  /**
311  Get the number of postively certified transactions by the certifier
312  */
314 
315  /**
316  Get method to retrieve the number of negatively certified transactions.
317  */
319 
320  /**
321  Get method to retrieve the certification db size.
322  */
324 
325  /**
326  Get method to retrieve the last conflict free transaction.
327 
328  @param[out] value The last conflict free transaction
329  */
330  void get_last_conflict_free_transaction(std::string *value);
331 
332  /**
333  Get method to retrieve the size of the members.
334  */
335  size_t get_members_size();
336 
337  /**
338  Generate group GNO for a view change log event.
339 
340  @retval >0 view change GNO
341  @retval otherwise Error on GNO generation
342  */
344 
345  /**
346  Public method to add the given gno value to the group_gtid_executed set
347  which is used to support skip gtid functionality.
348 
349  @param[in] gno The gno of the transaction which will be added to the
350  group_gtid executed GTID set. The sidno used for this
351  transaction will be the group_sidno. The gno here belongs specifically to
352  the group UUID.
353  @param[in] local If the gtid value is local or comes from a remote server
354 
355  @retval 1 error during addition.
356  @retval 0 success.
357  */
358  int add_group_gtid_to_group_gtid_executed(rpl_gno gno, bool local);
359 
360  /**
361  Public method to add the given GTID value in the group_gtid_executed set
362  which is used to support skip gtid functionality.
363 
364  @param[in] gle The gtid value that needs to the added in the
365  group_gtid_executed GTID set.
366  @param[in] local If the gtid value is local or comes from a remote server
367 
368  @retval 1 error during addition.
369  @retval 0 success.
370  */
372  bool local);
373 
374  /**
375  This member function shall add transactions to the stable set
376 
377  @param executed_gtid_set The GTID set of the transactions to be added
378  to the stable set.
379 
380  @note when set, the stable set will cause the garbage collection
381  process to be invoked
382 
383  @returns
384  @retval False if adds successfully,
385  @retval True otherwise.
386  */
387  bool set_group_stable_transactions_set(Gtid_set *executed_gtid_set);
388 
389  /**
390  Method to get a string that represents the last local certified GTID
391 
392  @param[out] local_gtid_certified_string The last local GTID transaction
393  string
394 
395  @retval 0 if there is no GTID / the string is empty
396  @retval !=0 the size of the string
397  */
398  size_t get_local_certified_gtid(std::string &local_gtid_certified_string);
399 
400  /**
401  Enables conflict detection.
402  */
404 
405  /**
406  Disables conflict detection.
407  */
409 
410  /**
411  Check if conflict detection is enable.
412 
413  @returns
414  @retval True conflict detection is enable
415  @retval False otherwise
416  */
418 
419  private:
420  /**
421  Key used to store group_gtid_executed on certification
422  info on View_change_log_event.
423  */
424  static const std::string GTID_EXTRACTED_NAME;
425 
426  /**
427  Is certifier initialized.
428  */
430 
431  /**
432  Variable to store the sidno used for transactions which will be logged
433  with the group_uuid.
434  */
436 
437  /**
438  Method to initialize the group_gtid_executed gtid set with the server gtid
439  executed set and applier retrieved gtid set values.
440 
441  @param get_server_gtid_retrieved add applier retrieved gtid set to
442  group_gtid_executed gtid set
443 
444  @retval 1 error during initialization
445  @retval 0 success
446 
447  */
448  int initialize_server_gtid_set(bool get_server_gtid_retrieved = false);
449 
450  /**
451  This function computes the available GTID intervals from group
452  UUID and stores them on group_available_gtid_intervals.
453  */
455 
456  /**
457  This function reserves a block of GTIDs from the
458  group_available_gtid_intervals list.
459 
460  @retval Gtid_set::Interval which is the interval os GTIDs attributed
461  */
463 
464  /**
465  This function updates parallel applier indexes.
466  It must be called for each remote transaction.
467 
468  @param[in] update_parallel_applier_last_committed_global
469  If true parallel_applier_last_committed_global
470  is updated to the current sequence number
471  (before update sequence number).
472 
473  Note: parallel_applier_last_committed_global should be updated
474  on the following situations:
475  1) Transaction without write set is certified, since it
476  represents the lowest last_committed for all future
477  transactions;
478  2) After certification info garbage collection, since we
479  do not know what write sets were purged, which may cause
480  transactions last committed to be incorrectly computed.
481  */
483  bool update_parallel_applier_last_committed_global);
484 
485  /**
486  Internal method to add the given gtid gno in the group_gtid_executed set.
487  This will be used in the skip gtid implementation.
488 
489  @note this will update the last know local transaction GTID.
490 
491  @param[in] sidno rpl_sidno part of the executing gtid of the ongoing
492  transaction.
493 
494  @param[in] gno rpl_gno part of the executing gtid of the ongoing
495  transaction.
496  @param[in] local_transaction if the GTID belongs to a local transaction
497  */
499  bool local_transaction);
500 
501  /**
502  This method is used to get the next valid GNO for the
503  transaction that is being executed. It checks the already used
504  up GNOs and based on that chooses the next possible value.
505  This method will consult group_available_gtid_intervals to
506  assign GTIDs in blocks according to gtid_assignment_block_size.
507 
508  @param member_uuid The UUID of the member from which this
509  transaction originates. It will be NULL
510  on View_change_log_event.
511 
512  @retval >0 The GNO to be used.
513  @retval -1 Error: GNOs exhausted for group UUID.
514  */
515  rpl_gno get_group_next_available_gtid(const char *member_uuid);
516 
517  /**
518  Generate the candidate GNO for the current transaction.
519  The candidate will be on the interval [start, end] or a error
520  be returned.
521  This method will consult group_gtid_executed to avoid generate
522  the same value twice.
523 
524  @param start The first possible value for the GNO
525  @param end The last possible value for the GNO
526 
527  @retval >0 The GNO to be used.
528  @retval -1 Error: GNOs exhausted for group UUID.
529  @retval -2 Error: generated GNO is bigger than end.
530  */
532  rpl_gno end) const;
533 
534  bool inline is_initialized() { return initialized; }
535 
537 
538  /**
539  Method to clear the members.
540  */
541  void clear_members();
542 
543  /**
544  Last conflict free transaction identification.
545  */
547 
548  /**
549  Certification database.
550  */
553 
558 
559 #if !defined(DBUG_OFF)
562 #endif
563 
565 
566  /**
567  Stable set and garbage collector variables.
568  */
573 
574  std::vector<std::string> members;
575 
576  /*
577  Flag to indicate that certifier is handling already applied
578  transactions during distributed recovery procedure.
579 
580  On donor we may have local transactions certified after
581  View_change_log_event (VCLE) logged into binary log before VCLE.
582  That is, these local transactions will be appear on recovery
583  and also on GCS messages. One can see on example scenario below:
584 
585  GCS order | donor binary log order | joiner apply order
586  -----------+------------------------+--------------------
587  T1 | T1 | T1
588  T2 | T2 | T2
589  V1 | T3 | T3 (recovery)
590  T3 | V1 | V1
591  | | T3 (GCS)
592  -----------+------------------------+--------------------
593 
594  T3 is delivered to donor by both recovery and GCS, so joiner needs
595  to ensure that T3 has the same global identifier on both cases, so
596  that it is correctly skipped on the second time it is applied.
597 
598  We ensure that T3 (and other transactions on that situation) have
599  the same global identifiers on joiner by:
600  1) When the VCLE is applied, we set on joiner certification info
601  the same exact certification that was on donor, including the
602  set of certified transactions before the joiner joined:
603  group_gtid_extracted.
604  2) We compare group_gtid_extracted and group_gtid_executed:
605  If group_gtid_extracted is a non equal subset of
606  group_gtid_executed, it means that we are on the above
607  scenario, that is, when applying the last transaction from
608  the distributed recovery process we have more transactions
609  than the ones certified before the view on which joiner joined.
610  So until group_gtid_extracted is a non equal subset of
611  group_gtid_executed certifier will generate transactions ids
612  following group_gtid_extracted so that we have the same exact
613  ids that donor has.
614  3) When joiner group_gtid_extracted and group_gtid_executed are
615  equal, joiner switches to its regular ids generation mode,
616  generating ids from group_gtid_executed.
617  */
619 
620  /*
621  Sid map to store the GTIDs that are executed in the group.
622  */
624 
625  /*
626  A Gtid_set containing the already executed for the group.
627  This is used to support skip_gtid.
628  */
630 
631  /**
632  A Gtid_set which contains the gtid extracted from the certification info
633  map of the donor. It is the set of transactions that is executed at the
634  time of View_change_log_event at donor.
635  */
637 
638  /**
639  The group GTID assignment block size.
640  */
642 
643  /**
644  List of free GTID intervals in group
645  */
646  std::list<Gtid_set::Interval> group_available_gtid_intervals;
647 
648  /**
649  Extends the above to allow GTIDs to be assigned in blocks per member.
650  */
651  std::map<std::string, Gtid_set::Interval> member_gtids;
653 
654  /**
655  Last local known GTID
656  */
658 
659  /**
660  Conflict detection is performed when:
661  1) group is on multi-master mode;
662  2) group is on single-primary mode and primary is applying
663  relay logs with transactions from a previous primary.
664  */
666 
668 
669  /**
670  Broadcast thread.
671  */
673 
674  /**
675  Adds an item from transaction writeset to the certification DB.
676  @param[in] item item in the writeset to be added to the
677  Certification DB.
678  @param[in] snapshot_version Snapshot version of the incoming transaction
679  which modified the above mentioned item.
680  @param[out] item_previous_sequence_number
681  The previous parallel applier sequence number
682  for this item.
683 
684  @return
685  @retval False successfully added to the map.
686  True otherwise.
687  */
688  bool add_item(const char *item, Gtid_set_ref *snapshot_version,
689  int64 *item_previous_sequence_number);
690 
691  /**
692  Find the snapshot_version corresponding to an item. Return if
693  it exists, other wise return NULL;
694 
695  @param[in] item item for the snapshot version.
696  @retval Gtid_set pointer if exists in the map.
697  Otherwise 0;
698  */
700 
701  /**
702  Computes intersection between all sets received, so that we
703  have the already applied transactions on all servers.
704 
705  @return the operation status
706  @retval 0 OK
707  @retval !=0 Error
708  */
709  int stable_set_handle();
710 
711  /**
712  Removes the intersection of the received transactions stable
713  sets from certification database.
714  */
715  void garbage_collect();
716 
717  /**
718  Clear incoming queue.
719  */
720  void clear_incoming();
721 
722  /*
723  Update method to store the count of the positively and negatively
724  certified transaction on a particular group member.
725  */
726  void update_certified_transaction_count(bool result, bool local_transaction);
727 };
728 
729 /*
730  @class Gtid_Executed_Message
731 
732  Class to convey the serialized contents of the previously executed GTIDs
733  */
735  public:
737  // This type should not be used anywhere.
739 
740  // Length of the payload item: variable
742 
743  // No valid type codes can appear after this one.
745  };
746 
747  /**
748  Gtid_Executed_Message constructor
749  */
751  virtual ~Gtid_Executed_Message();
752 
753  /**
754  Appends Gtid executed information in a raw format
755 
756  * @param[in] gtid_data encoded GTID data
757  * @param[in] len GTID data length
758  */
759  void append_gtid_executed(uchar *gtid_data, size_t len);
760 
761  protected:
762  /*
763  Implementation of the template methods of Gcs_plugin_message
764  */
765  void encode_payload(std::vector<unsigned char> *buffer) const;
766  void decode_payload(const unsigned char *buffer, const unsigned char *);
767 
768  private:
769  std::vector<uchar> data;
770 };
771 
772 #endif /* CERTIFIER_INCLUDE */
void dispatcher()
Broadcast thread worker method.
Definition: certifier.cc:126
virtual ~Certifier()
Definition: certifier.cc:287
Definition: result.h:33
unsigned long long int ulonglong
Definition: my_inttypes.h:55
mysql_cond_t broadcast_dispatcher_cond
Definition: certifier.h:159
virtual ~Gtid_set_ref()
Definition: certifier.h:60
mysql_mutex_t LOCK_certification_info
Definition: certifier.h:564
bool same_member_message_discarded
Definition: certifier.h:561
int rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:93
unsigned char uchar
Definition: my_inttypes.h:51
virtual int set_certification_info(std::map< std::string, std::string > *cert_info)
Sets the certification info according to the given value.
Definition: certifier.cc:1379
Sid_map * stable_sid_map
Definition: certifier.h:570
size_t broadcast_counter
Definition: certifier.h:161
virtual void enable_conflict_detection()=0
Gtid last_local_gtid
Last local known GTID.
Definition: certifier.h:657
thread_state broadcast_thd_state
Definition: certifier.h:160
virtual int handle_certifier_data(const uchar *data, ulong len, const Gcs_member_identifier &gcs_member_id)
Queues the packet coming from the reader for future processing.
Definition: certifier.cc:1153
Certifier()
Definition: certifier.cc:235
bool is_conflict_detection_enable()
Check if conflict detection is enable.
Definition: certifier.cc:1552
ulonglong positive_cert
Definition: certifier.h:554
void append_gtid_executed(uchar *gtid_data, size_t len)
Appends Gtid executed information in a raw format.
Definition: certifier.cc:1571
virtual void get_certification_info(std::map< std::string, std::string > *cert_info)=0
size_t unlink()
Decrement the number of references by one.
Definition: certifier.h:74
Synchronized_queue< Data_packet * > * incoming
Definition: certifier.h:572
Sid_map * group_gtid_sid_map
Definition: certifier.h:623
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
int add_specified_gtid_to_group_gtid_executed(Gtid_log_event *gle, bool local)
Public method to add the given GTID value in the group_gtid_executed set which is used to support ski...
Definition: certifier.cc:829
rpl_gno generate_view_change_group_gno()
Generate group GNO for a view change log event.
Definition: certifier.cc:1360
void get_last_conflict_free_transaction(std::string *value)
Get method to retrieve the last conflict free transaction.
Definition: certifier.cc:1505
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
Definition: certifier.h:744
Some integer typedefs for easier portability.
This class extends Gtid_set to include a reference counter.
Definition: certifier.h:53
size_t get_members_size()
Get method to retrieve the size of the members.
Definition: certifier.cc:1519
ulonglong get_negative_certified()
Get method to retrieve the number of negatively certified transactions.
Definition: certifier.cc:1499
virtual void handle_view_change()
Handle view changes on certifier.
Definition: certifier.cc:1323
mysql_mutex_t broadcast_run_lock
Definition: certifier.h:156
ulonglong get_certification_info_size()
Get method to retrieve the certification db size.
Definition: certifier.cc:1501
void clear_incoming()
Clear incoming queue.
Definition: certifier.cc:524
std::map< std::string, Gtid_set::Interval > member_gtids
Extends the above to allow GTIDs to be assigned in blocks per member.
Definition: certifier.h:651
size_t reference_counter
Definition: certifier.h:84
size_t get_local_certified_gtid(std::string &local_gtid_certified_string)
Method to get a string that represents the last local certified GTID.
Definition: certifier.cc:1521
Definition: certifier.h:112
void increment_parallel_applier_sequence_number(bool update_parallel_applier_last_committed_global)
This function updates parallel applier indexes.
Definition: certifier.cc:582
virtual bool is_conflict_detection_enable()=0
This is a subclass if Gtid_event and Log_event.
Definition: log_event.h:3556
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
std::vector< std::string > members
Definition: certifier.h:574
int64 parallel_applier_sequence_number
Definition: certifier.h:557
void clear_members()
Method to clear the members.
Definition: certifier.cc:533
Sid_map * certification_info_sid_map
Definition: certifier.h:552
void add_to_group_gtid_executed_internal(rpl_sidno sidno, rpl_gno gno, bool local_transaction)
Internal method to add the given gtid gno in the group_gtid_executed set.
Definition: certifier.cc:493
void clear_certification_info()
Definition: certifier.cc:514
TODO: Move this structure to libbinlogevents/include/control_events.h when we start using C++11...
Definition: rpl_gtid.h:924
Represents a bidirectional map between SID and SIDNO.
Definition: rpl_gtid.h:582
void enable_conflict_detection()
Enables conflict detection.
Definition: certifier.cc:1531
uint64 gtid_assignment_block_size
The group GTID assignment block size.
Definition: certifier.h:641
void decode_payload(const unsigned char *buffer, const unsigned char *)
Decodes the contents of the buffer and sets the payload field values according to the values decoded...
Definition: certifier.cc:1583
int broadcast_gtid_executed_period
Definition: certifier.h:162
virtual int set_certification_info(std::map< std::string, std::string > *cert_info)=0
rpl_gno certify(Gtid_set *snapshot_version, std::list< const char *> *write_set, bool generate_group_id, const char *member_uuid, Gtid_log_event *gle, bool local_transaction)
This member function SHALL certify the set of items against transactions that have already passed the...
Definition: certifier.cc:595
mysql_mutex_t broadcast_dispatcher_lock
Definition: certifier.h:158
bool certifying_already_applied_transactions
Definition: certifier.h:618
std::list< Gtid_set::Interval > group_available_gtid_intervals
List of free GTID intervals in group.
Definition: certifier.h:646
int add_group_gtid_to_group_gtid_executed(rpl_gno gno, bool local)
Public method to add the given gno value to the group_gtid_executed set which is used to support skip...
Definition: certifier.cc:856
bool add_item(const char *item, Gtid_set_ref *snapshot_version, int64 *item_previous_sequence_number)
Adds an item from transaction writeset to the certification DB.
Definition: certifier.cc:1002
bool aborted
Thread control.
Definition: certifier.h:153
static const std::string GTID_EXTRACTED_NAME
Key used to store group_gtid_executed on certification info on View_change_log_event.
Definition: certifier.h:424
Sid_map * sid_map
Sid_map associated with this Gtid_set.
Definition: rpl_gtid.h:2166
static const std::string CERTIFICATION_INFO_ERROR_NAME
Key used to store errors in the certification info on View_change_log_event.
Definition: certifier.h:202
int stable_set_handle()
Computes intersection between all sets received, so that we have the already applied transactions on ...
Definition: certifier.cc:1230
#define DBUG_ASSERT(A)
Definition: my_dbug.h:197
int broadcast_gtid_executed()
Broadcast local GTID_EXECUTED to group.
Definition: certifier.cc:185
virtual ~Gtid_Executed_Message()
Definition: certifier.cc:1569
Definition: certifier.h:734
mysql_cond_t broadcast_run_cond
Definition: certifier.h:157
void encode_payload(std::vector< unsigned char > *buffer) const
Encodes the contents of this instance payload into the buffer.
Definition: certifier.cc:1575
Gtid_set * group_gtid_executed
Definition: certifier.h:629
ulonglong gtids_assigned_in_blocks_counter
Definition: certifier.h:652
ulonglong get_positive_certified()
Get the number of postively certified transactions by the certifier.
Definition: certifier.cc:1497
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
int64_t int64
Definition: my_inttypes.h:67
Definition: my_thread_bits.h:51
Gtid_Executed_Message()
Gtid_Executed_Message constructor
Definition: certifier.cc:1566
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:39
virtual void get_certification_info(std::map< std::string, std::string > *cert_info)
Retrieves the current certification info.
Definition: certifier.cc:1329
bool is_initialized()
Definition: certifier.h:534
mysql_mutex_t LOCK_members
Definition: certifier.h:667
Gtid_set * get_certified_write_set_snapshot_version(const char *item)
Find the snapshot_version corresponding to an item.
Definition: certifier.cc:1029
long long int longlong
Definition: my_inttypes.h:54
Gtid_set * group_gtid_extracted
A Gtid_set which contains the gtid extracted from the certification info map of the donor...
Definition: certifier.h:636
bool set_group_stable_transactions_set(Gtid_set *executed_gtid_set)
This member function shall add transactions to the stable set.
Definition: certifier.cc:1064
Definition: certifier.h:174
int terminate()
Terminate certifier.
Definition: certifier.cc:573
bool conflict_detection_enable
Conflict detection is performed when: 1) group is on multi-master mode; 2) group is on single-primary...
Definition: certifier.h:665
enum_payload_item_type
Definition: certifier.h:736
Checkable_rwlock * stable_gtid_set_lock
Stable set and garbage collector variables.
Definition: certifier.h:569
THD * broadcast_thd
Definition: certifier.h:154
virtual void disable_conflict_detection()=0
virtual void handle_view_change()=0
Definition: plugin_utils.h:42
Represents a set of GTIDs.
Definition: rpl_gtid.h:1302
static const int BROADCAST_GTID_EXECUTED_PERIOD
Period (in seconds) between stable transactions set broadcast.
Definition: certifier.h:147
Certifier_broadcast_thread * broadcast_thread
Broadcast thread.
Definition: certifier.h:672
int initialize()
Initialize broadcast thread.
Definition: certifier.cc:70
Definition: certifier.h:193
rpl_gno get_group_next_available_gtid(const char *member_uuid)
This method is used to get the next valid GNO for the transaction that is being executed.
Definition: certifier.cc:891
Certifier_broadcast_thread()
Certifier_broadcast_thread constructor.
Definition: certifier.cc:46
size_t link()
Increment the number of references by one.
Definition: certifier.h:67
virtual ~Certifier_interface()
Definition: certifier.h:176
void disable_conflict_detection()
Disables conflict detection.
Definition: certifier.cc:1540
int64 parallel_applier_last_committed_global
Definition: certifier.h:556
virtual bool set_group_stable_transactions_set(Gtid_set *executed_gtid_set)=0
my_thread_handle broadcast_pthd
Definition: certifier.h:155
void compute_group_available_gtid_intervals()
This function computes the available GTID intervals from group UUID and stores them on group_availabl...
Definition: certifier.cc:404
Gtid_set * stable_gtid_set
Definition: certifier.h:571
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Gtid last_conflict_free_transaction
Last conflict free transaction identification.
Definition: certifier.h:546
std::vector< uchar > data
Definition: certifier.h:769
Gtid_set::Interval reserve_gtid_block(longlong block_size)
This function reserves a block of GTIDs from the group_available_gtid_intervals list.
Definition: certifier.cc:459
rpl_sidno group_gtid_sid_map_group_sidno
Variable to store the sidno used for transactions which will be logged with the group_uuid.
Definition: certifier.h:435
Certification_info certification_info
Certification database.
Definition: certifier.h:551
virtual ~Certifier_broadcast_thread()
Definition: certifier.cc:63
Represents one element in the linked list of intervals associated with a SIDNO.
Definition: rpl_gtid.h:1740
static void start(PluginFuncEnv *env)
Definition: http_server_plugin.cc:572
int get_group_stable_transactions_set_string(char **buffer, size_t *length)
Returns the transactions in stable set in text format, that is, the set of transactions already appli...
Definition: certifier.cc:1047
Definition: plugin_utils.h:176
int64 get_parallel_applier_sequence_number() const
Definition: certifier.h:79
void update_certified_transaction_count(bool result, bool local_transaction)
Definition: certifier.cc:1465
rpl_gno get_group_next_available_gtid_candidate(rpl_gno start, rpl_gno end) const
Generate the candidate GNO for the current transaction.
Definition: certifier.cc:957
const string value("\alue\)
bool certifier_garbage_collection_block
Definition: certifier.h:560
Definition: certifier.h:738
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:429
Definition: certifier_stats_interface.h:28
Definition: certifier.h:741
int initialize_server_gtid_set(bool get_server_gtid_retrieved=false)
Method to initialize the group_gtid_executed gtid set with the server gtid executed set and applier r...
Definition: certifier.cc:307
int initialize(ulonglong gtid_assignment_block_size)
Initialize certifier.
Definition: certifier.cc:540
long long int rpl_gno
Type of GNO, the second (numeric) component of GTID.
Definition: rpl_gtid.h:99
unsigned long ulong
Definition: my_inttypes.h:48
bool initialized
Is certifier initialized.
Definition: certifier.h:429
ulonglong negative_cert
Definition: certifier.h:555
virtual int handle_certifier_data(const uchar *data, ulong len, const Gcs_member_identifier &gcs_member_id)=0
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
uint64_t uint64
Definition: my_inttypes.h:68
int terminate()
Terminate broadcast thread.
Definition: certifier.cc:98
int64 parallel_applier_sequence_number
Definition: certifier.h:85
std::unordered_map< std::string, Gtid_set_ref * > Certification_info
This class is a core component of the database state machine replication protocol.
Definition: certifier.h:110
void garbage_collect()
Removes the intersection of the received transactions stable sets from certification database...
Definition: certifier.cc:1089
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778
Gtid_set_ref(Sid_map *sid_map, int64 parallel_applier_sequence_number)
Definition: certifier.h:55