MySQL 8.0.39
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 |
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... | |
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 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... | |
int | set_certification_info (std::map< std::string, std::string > *cert_info) override |
Sets the certification info according to the given value. 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... | |
Gtid | generate_view_change_group_gtid () |
Generate group GTID for a view change log event. More... | |
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 gtid functionality. More... | |
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 skip gtid functionality. More... | |
int | stable_set_handle () override |
Computes intersection between all sets received, so that we have the already applied transactions on all servers. More... | |
bool | set_group_stable_transactions_set (Gtid_set *executed_gtid_set) override |
This member function shall add transactions to the stable set. 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... | |
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 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 | compute_group_available_gtid_intervals () |
This function computes the available GTID intervals from group UUID and stores them on group_available_gtid_intervals. More... | |
Gtid_set::Interval | reserve_gtid_block (longlong block_size) |
This function reserves a block of GTIDs from the group_available_gtid_intervals list. 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... | |
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 executed. More... | |
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. More... | |
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. More... | |
bool | is_initialized () |
void | clear_certification_info () |
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 | garbage_collect () |
Removes the intersection of the received transactions stable sets from certification database. More... | |
void | clear_incoming () |
Clear incoming queue. More... | |
void | update_certified_transaction_count (bool result, bool local_transaction) |
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 |
Certifier::Certifier | ( | ) |
|
override |
int Certifier::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 gtid functionality.
[in] | gno | The gno of the transaction which will be added to the group_gtid executed GTID set. The sidno used for this transaction will be the group_sidno. The gno here belongs specifically to the group UUID. |
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. |
int Certifier::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 skip gtid functionality.
[in] | gle | The gtid value that needs to the added in the group_gtid_executed GTID set. |
1 | error during addition. |
0 | success. |
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. |
rpl_gno Certifier::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 certification test.
snapshot_version | The incoming transaction snapshot version. |
write_set | The incoming transaction write set. |
generate_group_id | Flag that indicates if transaction group id must be generated. |
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 |
|
private |
Clear incoming queue.
|
private |
Method to clear the members.
|
private |
This function computes the available GTID intervals from group UUID and stores them on group_available_gtid_intervals.
|
overridevirtual |
Disables conflict detection.
Implements Certifier_interface.
|
overridevirtual |
Enables conflict detection.
Implements Certifier_interface.
|
private |
Removes the intersection of the received transactions stable sets from certification database.
Gtid Certifier::generate_view_change_group_gtid | ( | ) |
Generate group GTID for a view change log event.
>0 | view change GTID |
otherwise | Error on GTID generation |
|
overridevirtual |
Retrieves the current certification info.
[out] | cert_info | a pointer to retrieve the certification info |
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 |
This method is used to get the next valid GNO for the transaction that is being executed.
It checks the already used up GNOs and based on that chooses the next possible value. This method will consult group_available_gtid_intervals to assign GTIDs in blocks according to gtid_assignment_block_size.
member_uuid | The UUID of the member from which this transaction originates. It will be NULL on View_change_log_event. |
>0 | The GNO to be used. |
-1 | Error: GNOs exhausted for group UUID. |
|
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.
This method is used to get the next valid GNO for the given sidno, for the transaction that is being executed.
It checks the already used up GNOs and based on that chooses the next possible value. This method will consult group_available_gtid_intervals to assign GTIDs in blocks according to gtid_assignment_block_size when sidno
is the group sidno.
member_uuid | The UUID of the member from which this transaction originates. It will be NULL on View_change_log_event. |
sidno | The sidno that will be used on GTID |
>0 | The GNO to be used. |
-1 | Error: GNOs exhausted for group UUID. |
|
private |
Generate the candidate GNO for the current transaction.
The candidate will be on the interval [start, end] or a error be returned. This method will consult group_gtid_executed to avoid generate the same value twice.
sidno | The sidno that will be used to retrieve GNO |
start | The first possible value for the GNO |
end | The last possible value for the GNO |
>0 | The GNO to be used. |
-1 | Error: GNOs exhausted for group UUID. |
-2 | Error: generated GNO is bigger than end. |
|
overridevirtual |
Get the number of postively certified transactions by the certifier.
Implements Certifier_stats.
|
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 |
Check if conflict detection is enable.
True | conflict detection is enable |
False | otherwise |
Implements Certifier_interface.
|
inlineprivate |
|
private |
This function reserves a block of GTIDs from the group_available_gtid_intervals list.
Gtid_set::Interval | which is the interval os GTIDs attributed |
|
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.
|
overridevirtual |
This member function shall add transactions to the stable set.
executed_gtid_set | The GTID set of the transactions to be added to the stable set. |
False | if adds successfully, |
True | otherwise. |
Implements Certifier_interface.
|
overridevirtual |
Computes intersection between all sets received, so that we have the already applied transactions on all servers.
0 | OK |
!=0 | 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 |
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 |
List of free GTID intervals in group.
|
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.
|
private |
The group GTID assignment block size.
|
staticprivate |
Key used to store group_gtid_executed on certification info on View_change_log_event.
|
private |
|
private |
|
private |
Is certifier initialized.
|
private |
Last conflict free transaction identification.
|
private |
|
private |
|
private |
Extends the above to allow GTIDs to be assigned in blocks per member.
|
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.