MySQL 8.0.39
Source Code Documentation
Certifier Class Reference

#include <certifier.h>

Inheritance diagram for Certifier:
[legend]

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_setget_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)
 

Private Attributes

std::atomic< bool > initialized {false}
 Is certifier initialized. More...
 
rpl_sidno group_gtid_sid_map_group_sidno
 Variable to store the sidno used for transactions which will be logged with the group_uuid. More...
 
rpl_sidno views_sidno_group_representation
 The sidno used for view log events as seen by the group sid map. More...
 
rpl_sidno views_sidno_server_representation
 The sidno used for view log events as seen by the server sid map. More...
 
Gtid last_conflict_free_transaction
 Last conflict free transaction identification. More...
 
Certification_info certification_info
 Certification database. More...
 
Sid_mapcertification_info_sid_map
 
ulonglong positive_cert
 
ulonglong negative_cert
 
int64 parallel_applier_last_committed_global
 
int64 parallel_applier_last_sequence_number
 
int64 parallel_applier_sequence_number
 
bool certifier_garbage_collection_block
 
bool same_member_message_discarded
 
mysql_mutex_t LOCK_certification_info
 
Checkable_rwlockstable_gtid_set_lock
 Stable set and garbage collector variables. More...
 
Sid_mapstable_sid_map
 
Gtid_setstable_gtid_set
 
Synchronized_queue< Data_packet * > * incoming
 
std::vector< std::string > members
 
bool certifying_already_applied_transactions
 
Sid_mapgroup_gtid_sid_map
 
Gtid_setgroup_gtid_executed
 
Gtid_setgroup_gtid_extracted
 A Gtid_set which contains the gtid extracted from the certification info map of the donor. More...
 
uint64 gtid_assignment_block_size
 The group GTID assignment block size. More...
 
std::list< Gtid_set::Intervalgroup_available_gtid_intervals
 List of free GTID intervals in group. More...
 
std::map< std::string, Gtid_set::Intervalmember_gtids
 Extends the above to allow GTIDs to be assigned in blocks per member. More...
 
ulonglong gtids_assigned_in_blocks_counter
 
bool conflict_detection_enable
 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. More...
 
mysql_mutex_t LOCK_members
 
Certifier_broadcast_threadbroadcast_thread
 Broadcast thread. 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...
 

Member Typedef Documentation

◆ Certification_info

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

Constructor & Destructor Documentation

◆ Certifier()

Certifier::Certifier ( )

◆ ~Certifier()

Certifier::~Certifier ( )
override

Member Function Documentation

◆ add_group_gtid_to_group_gtid_executed()

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.

Parameters
[in]gnoThe 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.
Return values
1error during addition.
0success.

◆ add_item()

bool Certifier::add_item ( const char *  item,
Gtid_set_ref snapshot_version,
int64 item_previous_sequence_number 
)
private

Adds an item from transaction writeset to the certification DB.

Parameters
[in]itemitem in the writeset to be added to the Certification DB.
[in]snapshot_versionSnapshot version of the incoming transaction which modified the above mentioned item.
[out]item_previous_sequence_numberThe previous parallel applier sequence number for this item.
Return values
Falsesuccessfully added to the map. True otherwise.

◆ add_specified_gtid_to_group_gtid_executed()

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.

Parameters
[in]gleThe gtid value that needs to the added in the group_gtid_executed GTID set.
Return values
1error during addition.
0success.

◆ add_to_group_gtid_executed_internal()

void Certifier::add_to_group_gtid_executed_internal ( rpl_sidno  sidno,
rpl_gno  gno 
)
private

Internal method to add the given gtid gno in the group_gtid_executed set.

This will be used in the skip gtid implementation.

Note
this will update the last know local transaction GTID.
Parameters
[in]sidnorpl_sidno part of the executing gtid of the ongoing transaction.
[in]gnorpl_gno part of the executing gtid of the ongoing transaction.

◆ certify()

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.

