24#ifndef CERTIFIER_INCLUDE
25#define CERTIFIER_INCLUDE
33#include <unordered_map>
51#include "plugin/group_replication/generated/protobuf_lite/replication_group_recovery_metadata.pb.h"
63#define MAX_COMPRESSED_PACKET_SIZE 10485760
199 const uchar *data, ulong len,
203 std::map<std::string, std::string> *cert_info) = 0;
207 std::map<std::string, std::string> *cert_info) = 0;
212 bool on_member_join =
false) = 0;
223 std::equal_to<std::string>,
227 typedef protobuf_replication_group_recovery_metadata::
276 const uchar *data, ulong len,
300 std::list<const char *> *write_set,
301 bool is_gtid_specified,
const char *member_uuid,
330 std::map<std::string, std::string> *cert_info)
override;
359 std::map<std::string, std::string> *cert_info)
override;
413 std::pair<Gtid, mysql::utils::Return_status>
458 bool on_member_join =
false)
override;
524 bool update_parallel_applier_last_committed_global,
525 bool increment_parallel_applier_sequence_number);
579 std::tuple<rpl_sidno, rpl_sidno, rpl_sidno, mysql::utils::Return_status>
596 const rpl_gno &generated_gno,
bool is_gtid_specified,
597 bool local_transaction,
609 int64 &transaction_last_committed,
Gtid_set *snapshot_version,
610 std::list<const char *> *write_set,
bool local_transaction);
621 Gtid_log_event &gle,
bool has_write_set,
bool has_write_set_large_size,
622 int64 transaction_last_committed);
642 unsigned char **uncompresssed_buffer,
643 std::vector<GR_compress *> &compressor_list,
670 const unsigned char *
buffer,
unsigned long long buffer_length,
671 unsigned long long uncompressed_buffer_length);
812 int64 *item_previous_sequence_number);
850 bool preemptive =
false);
934 const unsigned char *)
override;
This class is a core component of the database state machine replication protocol.
Definition: certifier.h:132
mysql_cond_t broadcast_dispatcher_cond
Definition: certifier.h:179
mysql_mutex_t broadcast_dispatcher_lock
Definition: certifier.h:178
Certifier_broadcast_thread()
Certifier_broadcast_thread constructor.
Definition: certifier.cc:54
THD * broadcast_thd
Definition: certifier.h:174
int initialize()
Initialize broadcast thread.
Definition: certifier.cc:80
int terminate()
Terminate broadcast thread.
Definition: certifier.cc:110
mysql_mutex_t broadcast_run_lock
Definition: certifier.h:176
static const int BROADCAST_GTID_EXECUTED_PERIOD
Period (in seconds) between stable transactions set broadcast.
Definition: certifier.h:167
int broadcast_gtid_executed()
Broadcast local GTID_EXECUTED to group.
Definition: certifier.cc:214
size_t broadcast_counter
Definition: certifier.h:181
int broadcast_gtid_executed_period
Definition: certifier.h:182
bool aborted
Thread control.
Definition: certifier.h:173
void dispatcher()
Broadcast thread worker method.
Definition: certifier.cc:141
my_thread_handle broadcast_pthd
Definition: certifier.h:175
virtual ~Certifier_broadcast_thread()
Definition: certifier.cc:73
thread_state broadcast_thd_state
Definition: certifier.h:180
mysql_cond_t broadcast_run_cond
Definition: certifier.h:177
Definition: certifier.h:194
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 garbage_collect(Gtid_set *executed_gtid_set=nullptr, bool on_member_join=false)=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 bool initialize_server_gtid_set_after_distributed_recovery()=0
Definition: certifier_stats_interface.h:29
Definition: certifier.h:219
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:856
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:465
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:1107
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:1021
Tsid_map * certification_info_tsid_map
Definition: certifier.h:692
Certification_info certification_info
Certification database.
Definition: certifier.h:691
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:1988
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:1719
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:789
bool is_conflict_detection_enable() override
Check if conflict detection is enable.
Definition: certifier.cc:2163
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:1590
bool initialize_server_gtid_set_after_distributed_recovery() override
Initializes the gtid_executed set.
Definition: certifier.cc:1806
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:1346
int64 parallel_applier_sequence_number
Definition: certifier.h:698
void clear_certification_info()
Empties certification info.
Definition: certifier.cc:497
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:476
Tsid_map * group_gtid_tsid_map
Definition: certifier.h:764
Gtid_set * stable_gtid_set
Definition: certifier.h:712
int initialize(ulonglong gtid_assignment_block_size)
Initialize certifier.
Definition: certifier.cc:532
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:1045
void clear_members()
Method to clear the members.
Definition: certifier.cc:526
Gtid_set * group_gtid_extracted
A Gtid_set which contains the gtid extracted from the certification info map of the donor.
Definition: certifier.h:777
std::atomic< bool > initialized
Is certifier initialized.
Definition: certifier.h:470
void disable_conflict_detection() override
Disables conflict detection.
Definition: certifier.cc:2147
Synchronized_queue< Data_packet * > * incoming
Definition: certifier.h:713
std::pair< Gtid, mysql::utils::Return_status > generate_view_change_group_gtid()
Generate group GTID for a view change log event.
Definition: certifier.cc:1962
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:225
void update_certified_transaction_count(bool result, bool local_transaction)
Definition: certifier.cc:2074
void clear_incoming()
Clear incoming queue.
Definition: certifier.cc:516
Certifier()
Definition: certifier.cc:264
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:698
enum_update_status
Definition: certifier.h:862
@ STABLE_SET_UPDATED
Definition: certifier.h:864
@ STABLE_SET_ALREADY_CONTAINED
Definition: certifier.h:866
@ STABLE_SET_ERROR
Definition: certifier.h:868
bool is_first_remote_transaction_certified
Definition: certifier.h:840
int64 parallel_applier_last_sequence_number
Definition: certifier.h:697
std::vector< std::string > members
Definition: certifier.h:715
~Certifier() override
Definition: certifier.cc:316
rpl_sidno views_sidno_group_representation
The sidno used for view log events as seen by the group sid map.
Definition: certifier.h:481
void get_last_conflict_free_transaction(std::string *value) override
Get method to retrieve the last conflict free transaction.
Definition: certifier.cc:2119
rpl_sidno views_sidno_server_representation
The sidno used for view log events as seen by the server sid map.
Definition: certifier.h:485
bool get_certification_info_recovery_metadata(Recovery_metadata_message *recovery_metadata_message) override
Retrieves the current certification info.
Definition: certifier.cc:1869
ulonglong get_certification_info_size() override
Get method to retrieve the certification db size.
Definition: certifier.cc:2115
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:570
void get_certification_info(std::map< std::string, std::string > *cert_info) override
Retrieves the current certification info.
Definition: certifier.cc:1556
bool certifying_already_applied_transactions
Definition: certifier.h:759
Checkable_rwlock * stable_gtid_set_lock
Stable set and garbage collector variables.
Definition: certifier.h:710
bool same_member_message_discarded
Definition: certifier.h:702
ulonglong positive_cert
Definition: certifier.h:694
ulonglong get_negative_certified() override
Get method to retrieve the number of negatively certified transactions.
Definition: certifier.cc:2113
enum enum_update_status update_stable_set(const Gtid_set &set)
Update stable set with set if not already contained.
Definition: certifier.cc:1329
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:1824
ulonglong negative_cert
Definition: certifier.h:695
protobuf_replication_group_recovery_metadata::CertificationInformationMap ProtoCertificationInformationMap
Definition: certifier.h:228
void garbage_collect_internal(Gtid_set *intersection_gtid_set, bool preemptive=false)
Removes the intersection of the received transactions stable sets from certification database.
Definition: certifier.cc:1185
bool intersect_members_gtid_executed_and_garbage_collect()
Computes intersection between all sets received, so that we have the already applied transactions on ...
Definition: certifier.cc:1423
mysql_mutex_t LOCK_certification_info
Definition: certifier.h:705
ulonglong get_positive_certified() override
Get the number of postively certified transactions by the certifier.
Definition: certifier.cc:2111
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:341
gr::Gtid_generator gtid_generator
Object responsible for generation of the GTIDs for transactions with gtid_next equal to AUTOMATIC (ta...
Definition: certifier.h:781
int add_gtid_to_group_gtid_executed(const Gtid >id)
Public method to add the given GTID value in the group_gtid_executed set which is used to support ski...
Definition: certifier.cc:1009
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:477
void gtid_intervals_computation()
Compute GTID intervals.
Definition: certifier.cc:1031
int64 parallel_applier_last_committed_global
Definition: certifier.h:696
void garbage_collect(Gtid_set *executed_gtid_set=nullptr, bool on_member_join=false) override
Validates if garbage collect should run against the intersection of the received transactions stable ...
Definition: certifier.cc:1138
void update_transaction_dependency_timestamps(Gtid_log_event &gle, bool has_write_set, bool has_write_set_large_size, int64 transaction_last_committed)
Updates parallel applier indexes in GLE.
Definition: certifier.cc:785
gr::Certified_gtid end_certification_result(const rpl_sidno >id_server_sidno, const rpl_sidno >id_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:675
void handle_view_change() override
Handle view changes on certifier.
Definition: certifier.cc:1543
Gtid_set * get_certified_write_set_snapshot_version(const char *item)
Find the snapshot_version corresponding to an item.
Definition: certifier.cc:1089
bool is_initialized()
Definition: certifier.h:624
void enable_conflict_detection() override
Enables conflict detection.
Definition: certifier.cc:2135
bool certifier_garbage_collection_block
Definition: certifier.h:701
Gtid_set * group_gtid_executed
Definition: certifier.h:770
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:628
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:237
Gtid last_conflict_free_transaction
Last conflict free transaction identification.
Definition: certifier.h:686
Tsid_map * stable_tsid_map
Definition: certifier.h:711
mysql_mutex_t LOCK_members
Definition: certifier.h:791
int terminate()
Terminate certifier.
Definition: certifier.cc:561
Certifier_broadcast_thread * broadcast_thread
Broadcast thread.
Definition: certifier.h:796
This has the functionality of mysql_rwlock_t, with two differences:
Definition: rpl_gtid.h:325
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:40
Definition: certifier.h:886
enum_payload_item_type
Definition: certifier.h:888
@ PIT_SENT_TIMESTAMP
Definition: certifier.h:896
@ PIT_MAX
Definition: certifier.h:899
@ PIT_GTID_EXECUTED
Definition: certifier.h:893
@ PIT_UNKNOWN
Definition: certifier.h:890
Gtid_Executed_Message()
Gtid_Executed_Message constructor.
Definition: certifier.cc:2179
std::vector< uchar > data
Definition: certifier.h:937
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:2212
~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:2184
void encode_payload(std::vector< unsigned char > *buffer) const override
Encodes the contents of this instance payload into the buffer.
Definition: certifier.cc:2188
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:2199
This is a subclass if Gtid_event and Log_event.
Definition: log_event.h:3972
This class extends Gtid_set to include a reference counter.
Definition: certifier.h:75
int64 parallel_applier_sequence_number
Definition: certifier.h:107
virtual ~Gtid_set_ref()=default
size_t link()
Increment the number of references by one.
Definition: certifier.h:89
Gtid_set_ref(Tsid_map *tsid_map, int64 parallel_applier_sequence_number)
Definition: certifier.h:77
size_t unlink()
Decrement the number of references by one.
Definition: certifier.h:96
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:1557
Tsid_map * tsid_map
Tsid_map associated with this Gtid_set.
Definition: rpl_gtid.h:2489
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
Definition: plugin_utils.h:182
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Represents a bidirectional map between TSID and SIDNO.
Definition: rpl_gtid.h:750
Class that aggregates important information about already certified gtid.
Definition: certified_gtid.h:46
This class is responsible for generating GTIDs in the Certifier.
Definition: gtid_generator.h:47
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
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
Certification_result
Represents result of certification function.
Definition: certification_result.h:30
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
std::unordered_map< Key, Value, Hash, Key_equal, ut::allocator< std::pair< const Key, Value > > > unordered_map
Definition: ut0new.h:2900
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
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:113
cs::index::rpl_sidno rpl_sidno
Type of SIDNO (source ID number, first component of GTID)
Definition: rpl_gtid.h:109
TODO: Move this structure to mysql/binlog/event/control_events.h when we start using C++11.
Definition: rpl_gtid.h:1101
Definition: my_thread_bits.h:58
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
Definition: plugin_utils.h:48