MySQL 9.1.0
Source Code Documentation
|
#include <certifier.h>
Public Types | |
typedef 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 |
typedef protobuf_replication_group_recovery_metadata::CertificationInformationMap | ProtoCertificationInformationMap |
Public Member Functions | |
Certifier () | |
~Certifier () override | |
int | initialize (ulonglong gtid_assignment_block_size) |
Initialize certifier. More... | |
int | terminate () |
Terminate certifier. More... | |
void | handle_view_change () override |
Handle view changes on certifier. More... | |
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. More... | |
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 certification test. More... | |
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 applied on all group members. More... | |
void | get_certification_info (std::map< std::string, std::string > *cert_info) override |
Retrieves the current certification info. More... | |
bool | get_certification_info_recovery_metadata (Recovery_metadata_message *recovery_metadata_message) override |
Retrieves the current certification info. More... | |
int | set_certification_info (std::map< std::string, std::string > *cert_info) override |
Sets the certification info according to the given value. More... | |
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 certification info for certification. More... | |
bool | initialize_server_gtid_set_after_distributed_recovery () override |
Initializes the gtid_executed set. More... | |
ulonglong | get_positive_certified () override |
Get the number of postively certified transactions by the certifier. More... | |
ulonglong | get_negative_certified () override |
Get method to retrieve the number of negatively certified transactions. More... | |
ulonglong | get_certification_info_size () override |
Get method to retrieve the certification db size. More... | |
void | get_last_conflict_free_transaction (std::string *value) override |
Get method to retrieve the last conflict free transaction. More... | |
std::pair< Gtid, mysql::utils::Return_status > | generate_view_change_group_gtid () |
Generate group GTID for a view change log event. More... | |
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 skip gtid functionality. More... | |
void | enable_conflict_detection () override |
Enables conflict detection. More... | |
void | disable_conflict_detection () override |
Disables conflict detection. More... | |
bool | is_conflict_detection_enable () override |
Check if conflict detection is enable. More... | |
void | gtid_intervals_computation () |
Compute GTID intervals. More... | |
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 sets. More... | |
Public Member Functions inherited from Certifier_interface | |
~Certifier_interface () override=default | |
Public Member Functions inherited from Certifier_stats | |
virtual | ~Certifier_stats ()=default |
Static Public Attributes | |
static const std::string | CERTIFICATION_INFO_ERROR_NAME |
Key used to store errors in the certification info on View_change_log_event. More... | |
Private Types | |
enum | enum_update_status { STABLE_SET_UPDATED , STABLE_SET_ALREADY_CONTAINED , STABLE_SET_ERROR } |
Private Member Functions | |
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 retrieved gtid set values. More... | |
void | update_parallel_applier_indexes (bool update_parallel_applier_last_committed_global, bool increment_parallel_applier_sequence_number) |
This function updates parallel applier indexes. More... | |
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. More... | |
const Gtid_set * | get_group_gtid_set () const |
Returns group_executed_gtid_set or group_extracted_gtid_set while certifying already applied transactions from the donor. More... | |
Gtid_set * | get_group_gtid_set () |
Returns group_executed_gtid_set or group_extracted_gtid_set while certifying already applied transactions from the donor. More... | |
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_log_event. More... | |
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 certification according to certification result. More... | |
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. More... | |
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. More... | |
bool | is_initialized () |
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 serialized string. More... | |
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. More... | |
void | clear_certification_info () |
Empties certification info. More... | |
void | clear_members () |
Method to clear the members. More... | |
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. More... | |
Gtid_set * | get_certified_write_set_snapshot_version (const char *item) |
Find the snapshot_version corresponding to an item. More... | |
void | clear_incoming () |
Clear incoming queue. More... | |
void | update_certified_transaction_count (bool result, bool local_transaction) |
void | garbage_collect_internal (Gtid_set *intersection_gtid_set, bool preemptive=false) |
Removes the intersection of the received transactions stable sets from certification database. More... | |
bool | intersect_members_gtid_executed_and_garbage_collect () |
Computes intersection between all sets received, so that we have the already applied transactions on all servers. More... | |
enum enum_update_status | update_stable_set (const Gtid_set &set) |
Update stable set with set if not already contained. More... | |
Static Private Attributes | |
static const std::string | GTID_EXTRACTED_NAME = "gtid_extracted" |
Key used to store group_gtid_executed on certification info on View_change_log_event. More... | |
typedef 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 *> > > Certifier::Certification_info |
typedef protobuf_replication_group_recovery_metadata::CertificationInformationMap Certifier::ProtoCertificationInformationMap |
|
private |
Certifier::Certifier | ( | ) |
|
override |
int Certifier::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 skip gtid functionality.
[in] | gtid | GTID to be added |
1 | error during addition. |
0 | success. |
|
private |
Adds an item from transaction writeset to the certification DB.
[in] | item | item in the writeset to be added to the Certification DB. |
[in] | snapshot_version | Snapshot version of the incoming transaction which modified the above mentioned item. |
[out] | item_previous_sequence_number | The previous parallel applier sequence number for this item. |
False | successfully added to the map. True otherwise. |
Internal method to add the given gtid gno in the group_gtid_executed set.
This will be used in the skip gtid implementation.
[in] | sidno | rpl_sidno part of the executing gtid of the ongoing transaction. |
[in] | gno | rpl_gno part of the executing gtid of the ongoing transaction. |
|
private |
Adds the transaction's write set to certification info.
[out] | transaction_last_committed | The transaction's logical timestamps used for MTS |
[in,out] | snapshot_version | The incoming transaction snapshot version. |
[in,out] | write_set | The incoming transaction write set. |
[in] | local_transaction | True in case this transaction originates from the this server |
Certified_gtid Certifier::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 certification test.
snapshot_version | The incoming transaction snapshot version. |
write_set | The incoming transaction write set. |
is_gtid_specified | True in case GTID is specified for this trx |
member_uuid | The UUID of the member from which this transaction originates. |
gle | The incoming transaction global identifier event. |
local_transaction | True if this transaction did originate from this member, false otherwise. |
>0 | transaction identifier (positively certified). If generate_group_id is false and certification positive a 1 is returned; |
0 | negatively certified; |
-1 | error. |
|
private |
Empties certification info.
|
private |
Clear incoming queue.
|
private |
Method to clear the members.
|
private |
This shall serialize the certification info stored in protobuf map format, and then compress provided serialized string.
The compressed payload is stored into multiple buffer containers of the output list.
[in] | cert_info | the certification info stored in protobuf map. |
[out] | uncompresssed_buffer | the buffer for uncompressed data. |
[out] | compressor_list | the certification info in compressed form splitted into multiple container of list. |
[in] | compression_type | the type of compression used |
false | OK |
true | Error |
|
overridevirtual |
Disables conflict detection.
Implements Certifier_interface.
|
overridevirtual |
Enables conflict detection.
Implements Certifier_interface.
|
private |
Internal helper method for ending certification, determination of final GTID values after certification according to certification result.
[in] | gtid_server_sidno | SIDNO for transaction GTID as represented in the server (global sid map) |
[in] | gtid_group_sidno | SIDNO for transaction GTID as represented in the group |
[in] | generated_gno | GNO generated for the transaction |
[in] | is_gtid_specified | True if GTID was specified |
[in] | local_transaction | True in case this transaction originates from the this server |
[in] | certification_result | Determined certification result |
|
private |
This function determines three sidnos for a specific TSID based on information obtained from the Gtid_log_event.
gle | Gtid_log_event from which tsid will be extracted |
is_gtid_specified | True in case GTID is specified |
snapshot_gtid_set | Snapshot GTIDs |
group_gtid_set | Current GTID set |
We need to ensure that group sidno does exist on snapshot version due to the following scenario: 1) Member joins the group. 2) Goes through recovery procedure, view change is queued to apply, member is marked ONLINE. This requires –group_replication_recovery_complete_at=TRANSACTIONS_CERTIFIED to happen. 3) Despite the view change log event is still being applied, since the member is already ONLINE it can execute transactions. The first transaction from this member will not include any group GTID, since no group transaction is yet applied. 4) As a result of this sequence snapshot_version will not contain any group GTID and the below instruction snapshot_version->_add_gtid(group_sidno, result); would fail because of that
|
overridevirtual |
Validates if garbage collect should run against the intersection of the received transactions stable sets.
executed_gtid_set | intersection gtid set |
on_member_join | call due to member joining |
Implements Certifier_interface.
|
private |
Removes the intersection of the received transactions stable sets from certification database.
intersection_gtid_set | intersection gtid set |
preemptive | is a preemptive run |
std::pair< Gtid, mysql::utils::Return_status > Certifier::generate_view_change_group_gtid | ( | ) |
Generate group GTID for a view change log event.
|
overridevirtual |
Retrieves the current certification info.
[out] | cert_info | a pointer to retrieve the certification info |
Implements Certifier_interface.
|
overridevirtual |
Retrieves the current certification info.
[out] | recovery_metadata_message | Retrieves the metadata message |
false | OK |
true | Error |
Implements Certifier_interface.
|
overridevirtual |
Get method to retrieve the certification db size.
Implements Certifier_interface.
|
private |
Find the snapshot_version corresponding to an item.
Return if it exists, other wise return NULL;
[in] | item | item for the snapshot version. |
Gtid_set | pointer if exists in the map. Otherwise 0; |
|
private |
Returns group_executed_gtid_set or group_extracted_gtid_set while certifying already applied transactions from the donor.
|
private |
Returns group_executed_gtid_set or group_extracted_gtid_set while certifying already applied transactions from the donor.
|
overridevirtual |
Returns the transactions in stable set in text format, that is, the set of transactions already applied on all group members.
[out] | buffer | Pointer to pointer to string. The method will set it to point to the newly allocated buffer, or NULL on out of memory. Caller must free the allocated memory. |
[out] | length | Length of the generated string. |
0 | OK |
!=0 | Out of memory error |
Implements Certifier_stats.
|
overridevirtual |
Get method to retrieve the last conflict free transaction.
[out] | value | The last conflict free transaction |
Implements Certifier_stats.
|
overridevirtual |
Get method to retrieve the number of negatively certified transactions.
Implements Certifier_stats.
|
overridevirtual |
Get the number of postively certified transactions by the certifier.
Implements Certifier_stats.
void Certifier::gtid_intervals_computation | ( | ) |
Compute GTID intervals.
|
overridevirtual |
Queues the packet coming from the reader for future processing.
[in] | data | the packet data |
[in] | len | the packet length |
[in] | gcs_member_id | the member_id which sent the message |
0 | OK |
!=0 | Error on queue |
Implements Certifier_interface.
|
overridevirtual |
Handle view changes on certifier.
Implements Certifier_interface.
int Certifier::initialize | ( | ulonglong | gtid_assignment_block_size | ) |
Initialize certifier.
gtid_assignment_block_size | the group gtid assignment block size |
0 | OK |
!=0 | Error |
|
private |
Method to initialize the group_gtid_executed gtid set with the server gtid executed set and applier retrieved gtid set values.
get_server_gtid_retrieved | add applier retrieved gtid set to group_gtid_executed gtid set |
1 | error during initialization |
0 | success |
|
overridevirtual |
Initializes the gtid_executed set.
false | OK |
true | Error |
Implements Certifier_interface.
|
private |
Computes intersection between all sets received, so that we have the already applied transactions on all servers.
false | it did not run garbage_collect |
true | it did run garbage_collect |
|
overridevirtual |
Check if conflict detection is enable.
True | conflict detection is enable |
False | otherwise |
Implements Certifier_interface.
|
inlineprivate |
|
overridevirtual |
Sets the certification info according to the given value.
[in] | cert_info | certification info retrieved from recovery procedure |
> | 0 Error during setting certification info. |
= | 0 Everything went fine. |
Implements Certifier_interface.
|
private |
Sets the certification info according to the given value.
This shall uncompress and then convert uncompressed string into the protobuf map format storing certification info. This certification info is added to certifier's certification info.
[in] | compression_type | the compression type |
[in] | buffer | the compressed certification info retrieved from recovery procedure. |
[in] | buffer_length | the size of the compressed retrieved certification info. |
[in] | uncompressed_buffer_length | the size of the uncompressed certification info before it was compressed. |
false | OK |
true | Error |
|
overridevirtual |
The received certification info from Recovery Metadata is decoded, compressed and added to the member certification info for certification.
[in] | recovery_metadata_message | the pointer to Recovery_metadata_message. |
false | OK |
true | Error |
Implements Certifier_interface.
int Certifier::terminate | ( | ) |
Terminate certifier.
0 | OK |
!=0 | Error |
|
private |
|
private |
This function updates parallel applier indexes.
It must be called for each remote transaction.
[in] | update_parallel_applier_last_committed_global | If true parallel_applier_last_committed_global is updated to the current sequence number (before update sequence number). |
[in] | increment_parallel_applier_sequence_number | If false (during certification garbage collection) parallel_applier_last_committed_global is set to parallel_applier_last_sequence_number and parallel_applier_last_sequence_number is not updated |
Note: parallel_applier_last_committed_global should be updated on the following situations: 1) Transaction without write set is certified, since it represents the lowest last_committed for all future transactions; 2) After certification info garbage collection, since we do not know what write sets were purged, which may cause transactions last committed to be incorrectly computed.
|
private |
Update stable set with set if not already contained.
set | Gtid to add to stable set |
|
private |
Updates parallel applier indexes in GLE.
gle | Gle currently processed |
has_write_set | True in case transaction write set is not empty |
has_write_set_large_size | True in case number of write sets in transactions is greater than group_replication_preemptive_garbage_collection_rows_threshold |
transaction_last_committed | The transaction's logical timestamps used for MTS |
|
private |
Broadcast thread.
|
private |
Certification database.
|
static |
Key used to store errors in the certification info on View_change_log_event.
|
private |
|
private |
|
private |
|
private |
Conflict detection is performed when: 1) group is on multi-master mode; 2) group is on single-primary mode and primary is applying relay logs with transactions from a previous primary.
|
private |
|
private |
A Gtid_set which contains the gtid extracted from the certification info map of the donor.
It is the set of transactions that is executed at the time of View_change_log_event at donor.
|
private |
|
private |
Variable to store the sidno used for transactions which will be logged with the group_uuid.
|
staticprivate |
Key used to store group_gtid_executed on certification info on View_change_log_event.
|
private |
Object responsible for generation of the GTIDs for transactions with gtid_next equal to AUTOMATIC (tagged/untagged)
|
private |
|
private |
Is certifier initialized.
|
private |
|
private |
Last conflict free transaction identification.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Stable set and garbage collector variables.
|
private |
|
private |
The sidno used for view log events as seen by the group sid map.
|
private |
The sidno used for view log events as seen by the server sid map.