Parameters
snapshot_versionThe incoming transaction snapshot version.
write_setThe incoming transaction write set.
generate_group_idFlag that indicates if transaction group id must be generated.
member_uuidThe UUID of the member from which this transaction originates.
gleThe incoming transaction global identifier event.
local_transactionTrue if this transaction did originate from this member, false otherwise.
Return values
>0transaction identifier (positively certified). If generate_group_id is false and certification positive a 1 is returned;
0negatively certified;
-1error.

◆ clear_certification_info()

void Certifier::clear_certification_info ( )
private

◆ clear_incoming()

void Certifier::clear_incoming ( )
private

Clear incoming queue.

◆ clear_members()

void Certifier::clear_members ( )
private

Method to clear the members.

◆ compute_group_available_gtid_intervals()

void Certifier::compute_group_available_gtid_intervals ( )
private

This function computes the available GTID intervals from group UUID and stores them on group_available_gtid_intervals.

◆ disable_conflict_detection()

void Certifier::disable_conflict_detection ( )
overridevirtual

Disables conflict detection.

Implements Certifier_interface.

◆ enable_conflict_detection()

void Certifier::enable_conflict_detection ( )
overridevirtual

Enables conflict detection.

Implements Certifier_interface.

◆ garbage_collect()

void Certifier::garbage_collect ( )
private

Removes the intersection of the received transactions stable sets from certification database.

◆ generate_view_change_group_gtid()

Gtid Certifier::generate_view_change_group_gtid ( )

Generate group GTID for a view change log event.

Return values
>0view change GTID
otherwiseError on GTID generation

◆ get_certification_info()

void Certifier::get_certification_info ( std::map< std::string, std::string > *  cert_info)
overridevirtual

Retrieves the current certification info.

Note
if concurrent access is introduce to these variables, locking is needed in this method
Parameters
[out]cert_infoa pointer to retrieve the certification info

Implements Certifier_interface.

◆ get_certification_info_size()

ulonglong Certifier::get_certification_info_size ( )
overridevirtual

Get method to retrieve the certification db size.

Implements Certifier_interface.

◆ get_certified_write_set_snapshot_version()

Gtid_set * Certifier::get_certified_write_set_snapshot_version ( const char *  item)
private

Find the snapshot_version corresponding to an item.

Return if it exists, other wise return NULL;

Parameters
[in]itemitem for the snapshot version.
Return values
Gtid_setpointer if exists in the map. Otherwise 0;

◆ get_group_next_available_gtid()

rpl_gno Certifier::get_group_next_available_gtid ( const char *  member_uuid)
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.

Parameters
member_uuidThe UUID of the member from which this transaction originates. It will be NULL on View_change_log_event.
Return values
>0The GNO to be used.
-1Error: GNOs exhausted for group UUID.

◆ get_group_stable_transactions_set_string()

int Certifier::get_group_stable_transactions_set_string ( char **  buffer,
size_t *  length 
)
overridevirtual

Returns the transactions in stable set in text format, that is, the set of transactions already applied on all group members.

Parameters
[out]bufferPointer 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]lengthLength of the generated string.
Returns
the operation status
Return values
0OK
!=0Out of memory error

Implements Certifier_stats.

◆ get_last_conflict_free_transaction()

void Certifier::get_last_conflict_free_transaction ( std::string *  value)
overridevirtual

Get method to retrieve the last conflict free transaction.

Parameters
[out]valueThe last conflict free transaction

Implements Certifier_stats.

◆ get_negative_certified()

ulonglong Certifier::get_negative_certified ( )
overridevirtual

Get method to retrieve the number of negatively certified transactions.

Implements Certifier_stats.

◆ get_next_available_gtid()

rpl_gno Certifier::get_next_available_gtid ( const char *  member_uuid,
rpl_sidno  sidno 
)
private

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.

Parameters
member_uuidThe UUID of the member from which this transaction originates. It will be NULL on View_change_log_event.
sidnoThe sidno that will be used on GTID
Return values
>0The GNO to be used.
-1Error: GNOs exhausted for group UUID.

◆ get_next_available_gtid_candidate()

