MySQL 8.3.0
Source Code Documentation
certifier.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 CERTIFIER_INCLUDE
24#define CERTIFIER_INCLUDE
25
26#include <assert.h>
28#include <list>
29#include <map>
30#include <string>
31#include <unordered_map>
32#include <vector>
33
34#include "my_inttypes.h"
48
49#include "plugin/group_replication/generated/protobuf_lite/replication_group_recovery_metadata.pb.h"
50
52
53/**
54 While sending Recovery Metadata the Certification Information is divided into
55 several small packets of MAX_COMPRESSED_PACKET_SIZE before sending it to
56 group for Recovery.
57 The compressed packet size is choosen as 10MB so that multiple threads can
58 process (serialize and compress or unserialize and decompress) packets
59 simultaneously without consuming too much memory.
60*/
61#define MAX_COMPRESSED_PACKET_SIZE 10485760
62
63/**
64 This class extends Gtid_set to include a reference counter.
65
66 It is for Certifier only, so it is single-threaded and no locks
67 are needed since Certifier already ensures sequential use.
68
69 It is to be used to share by multiple entries in the
70 certification info and released when the last reference to it
71 needs to be freed.
72*/
73class Gtid_set_ref : public Gtid_set {
74 public:
79
80 virtual ~Gtid_set_ref() = default;
81
82 /**
83 Increment the number of references by one.
84
85 @return the number of references
86 */
87 size_t link() { return ++reference_counter; }
88
89 /**
90 Decrement the number of references by one.
91
92 @return the number of references
93 */
94 size_t unlink() {
95 assert(reference_counter > 0);
96 return --reference_counter;
97 }
98
101 }
102
103 private:
106};
107
108/**
109 This class is a core component of the database state machine
110 replication protocol. It implements conflict detection based
111 on a certification procedure.
112
113 Snapshot Isolation is based on assigning logical timestamp to optimistic
114 transactions, i.e. the ones which successfully meet certification and
115 are good to commit on all members in the group. This timestamp is a
116 monotonically increasing counter, and is same across all members in the group.
117
118 This timestamp, which in our algorithm is the snapshot version, is further
119 used to update the certification info.
120 The snapshot version maps the items in a transaction to the GTID_EXECUTED
121 that this transaction saw when it was executed, that is, on which version
122 the transaction was executed.
123
124 If the incoming transaction snapshot version is a subset of a
125 previous certified transaction for the same write set, the current
126 transaction was executed on top of outdated data, so it will be
127 negatively certified. Otherwise, this transaction is marked
128 certified and goes into applier.
129*/
131 public:
132 /**
133 Certifier_broadcast_thread constructor
134 */
137
138 /**
139 Initialize broadcast thread.
140
141 @return the operation status
142 @retval 0 OK
143 @retval !=0 Error
144 */
145 int initialize();
146
147 /**
148 Terminate broadcast thread.
149
150 @return the operation status
151 @retval 0 OK
152 @retval !=0 Error
153 */
154 int terminate();
155
156 /**
157 Broadcast thread worker method.
158 */
159 void dispatcher();
160
161 /**
162 Period (in seconds) between stable transactions set
163 broadcast.
164 */
165 static const int BROADCAST_GTID_EXECUTED_PERIOD = 60; // seconds
166
167 private:
168 /**
169 Thread control.
170 */
181
182 /**
183 Broadcast local GTID_EXECUTED to group.
184
185 @return the operation status
186 @retval 0 OK
187 @retval !=0 Error
188 */
190};
191
193 public:
194 ~Certifier_interface() override = default;
195 virtual void handle_view_change() = 0;
197 const uchar *data, ulong len,
198 const Gcs_member_identifier &gcs_member_id) = 0;
199
201 std::map<std::string, std::string> *cert_info) = 0;
203 Recovery_metadata_message *recovery_metadata_message) = 0;
205 std::map<std::string, std::string> *cert_info) = 0;
207 Recovery_metadata_message *recovery_metadata_message) = 0;
209 virtual int stable_set_handle() = 0;
211 Gtid_set *executed_gtid_set) = 0;
212 virtual void enable_conflict_detection() = 0;
213 virtual void disable_conflict_detection() = 0;
216};
217
219 public:
220 typedef std::unordered_map<
221 std::string, Gtid_set_ref *, std::hash<std::string>,
222 std::equal_to<std::string>,
225
226 typedef protobuf_replication_group_recovery_metadata::
227 CertificationInformationMap ProtoCertificationInformationMap;
228
229 Certifier();
230 ~Certifier() override;
231
232 /**
233 Key used to store errors in the certification info
234 on View_change_log_event.
235 */
236 static const std::string CERTIFICATION_INFO_ERROR_NAME;
237
238 /**
239 Initialize certifier.
240
241 @param gtid_assignment_block_size the group gtid assignment block size
242
243 @return the operation status
244 @retval 0 OK
245 @retval !=0 Error
246 */
247 int initialize(ulonglong gtid_assignment_block_size);
248
249 /**
250 Terminate certifier.
251
252 @return the operation status
253 @retval 0 OK
254 @retval !=0 Error
255 */
256 int terminate();
257
258 /**
259 Handle view changes on certifier.
260 */
261 void handle_view_change() override;
262
263 /**
264 Queues the packet coming from the reader for future processing.
265
266 @param[in] data the packet data
267 @param[in] len the packet length
268 @param[in] gcs_member_id the member_id which sent the message
269
270 @return the operation status
271 @retval 0 OK
272 @retval !=0 Error on queue
273 */
275 const uchar *data, ulong len,
276 const Gcs_member_identifier &gcs_member_id) override;
277
278 /**
279 This member function SHALL certify the set of items against transactions
280 that have already passed the certification test.
281
282 @param snapshot_version The incoming transaction snapshot version.
283 @param write_set The incoming transaction write set.
284 @param is_gtid_specified True in case GTID is specified for this trx
285 @param member_uuid The UUID of the member from which this
286 transaction originates.
287 @param gle The incoming transaction global identifier
288 event.
289 @param local_transaction True if this transaction did originate from
290 this member, false otherwise.
291
292 @retval >0 transaction identifier (positively certified).
293 If generate_group_id is false and certification
294 positive a 1 is returned;
295 @retval 0 negatively certified;
296 @retval -1 error.
297 */
298 gr::Certified_gtid certify(Gtid_set *snapshot_version,
299 std::list<const char *> *write_set,
300 bool is_gtid_specified, const char *member_uuid,
301 Gtid_log_event *gle, bool local_transaction);
302
303 /**
304 Returns the transactions in stable set in text format, that is, the set of
305 transactions already applied on all group members.
306
307 @param[out] buffer Pointer to pointer to string. The method will set it to
308 point to the newly allocated buffer, or NULL on out of
309 memory.
310 Caller must free the allocated memory.
311 @param[out] length Length of the generated string.
312
313 @return the operation status
314 @retval 0 OK
315 @retval !=0 Out of memory error
316 */
318 size_t *length) override;
319
320 /**
321 Retrieves the current certification info.
322
323 @note if concurrent access is introduce to these variables,
324 locking is needed in this method
325
326 @param[out] cert_info a pointer to retrieve the certification info
327 */
329 std::map<std::string, std::string> *cert_info) override;
330
331 /**
332 Retrieves the current certification info.
333
334 @note if concurrent access is introduce to these variables,
335 locking is needed in this method
336
337 @param[out] recovery_metadata_message Retrieves the metadata message
338
339 @return the operation status
340 @retval false OK
341 @retval true Error
342 */
344 Recovery_metadata_message *recovery_metadata_message) override;
345
346 /**
347 Sets the certification info according to the given value.
348
349 @note if concurrent access is introduce to these variables,
350 locking is needed in this method
351
352 @param[in] cert_info certification info retrieved from recovery procedure
353
354 @retval > 0 Error during setting certification info.
355 @retval = 0 Everything went fine.
356 */
358 std::map<std::string, std::string> *cert_info) override;
359
360 /**
361 The received certification info from Recovery Metadata is decoded,
362 compressed and added to the member certification info for certification.
363
364 @note if concurrent access is introduce to these variables,
365 locking is needed in this method
366
367 @param[in] recovery_metadata_message the pointer to
368 Recovery_metadata_message.
369
370 @return the operation status
371 @retval false OK
372 @retval true Error
373 */
375 Recovery_metadata_message *recovery_metadata_message) override;
376 /**
377 Initializes the gtid_executed set.
378
379 @return the operation status
380 @retval false OK
381 @retval true Error
382 */
384
385 /**
386 Get the number of postively certified transactions by the certifier
387 */
389
390 /**
391 Get method to retrieve the number of negatively certified transactions.
392 */
394
395 /**
396 Get method to retrieve the certification db size.
397 */
399
400 /**
401 Get method to retrieve the last conflict free transaction.
402
403 @param[out] value The last conflict free transaction
404 */
405 void get_last_conflict_free_transaction(std::string *value) override;
406
407 /**
408 Generate group GTID for a view change log event.
409 @return Generated gtid and Gtid generation result
410 @see Return_status
411 */
412 std::pair<Gtid, mysql::utils::Return_status>
414
415 /**
416 Public method to add the given GTID value in the group_gtid_executed set
417 which is used to support skip gtid functionality.
418
419 @param[in] gtid GTID to be added
420
421 @retval 1 error during addition.
422 @retval 0 success.
423 */
424 int add_gtid_to_group_gtid_executed(const Gtid &gtid);
425
426 /**
427 Computes intersection between all sets received, so that we
428 have the already applied transactions on all servers.
429
430 @return the operation status
431 @retval 0 OK
432 @retval !=0 Error
433 */
434 int stable_set_handle() override;
435
436 /**
437 This member function shall add transactions to the stable set
438
439 @param executed_gtid_set The GTID set of the transactions to be added
440 to the stable set.
441
442 @note when set, the stable set will cause the garbage collection
443 process to be invoked
444
445 @retval False if adds successfully,
446 @retval True otherwise.
447 */
448 bool set_group_stable_transactions_set(Gtid_set *executed_gtid_set) override;
449
450 /**
451 Enables conflict detection.
452 */
453 void enable_conflict_detection() override;
454
455 /**
456 Disables conflict detection.
457 */
458 void disable_conflict_detection() override;
459
460 /**
461 Check if conflict detection is enable.
462
463 @retval True conflict detection is enable
464 @retval False otherwise
465 */
466 bool is_conflict_detection_enable() override;
467
468 /**
469 Compute GTID intervals.
470 */
472
473 private:
474 /**
475 Key used to store group_gtid_executed on certification
476 info on View_change_log_event.
477 */
478 static const std::string GTID_EXTRACTED_NAME;
479
480 /**
481 Is certifier initialized.
482 */
484
485 /**
486 Variable to store the sidno used for transactions which will be logged
487 with the group_uuid.
488 */
490
491 /**
492 The sidno used for view log events as seen by the group sid map
493 */
495 /**
496 The sidno used for view log events as seen by the server sid map
497 */
499
500 /**
501 Method to initialize the group_gtid_executed gtid set with the server gtid
502 executed set and applier retrieved gtid set values.
503
504 @param get_server_gtid_retrieved add applier retrieved gtid set to
505 group_gtid_executed gtid set
506
507 @retval 1 error during initialization
508 @retval 0 success
509
510 */
511 int initialize_server_gtid_set(bool get_server_gtid_retrieved = false);
512
513 /**
514 This function updates parallel applier indexes.
515 It must be called for each remote transaction.
516
517 @param[in] update_parallel_applier_last_committed_global
518 If true parallel_applier_last_committed_global
519 is updated to the current sequence number
520 (before update sequence number).
521
522 Note: parallel_applier_last_committed_global should be updated
523 on the following situations:
524 1) Transaction without write set is certified, since it
525 represents the lowest last_committed for all future
526 transactions;
527 2) After certification info garbage collection, since we
528 do not know what write sets were purged, which may cause
529 transactions last committed to be incorrectly computed.
530 */
532 bool update_parallel_applier_last_committed_global);
533
534 /**
535 Internal method to add the given gtid gno in the group_gtid_executed set.
536 This will be used in the skip gtid implementation.
537
538 @note this will update the last know local transaction GTID.
539
540 @param[in] sidno rpl_sidno part of the executing gtid of the ongoing
541 transaction.
542
543 @param[in] gno rpl_gno part of the executing gtid of the ongoing
544 transaction.
545 */
547
548 /// @brief Returns group_executed_gtid_set or group_extracted_gtid_set while
549 /// certifying already applied transactions from the donor
550 /// @returns Pointer to the 'correct' group_gtid_set
551 const Gtid_set *get_group_gtid_set() const;
552
553 /// @brief Returns group_executed_gtid_set or group_extracted_gtid_set while
554 /// certifying already applied transactions from the donor
555 /// @returns Pointer to the 'correct' group_gtid_set
557
558 /// @brief This function determines three sidnos for a specific TSID
559 /// based on information obtained from the Gtid_log_event.
560 /// @param gle Gtid_log_event from which tsid will be extracted
561 /// @param is_gtid_specified True in case GTID is specified
562 /// @param snapshot_gtid_set Snapshot GTIDs
563 /// @param group_gtid_set Current GTID set
564 /// @return A tuple of:
565 /// - group_sidno Sidno relative to the group sid map
566 /// - gtid_snapshot_sidno Sidno relative to the snapshot sid map
567 /// - gtid_global_sidno Sidno relative to the global sid map
568 /// - return status
569 /// @details
570 /// We need to ensure that group sidno does exist on snapshot
571 /// version due to the following scenario:
572 /// 1) Member joins the group.
573 /// 2) Goes through recovery procedure, view change is queued to
574 /// apply, member is marked ONLINE. This requires
575 /// --group_replication_recovery_complete_at=TRANSACTIONS_CERTIFIED
576 /// to happen.
577 /// 3) Despite the view change log event is still being applied,
578 /// since the member is already ONLINE it can execute
579 /// transactions. The first transaction from this member will
580 /// not include any group GTID, since no group transaction is
581 /// yet applied.
582 /// 4) As a result of this sequence snapshot_version will not
583 /// contain any group GTID and the below instruction
584 /// snapshot_version->_add_gtid(group_sidno, result);
585 /// would fail because of that
586 std::tuple<rpl_sidno, rpl_sidno, rpl_sidno, mysql::utils::Return_status>
587 extract_sidno(Gtid_log_event &gle, bool is_gtid_specified,
588 Gtid_set &snapshot_gtid_set, Gtid_set &group_gtid_set);
589
590 /// @brief Internal helper method for ending certification, determination
591 /// of final GTID values after certification according to certification result
592 /// @param[in] gtid_server_sidno SIDNO for transaction GTID as represented in
593 /// the server (global sid map)
594 /// @param[in] gtid_group_sidno SIDNO for transaction GTID as represented in
595 /// the group
596 /// @param[in] generated_gno GNO generated for the transaction
597 /// @param[in] is_gtid_specified True if GTID was specified
598 /// @param[in] local_transaction True in case this transaction originates
599 /// from the this server
600 /// @param[in] certification_result Determined certification result
602 const rpl_sidno &gtid_server_sidno, const rpl_sidno &gtid_group_sidno,
603 const rpl_gno &generated_gno, bool is_gtid_specified,
604 bool local_transaction,
605 const gr::Certification_result &certification_result);
606
607 /// @brief Adds the transaction's write set to certification info.
608 /// @param[out] transaction_last_committed The transaction's logical
609 /// timestamps used for MTS
610 /// @param[in,out] snapshot_version The incoming transaction snapshot
611 /// version.
612 /// @param[in, out] write_set The incoming transaction write set.
613 /// @param[in] local_transaction True in case this transaction originates
614 /// from the this server
616 int64 &transaction_last_committed, Gtid_set *snapshot_version,
617 std::list<const char *> *write_set, bool local_transaction);
618
619 /// @brief Updates parallel applier indexes in GLE
620 /// @param gle Gle currently processed
621 /// @param has_write_set True in case transaction write set is not empty
622 /// @param transaction_last_committed The transaction's logical timestamps
623 /// used for MTS
625 Gtid_log_event &gle, bool has_write_set,
626 int64 transaction_last_committed);
627
628 bool inline is_initialized() { return initialized; }
629
630 /**
631 This shall serialize the certification info stored in protobuf map format,
632 and then compress provided serialized string. The compressed payload is
633 stored into multiple buffer containers of the output list.
634
635 @param[in] cert_info the certification info stored in protobuf map.
636 @param[out] uncompresssed_buffer the buffer for uncompressed data.
637 @param[out] compressor_list the certification info in compressed form
638 splitted into multiple container of list.
639 @param[in] compression_type the type of compression used
640
641 @return the operation status
642 @retval false OK
643 @retval true Error
644 */
646 unsigned char **uncompresssed_buffer,
647 std::vector<GR_compress *> &compressor_list,
648 GR_compress::enum_compression_type compression_type);
649
650 /**
651 Sets the certification info according to the given value.
652 This shall uncompress and then convert uncompressed string into the protobuf
653 map format storing certification info. This certification info is added to
654 certifier's certification info.
655
656 @note if concurrent access is introduce to these variables,
657 locking is needed in this method
658
659 @param[in] compression_type the compression type
660 @param[in] buffer the compressed certification info retrieved from
661 recovery procedure.
662 @param[in] buffer_length the size of the compressed retrieved
663 certification info.
664 @param[in] uncompressed_buffer_length the size of the uncompressed
665 certification info before it was
666 compressed.
667
668 @return the operation status
669 @retval false OK
670 @retval true Error
671 */
673 GR_compress::enum_compression_type compression_type,
674 const unsigned char *buffer, unsigned long long buffer_length,
675 unsigned long long uncompressed_buffer_length);
676
677 /**
678 Empties certification info.
679 */
681
682 /**
683 Method to clear the members.
684 */
685 void clear_members();
686
687 /**
688 Last conflict free transaction identification.
689 */
691
692 /**
693 Certification database.
694 */
697
702
703#if !defined(NDEBUG)
706#endif
707
709
710 /**
711 Stable set and garbage collector variables.
712 */
717
718 std::vector<std::string> members;
719
720 /*
721 Flag to indicate that certifier is handling already applied
722 transactions during distributed recovery procedure.
723
724 On donor we may have local transactions certified after
725 View_change_log_event (VCLE) logged into binary log before VCLE.
726 That is, these local transactions will be appear on recovery
727 and also on GCS messages. One can see on example scenario below:
728
729 GCS order | donor binary log order | joiner apply order
730 -----------+------------------------+--------------------
731 T1 | T1 | T1
732 T2 | T2 | T2
733 V1 | T3 | T3 (recovery)
734 T3 | V1 | V1
735 | | T3 (GCS)
736 -----------+------------------------+--------------------
737
738 T3 is delivered to donor by both recovery and GCS, so joiner needs
739 to ensure that T3 has the same global identifier on both cases, so
740 that it is correctly skipped on the second time it is applied.
741
742 We ensure that T3 (and other transactions on that situation) have
743 the same global identifiers on joiner by:
744 1) When the VCLE is applied, we set on joiner certification info
745 the same exact certification that was on donor, including the
746 set of certified transactions before the joiner joined:
747 group_gtid_extracted.
748 2) We compare group_gtid_extracted and group_gtid_executed:
749 If group_gtid_extracted is a non equal subset of
750 group_gtid_executed, it means that we are on the above
751 scenario, that is, when applying the last transaction from
752 the distributed recovery process we have more transactions
753 than the ones certified before the view on which joiner joined.
754 So until group_gtid_extracted is a non equal subset of
755 group_gtid_executed certifier will generate transactions ids
756 following group_gtid_extracted so that we have the same exact
757 ids that donor has.
758 3) When joiner group_gtid_extracted and group_gtid_executed are
759 equal, joiner switches to its regular ids generation mode,
760 generating ids from group_gtid_executed.
761 */
763
764 /*
765 Sid map to store the GTIDs that are executed in the group.
766 */
768
769 /*
770 A Gtid_set containing the already executed for the group.
771 This is used to support skip_gtid.
772 */
774
775 /**
776 A Gtid_set which contains the gtid extracted from the certification info
777 map of the donor. It is the set of transactions that is executed at the
778 time of View_change_log_event at donor.
779 */
781
782 /// Object responsible for generation of the GTIDs for transactions with
783 /// gtid_next equal to AUTOMATIC (tagged/untagged)
785
786 /**
787 Conflict detection is performed when:
788 1) group is on multi-master mode;
789 2) group is on single-primary mode and primary is applying
790 relay logs with transactions from a previous primary.
791 */
793
795
796 /**
797 Broadcast thread.
798 */
800
801 /**
802 Adds an item from transaction writeset to the certification DB.
803 @param[in] item item in the writeset to be added to the
804 Certification DB.
805 @param[in] snapshot_version Snapshot version of the incoming transaction
806 which modified the above mentioned item.
807 @param[out] item_previous_sequence_number
808 The previous parallel applier sequence number
809 for this item.
810
811 @retval False successfully added to the map.
812 True otherwise.
813 */
814 bool add_item(const char *item, Gtid_set_ref *snapshot_version,
815 int64 *item_previous_sequence_number);
816
817 /**
818 Find the snapshot_version corresponding to an item. Return if
819 it exists, other wise return NULL;
820
821 @param[in] item item for the snapshot version.
822 @retval Gtid_set pointer if exists in the map.
823 Otherwise 0;
824 */
826
827 /**
828 Removes the intersection of the received transactions stable
829 sets from certification database.
830 */
831 void garbage_collect();
832
833 /**
834 Clear incoming queue.
835 */
836 void clear_incoming();
837
838 /*
839 Update method to store the count of the positively and negatively
840 certified transaction on a particular group member.
841 */
842 void update_certified_transaction_count(bool result, bool local_transaction);
843
844 /*
845 The first remote transaction certified does need to reset
846 replication_group_applier channel previous transaction
847 sequence_number.
848 */
850};
851
852/*
853 @class Gtid_Executed_Message
854
855 Class to convey the serialized contents of the previously executed GTIDs
856 */
858 public:
860 // This type should not be used anywhere.
862
863 // Length of the payload item: variable
865
866 // Length of the payload item: 8 bytes
868
869 // No valid type codes can appear after this one.
870 PIT_MAX = 3
871 };
872
873 /**
874 Gtid_Executed_Message constructor
875 */
878
879 /**
880 Appends Gtid executed information in a raw format
881
882 * @param[in] gtid_data encoded GTID data
883 * @param[in] len GTID data length
884 */
885 void append_gtid_executed(uchar *gtid_data, size_t len);
886
887 /**
888 Return the time at which the message contained in the buffer was sent.
889 @see Metrics_handler::get_current_time()
890
891 @param[in] buffer the buffer to decode from.
892 @param[in] length the buffer length
893
894 @return the time on which the message was sent.
895 */
896 static uint64_t get_sent_timestamp(const unsigned char *buffer,
897 size_t length);
898
899 protected:
900 /*
901 Implementation of the template methods of Gcs_plugin_message
902 */
903 void encode_payload(std::vector<unsigned char> *buffer) const override;
904 void decode_payload(const unsigned char *buffer,
905 const unsigned char *) override;
906
907 private:
908 std::vector<uchar> data;
909};
910
911#endif /* CERTIFIER_INCLUDE */
This class is a core component of the database state machine replication protocol.
Definition: certifier.h:130
mysql_cond_t broadcast_dispatcher_cond
Definition: certifier.h:177
mysql_mutex_t broadcast_dispatcher_lock
Definition: certifier.h:176
Certifier_broadcast_thread()
Certifier_broadcast_thread constructor.
Definition: certifier.cc:53
THD * broadcast_thd
Definition: certifier.h:172
int initialize()
Initialize broadcast thread.
Definition: certifier.cc:77
int terminate()
Terminate broadcast thread.
Definition: certifier.cc:105
mysql_mutex_t broadcast_run_lock
Definition: certifier.h:174
static const int BROADCAST_GTID_EXECUTED_PERIOD
Period (in seconds) between stable transactions set broadcast.
Definition: certifier.h:165
int broadcast_gtid_executed()
Broadcast local GTID_EXECUTED to group.
Definition: certifier.cc:206
size_t broadcast_counter
Definition: certifier.h:179
int broadcast_gtid_executed_period
Definition: certifier.h:180
bool aborted
Thread control.
Definition: certifier.h:171
void dispatcher()
Broadcast thread worker method.
Definition: certifier.cc:133
my_thread_handle broadcast_pthd
Definition: certifier.h:173
virtual ~Certifier_broadcast_thread()
Definition: certifier.cc:70
thread_state broadcast_thd_state
Definition: certifier.h:178
mysql_cond_t broadcast_run_cond
Definition: certifier.h:175
Definition: certifier.h:192
virtual bool set_group_stable_transactions_set(Gtid_set *executed_gtid_set)=0
virtual void handle_view_change()=0
virtual ulonglong get_certification_info_size() override=0
virtual bool is_conflict_detection_enable()=0
~Certifier_interface() override=default
virtual void get_certification_info(std::map< std::string, std::string > *cert_info)=0
virtual int handle_certifier_data(const uchar *data, ulong len, const Gcs_member_identifier &gcs_member_id)=0
virtual int set_certification_info(std::map< std::string, std::string > *cert_info)=0
virtual void disable_conflict_detection()=0
virtual void enable_conflict_detection()=0
virtual bool set_certification_info_recovery_metadata(Recovery_metadata_message *recovery_metadata_message)=0
virtual bool get_certification_info_recovery_metadata(Recovery_metadata_message *recovery_metadata_message)=0
virtual int stable_set_handle()=0
virtual bool initialize_server_gtid_set_after_distributed_recovery()=0
Definition: certifier_stats_interface.h:28
Definition: certifier.h:218
gr::Certified_gtid certify(Gtid_set *snapshot_version, std::list< const char * > *write_set, bool is_gtid_specified, 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:804
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:478
int get_group_stable_transactions_set_string(char **buffer, size_t *length) override
Returns the transactions in stable set in text format, that is, the set of transactions already appli...
Definition: certifier.cc:1019
const Gtid_set * get_group_gtid_set() const
Returns group_executed_gtid_set or group_extracted_gtid_set while certifying already applied transact...
Definition: certifier.cc:946
Tsid_map * certification_info_tsid_map
Definition: certifier.h:696
Certification_info certification_info
Certification database.
Definition: certifier.h:695
int set_certification_info(std::map< std::string, std::string > *cert_info) override
Sets the certification info according to the given value.
Definition: certifier.cc:1764
bool set_certification_info_part(GR_compress::enum_compression_type compression_type, const unsigned char *buffer, unsigned long long buffer_length, unsigned long long uncompressed_buffer_length)
Sets the certification info according to the given value.
Definition: certifier.cc:1517
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:792
bool is_conflict_detection_enable() override
Check if conflict detection is enable.
Definition: certifier.cc:1912
bool set_certification_info_recovery_metadata(Recovery_metadata_message *recovery_metadata_message) override
The received certification info from Recovery Metadata is decoded, compressed and added to the member...
Definition: certifier.cc:1392
bool initialize_server_gtid_set_after_distributed_recovery() override
Initializes the gtid_executed set.
Definition: certifier.cc:1595
int handle_certifier_data(const uchar *data, ulong len, const Gcs_member_identifier &gcs_member_id) override
Queues the packet coming from the reader for future processing.
Definition: certifier.cc:1143
int64 parallel_applier_sequence_number
Definition: certifier.h:701
void clear_certification_info()
Empties certification info.
Definition: certifier.cc:485
rpl_sidno group_gtid_tsid_map_group_sidno
Variable to store the sidno used for transactions which will be logged with the group_uuid.
Definition: certifier.h:489
Tsid_map * group_gtid_tsid_map
Definition: certifier.h:767
Gtid_set * stable_gtid_set
Definition: certifier.h:715
int initialize(ulonglong gtid_assignment_block_size)
Initialize certifier.
Definition: certifier.cc:511
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:965
void clear_members()
Method to clear the members.
Definition: certifier.cc:505
Gtid_set * group_gtid_extracted
A Gtid_set which contains the gtid extracted from the certification info map of the donor.
Definition: certifier.h:780
void increment_parallel_applier_sequence_number(bool update_parallel_applier_last_committed_global)
This function updates parallel applier indexes.
Definition: certifier.cc:549
void disable_conflict_detection() override
Disables conflict detection.
Definition: certifier.cc:1901
Synchronized_queue< Data_packet * > * incoming
Definition: certifier.h:716
std::pair< Gtid, mysql::utils::Return_status > generate_view_change_group_gtid()
Generate group GTID for a view change log event.
Definition: certifier.cc:1743
std::unordered_map< std::string, Gtid_set_ref *, std::hash< std::string >, std::equal_to< std::string >, Malloc_allocator< std::pair< const std::string, Gtid_set_ref * > > > Certification_info
Definition: certifier.h:224
void update_certified_transaction_count(bool result, bool local_transaction)
Definition: certifier.cc:1836
void clear_incoming()
Clear incoming queue.
Definition: certifier.cc:495
Certifier()
Definition: certifier.cc:256
gr::Certification_result add_writeset_to_certification_info(int64 &transaction_last_committed, Gtid_set *snapshot_version, std::list< const char * > *write_set, bool local_transaction)
Adds the transaction's write set to certification info.
Definition: certifier.cc:659
bool is_first_remote_transaction_certified
Definition: certifier.h:849
std::vector< std::string > members
Definition: certifier.h:718
~Certifier() override
Definition: certifier.cc:307
rpl_sidno views_sidno_group_representation
The sidno used for view log events as seen by the group sid map.
Definition: certifier.h:494
void get_last_conflict_free_transaction(std::string *value) override
Get method to retrieve the last conflict free transaction.
Definition: certifier.cc:1881
rpl_sidno views_sidno_server_representation
The sidno used for view log events as seen by the server sid map.
Definition: certifier.h:498
bool get_certification_info_recovery_metadata(Recovery_metadata_message *recovery_metadata_message) override
Retrieves the current certification info.
Definition: certifier.cc:1654
ulonglong get_certification_info_size() override
Get method to retrieve the certification db size.
Definition: certifier.cc:1877
void get_certification_info(std::map< std::string, std::string > *cert_info) override
Retrieves the current certification info.
Definition: certifier.cc:1363
bool certifying_already_applied_transactions
Definition: certifier.h:762
Checkable_rwlock * stable_gtid_set_lock
Stable set and garbage collector variables.
Definition: certifier.h:713
bool same_member_message_discarded
Definition: certifier.h:705
ulonglong positive_cert
Definition: certifier.h:698
ulonglong get_negative_certified() override
Get method to retrieve the number of negatively certified transactions.
Definition: certifier.cc:1875
bool compress_packet(ProtoCertificationInformationMap &cert_info, unsigned char **uncompresssed_buffer, std::vector< GR_compress * > &compressor_list, GR_compress::enum_compression_type compression_type)
This shall serialize the certification info stored in protobuf map format, and then compress provided...
Definition: certifier.cc:1609
ulonglong negative_cert
Definition: certifier.h:699
bool set_group_stable_transactions_set(Gtid_set *executed_gtid_set) override
This member function shall add transactions to the stable set.
Definition: certifier.cc:1046
protobuf_replication_group_recovery_metadata::CertificationInformationMap ProtoCertificationInformationMap
Definition: certifier.h:227
mysql_mutex_t LOCK_certification_info
Definition: certifier.h:708
ulonglong get_positive_certified() override
Get the number of postively certified transactions by the certifier.
Definition: certifier.cc:1873
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:329
gr::Gtid_generator gtid_generator
Object responsible for generation of the GTIDs for transactions with gtid_next equal to AUTOMATIC (ta...
Definition: certifier.h:784
int add_gtid_to_group_gtid_executed(const Gtid &gtid)
Public method to add the given GTID value in the group_gtid_executed set which is used to support ski...
Definition: certifier.cc:939
void add_to_group_gtid_executed_internal(rpl_sidno sidno, rpl_gno gno)
Internal method to add the given gtid gno in the group_gtid_executed set.
Definition: certifier.cc:465
void gtid_intervals_computation()
Compute GTID intervals.
Definition: certifier.cc:956
int64 parallel_applier_last_committed_global
Definition: certifier.h:700
void update_transaction_dependency_timestamps(Gtid_log_event &gle, bool has_write_set, int64 transaction_last_committed)
Updates parallel applier indexes in GLE.
Definition: certifier.cc:737
gr::Certified_gtid end_certification_result(const rpl_sidno &gtid_server_sidno, const rpl_sidno &gtid_group_sidno, const rpl_gno &generated_gno, bool is_gtid_specified, bool local_transaction, const gr::Certification_result &certification_result)
Internal helper method for ending certification, determination of final GTID values after certificati...
Definition: certifier.cc:636
void handle_view_change() override
Handle view changes on certifier.
Definition: certifier.cc:1355
Gtid_set * get_certified_write_set_snapshot_version(const char *item)
Find the snapshot_version corresponding to an item.
Definition: certifier.cc:1001
bool is_initialized()
Definition: certifier.h:628
void enable_conflict_detection() override
Enables conflict detection.
Definition: certifier.cc:1893
bool certifier_garbage_collection_block
Definition: certifier.h:704
Gtid_set * group_gtid_executed
Definition: certifier.h:773
std::tuple< rpl_sidno, rpl_sidno, rpl_sidno, mysql::utils::Return_status > extract_sidno(Gtid_log_event &gle, bool is_gtid_specified, Gtid_set &snapshot_gtid_set, Gtid_set &group_gtid_set)
This function determines three sidnos for a specific TSID based on information obtained from the Gtid...
Definition: certifier.cc:589
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:236
Gtid last_conflict_free_transaction
Last conflict free transaction identification.
Definition: certifier.h:690
Tsid_map * stable_tsid_map
Definition: certifier.h:714
int stable_set_handle() override
Computes intersection between all sets received, so that we have the already applied transactions on ...
Definition: certifier.cc:1220
mysql_mutex_t LOCK_members
Definition: certifier.h:794
int terminate()
Terminate certifier.
Definition: certifier.cc:540
void garbage_collect()
Removes the intersection of the received transactions stable sets from certification database.
Definition: certifier.cc:1071
bool initialized
Is certifier initialized.
Definition: certifier.h:483
Certifier_broadcast_thread * broadcast_thread
Broadcast thread.
Definition: certifier.h:799
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:323
enum_compression_type
Compression Type.
Definition: gr_compression.h:45
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:39
Definition: certifier.h:857
enum_payload_item_type
Definition: certifier.h:859
@ PIT_SENT_TIMESTAMP
Definition: certifier.h:867
@ PIT_MAX
Definition: certifier.h:870
@ PIT_GTID_EXECUTED
Definition: certifier.h:864
@ PIT_UNKNOWN
Definition: certifier.h:861
Gtid_Executed_Message()
Gtid_Executed_Message constructor.
Definition: certifier.cc:1923
std::vector< uchar > data
Definition: certifier.h:908
static uint64_t get_sent_timestamp(const unsigned char *buffer, size_t length)
Return the time at which the message contained in the buffer was sent.
Definition: certifier.cc:1956
~Gtid_Executed_Message() override
void append_gtid_executed(uchar *gtid_data, size_t len)
Appends Gtid executed information in a raw format.
Definition: certifier.cc:1928
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the contents of this instance payload into the buffer.
Definition: certifier.cc:1932
void decode_payload(const unsigned char *buffer, const unsigned char *) override
Decodes the contents of the buffer and sets the payload field values according to the values decoded.
Definition: certifier.cc:1943
This is a subclass if Gtid_event and Log_event.
Definition: log_event.h:3951
This class extends Gtid_set to include a reference counter.
Definition: certifier.h:73
int64 parallel_applier_sequence_number
Definition: certifier.h:105
virtual ~Gtid_set_ref()=default
size_t link()
Increment the number of references by one.
Definition: certifier.h:87
Gtid_set_ref(Tsid_map *tsid_map, int64 parallel_applier_sequence_number)
Definition: certifier.h:75
size_t unlink()
Decrement the number of references by one.
Definition: certifier.h:94
int64 get_parallel_applier_sequence_number() const
Definition: certifier.h:99
size_t reference_counter
Definition: certifier.h:104
Represents a set of GTIDs.
Definition: rpl_gtid.h:1555
Tsid_map * tsid_map
Tsid_map associated with this Gtid_set.
Definition: rpl_gtid.h:2461
Malloc_allocator is a C++ STL memory allocator based on my_malloc/my_free.
Definition: malloc_allocator.h:62
This is the base GCS plugin message.
Definition: gcs_plugin_messages.h:63
Definition: recovery_metadata_message.h:35
Definition: plugin_utils.h:181
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
Represents a bidirectional map between TSID and SIDNO.
Definition: rpl_gtid.h:748
Class that aggregates important information about already certified gtid.
Definition: certified_gtid.h:45
This class is responsible for generating GTIDs in the Certifier.
Definition: gtid_generator.h:46
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
unsigned char uchar
Definition: my_inttypes.h:51
int64_t int64
Definition: my_inttypes.h:67
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
Certification_result
Represents result of certification function.
Definition: certification_result.h:29
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:417
std::unordered_map< Key, Value, Hash, Key_equal, ut::allocator< std::pair< const Key, Value > > > unordered_map
Definition: ut0new.h:2897
Experimental API header.
mysql::gtid::gno_t rpl_gno
GNO, the second (numeric) component of a GTID, is an alias of mysql::gtid::gno_t.
Definition: rpl_gtid.h:111
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:107
TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1099
Definition: my_thread_bits.h:57
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49
Definition: result.h:29
Definition: plugin_utils.h:47