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