rpl_gno Certifier::get_next_available_gtid_candidate ( rpl_sidno  sidno,
rpl_gno  start,
rpl_gno  end 
) const
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.

Parameters
sidnoThe sidno that will be used to retrieve GNO
startThe first possible value for the GNO
endThe last possible value for the GNO
Return values
>0The GNO to be used.
-1Error: GNOs exhausted for group UUID.
-2Error: generated GNO is bigger than end.

◆ get_positive_certified()

ulonglong Certifier::get_positive_certified ( )
overridevirtual

Get the number of postively certified transactions by the certifier.

Implements Certifier_stats.

◆ handle_certifier_data()

int Certifier::handle_certifier_data ( const uchar data,
ulong  len,
const Gcs_member_identifier gcs_member_id 
)
overridevirtual

Queues the packet coming from the reader for future processing.

Parameters
[in]datathe packet data
[in]lenthe packet length
[in]gcs_member_idthe member_id which sent the message
Returns
the operation status
Return values
0OK
!=0Error on queue

Implements Certifier_interface.

◆ handle_view_change()

void Certifier::handle_view_change ( )
overridevirtual

Handle view changes on certifier.

Implements Certifier_interface.

◆ initialize()

int Certifier::initialize ( ulonglong  gtid_assignment_block_size)

Initialize certifier.

Parameters
gtid_assignment_block_sizethe group gtid assignment block size
Returns
the operation status
Return values
0OK
!=0Error

◆ initialize_server_gtid_set()

int Certifier::initialize_server_gtid_set ( bool  get_server_gtid_retrieved = false)
private

Method to initialize the group_gtid_executed gtid set with the server gtid executed set and applier retrieved gtid set values.

Parameters
get_server_gtid_retrievedadd applier retrieved gtid set to group_gtid_executed gtid set
Return values
1error during initialization
0success

◆ is_conflict_detection_enable()

bool Certifier::is_conflict_detection_enable ( )
overridevirtual

Check if conflict detection is enable.

Return values
Trueconflict detection is enable
Falseotherwise

Implements Certifier_interface.

◆ is_initialized()

bool Certifier::is_initialized ( )
inlineprivate

◆ reserve_gtid_block()

Gtid_set::Interval Certifier::reserve_gtid_block ( longlong  block_size)
private

This function reserves a block of GTIDs from the group_available_gtid_intervals list.

Return values
Gtid_set::Intervalwhich is the interval os GTIDs attributed

◆ set_certification_info()

int Certifier::set_certification_info ( std::map< std::string, std::string > *  cert_info)
overridevirtual

Sets the certification info according to the given value.

Note
if concurrent access is introduce to these variables, locking is needed in this method
Parameters
[in]cert_infocertification info retrieved from recovery procedure
Return values
>0 Error during setting certification info.
=0 Everything went fine.

Implements Certifier_interface.

◆ set_group_stable_transactions_set()

bool Certifier::set_group_stable_transactions_set ( Gtid_set executed_gtid_set)
overridevirtual

This member function shall add transactions to the stable set.

Parameters
executed_gtid_setThe GTID set of the transactions to be added to the stable set.
Note
when set, the stable set will cause the garbage collection process to be invoked
Return values
Falseif adds successfully,
Trueotherwise.

Implements Certifier_interface.

◆ stable_set_handle()

int Certifier::stable_set_handle ( )
overridevirtual

Computes intersection between all sets received, so that we have the already applied transactions on all servers.

Returns
the operation status
Return values
0OK
!=0Error

Implements Certifier_interface.

◆ terminate()

int Certifier::terminate ( )

Terminate certifier.

Returns
the operation status
Return values
0OK
!=0Error

◆ update_certified_transaction_count()

void Certifier::update_certified_transaction_count ( bool  result,
bool  local_transaction 
)
private

◆ update_parallel_applier_indexes()

void Certifier::update_parallel_applier_indexes ( bool  update_parallel_applier_last_committed_global,
bool  increment_parallel_applier_sequence_number 
)
private

This function updates parallel applier indexes.

It must be called for each remote transaction.

Parameters
[in]update_parallel_applier_last_committed_globalIf true parallel_applier_last_committed_global is updated to the current sequence number (before update sequence number).
[in]increment_parallel_applier_sequence_numberIf 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.

Member Data Documentation

◆ broadcast_thread

Certifier_broadcast_thread* Certifier::broadcast_thread
private

Broadcast thread.

◆ certification_info

Certification_info Certifier::certification_info
private

Certification database.

◆ CERTIFICATION_INFO_ERROR_NAME

const std::string Certifier::CERTIFICATION_INFO_ERROR_NAME
static
Initial value:
=
"certification_info_error"

Key used to store errors in the certification info on View_change_log_event.

◆ certification_info_sid_map

Sid_map* Certifier::certification_info_sid_map
private

◆ certifier_garbage_collection_block

bool Certifier::certifier_garbage_collection_block
private

◆ certifying_already_applied_transactions

bool Certifier::certifying_already_applied_transactions
private

◆ conflict_detection_enable

bool Certifier::conflict_detection_enable
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.

◆ group_available_gtid_intervals

std::list<Gtid_set::Interval> Certifier::group_available_gtid_intervals
private

List of free GTID intervals in group.

◆ group_gtid_executed

Gtid_set* Certifier::group_gtid_executed
private

◆ group_gtid_extracted

Gtid_set* Certifier::group_gtid_extracted
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.

◆ group_gtid_sid_map

Sid_map* Certifier::group_gtid_sid_map
private

◆ group_gtid_sid_map_group_sidno

rpl_sidno Certifier::group_gtid_sid_map_group_sidno
private

Variable to store the sidno used for transactions which will be logged with the group_uuid.

◆ gtid_assignment_block_size

uint64 Certifier::gtid_assignment_block_size
private

The group GTID assignment block size.

◆ GTID_EXTRACTED_NAME

const std::string Certifier::GTID_EXTRACTED_NAME = "gtid_extracted"
staticprivate

Key used to store group_gtid_executed on certification info on View_change_log_event.

◆ gtids_assigned_in_blocks_counter

ulonglong Certifier::gtids_assigned_in_blocks_counter
private

◆ incoming

Synchronized_queue<Data_packet *>* Certifier::incoming
private

◆ initialized

std::atomic<bool> Certifier::initialized {false}
private

Is certifier initialized.

◆ last_conflict_free_transaction

Gtid Certifier::last_conflict_free_transaction
private

Last conflict free transaction identification.

◆ LOCK_certification_info

mysql_mutex_t Certifier::LOCK_certification_info
private

◆ LOCK_members

mysql_mutex_t Certifier::LOCK_members
private

◆ member_gtids

std::map<std::string, Gtid_set::Interval> Certifier::member_gtids
private

Extends the above to allow GTIDs to be assigned in blocks per member.

◆ members

std::vector<std::string> Certifier::members
private

◆ negative_cert

ulonglong Certifier::negative_cert
private

◆ parallel_applier_last_committed_global

int64 Certifier::parallel_applier_last_committed_global
private

◆ parallel_applier_last_sequence_number

int64 Certifier::parallel_applier_last_sequence_number
private

◆ parallel_applier_sequence_number

int64 Certifier::parallel_applier_sequence_number
private

◆ positive_cert

ulonglong Certifier::positive_cert
private

◆ same_member_message_discarded

bool Certifier::same_member_message_discarded
private

◆ stable_gtid_set

Gtid_set* Certifier::stable_gtid_set
private

◆ stable_gtid_set_lock

Checkable_rwlock* Certifier::stable_gtid_set_lock
private

Stable set and garbage collector variables.

◆ stable_sid_map

Sid_map* Certifier::stable_sid_map
private

◆ views_sidno_group_representation

rpl_sidno Certifier::views_sidno_group_representation
private

The sidno used for view log events as seen by the group sid map.

◆ views_sidno_server_representation

rpl_sidno Certifier::views_sidno_server_representation
private

The sidno used for view log events as seen by the server sid map.


The documentation for this class was generated from the following files: