MySQL 8.4.2
Source Code Documentation
gr::Gtid_generator_for_sidno Class Reference

Class that is responsible for holding available GTIDs and assigning GTID blocks to specific group members. More...

#include <gtid_generator_for_sidno.h>

Public Member Functions

 Gtid_generator_for_sidno (rpl_sidno sidno, std::size_t block_size)
 Constructs Gtid_generator_for_sidno for a given sidno and block_size. More...
 
std::pair< rpl_gno, mysql::utils::Return_statusget_next_available_gtid (const char *member_uuid, const Gtid_set &gtid_set)
 Generates gno for transaction originating from server identified with the 'member_uuid' When needed, function will consult gtid_set for the list of available GTIDs. More...
 
void compute_group_available_gtid_intervals (const Gtid_set &gtid_set)
 For a given sidno, clear the assigned blocks for all members, and compute the available GTID intervals for the sidno. More...
 

Private Types

enum class  Gno_generation_result { ok , gno_exhausted , gtid_block_overflow , error }
 Represents result of GNO generation function. More...
 
using Interval_container_type = std::list< Gtid_set::Interval >
 Interval container type, list of intervals. More...
 
using Assigned_intervals_container_type = std::unordered_map< std::string, Gtid_set::Interval >
 Container type hold currently assigned intervals (value) for the given member (key) More...
 
using Assigned_intervals_it = Assigned_intervals_container_type::iterator
 Type of iterator of assigned_gtids. More...
 

Private Member Functions

Gtid_set::Interval reserve_gtid_block (longlong block_size, const Gtid_set &gtid_set)
 This function reserves a block of GTIDs from the list of available GTIDs. More...
 
std::pair< rpl_gno, Gno_generation_resultget_next_available_gtid_candidate (rpl_gno start, rpl_gno end, const Gtid_set &gtid_set) const
 Generate the candidate GNO for the current transaction. More...
 
Assigned_intervals_it get_assigned_interval (const std::string &member_uuid, const Gtid_set &gtid_set)
 gets Interval assigned to the given member More...
 
Assigned_intervals_it reserve_gtid_block (const std::string &member_uuid, const Gtid_set &gtid_set)
 Allocates GTID block for the given member. More...
 

Private Attributes

rpl_sidno m_sidno
 Sidno for which this map has been created. More...
 
long m_block_size
 Block size used to assign GTIDs. More...
 
std::size_t m_counter
 The number of assigned GTIDs. More...
 
Interval_container_type m_available_intervals
 Free intervals. More...
 
Assigned_intervals_container_type m_assigned_intervals
 Holds currently assigned intervals for the given member. More...
 

Detailed Description

Class that is responsible for holding available GTIDs and assigning GTID blocks to specific group members.

Member Typedef Documentation

◆ Assigned_intervals_container_type

Container type hold currently assigned intervals (value) for the given member (key)

◆ Assigned_intervals_it

using gr::Gtid_generator_for_sidno::Assigned_intervals_it = Assigned_intervals_container_type::iterator
private

Type of iterator of assigned_gtids.

◆ Interval_container_type

Interval container type, list of intervals.

Member Enumeration Documentation

◆ Gno_generation_result

Represents result of GNO generation function.

Enumerator
ok 

successfully generated

gno_exhausted 

gno exausted for the given sidno/uuid (error)

gtid_block_overflow 

generated GNO > GNO_MAX defined for the current interval

error 

Other error, such as OOM.

Constructor & Destructor Documentation

◆ Gtid_generator_for_sidno()

gr::Gtid_generator_for_sidno::Gtid_generator_for_sidno ( rpl_sidno  sidno,
std::size_t  block_size 
)

Constructs Gtid_generator_for_sidno for a given sidno and block_size.

Parameters
sidnoSidno assigned to this object
block_sizeObject will reserve blocks of this size

Member Function Documentation

◆ compute_group_available_gtid_intervals()

void gr::Gtid_generator_for_sidno::compute_group_available_gtid_intervals ( const Gtid_set gtid_set)

For a given sidno, clear the assigned blocks for all members, and compute the available GTID intervals for the sidno.

Clearing the assigned blocks implies that subsequent GTID assignments will assign new blocks for any member that commits a transaction, picking them from the available intervals for the sidno. The available intervals for the sidno, which this function also recomputes, consists of the list of intervals that are not in the given gtid_set, i.e., the complement of the set for that sidno. For example, if gtid_set is equal to UUID1:11-47,UUID2:1-100, and sidno corresponds to UUID1, then this will compute the set consisting of the two intervals [1,10] and [48,MAX_GNO].

Parameters
gtid_setGtid set under consideration

◆ get_assigned_interval()

Gtid_generator_for_sidno::Assigned_intervals_it gr::Gtid_generator_for_sidno::get_assigned_interval ( const std::string &  member_uuid,
const Gtid_set gtid_set 
)
private

gets Interval assigned to the given member

Parameters
member_uuidUUID of a group member
gtid_setGtid set under consideration
Returns
Block assigned iterator, which may be invalid in case GNO intervals exhausted for this map

◆ get_next_available_gtid()

std::pair< rpl_gno, mysql::utils::Return_status > gr::Gtid_generator_for_sidno::get_next_available_gtid ( const char *  member_uuid,
const Gtid_set gtid_set 
)

Generates gno for transaction originating from server identified with the 'member_uuid' When needed, function will consult gtid_set for the list of available GTIDs.

Parameters
member_uuidUUID of a group member from which trx originates
gtid_setCurrently used GTID set
Returns
A pair of:
  • Generated gno and OK in case gno generation was possible
  • invalid gno and a corresponding error code: (-1) when there are no available gnos for this SIDNO (-2) when assigned GTIDs block is exhausted

◆ get_next_available_gtid_candidate()

std::pair< rpl_gno, Gtid_generator_for_sidno::Gno_generation_result > gr::Gtid_generator_for_sidno::get_next_available_gtid_candidate ( rpl_gno  start,
rpl_gno  end,
const Gtid_set gtid_set 
) 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 (or group_gtid_extracted) to avoid generate the same value twice.

Parameters
startThe first possible value for the GNO
endThe last possible value for the GNO
gtid_setGtid set under consideration

This method walks through available intervals for the given sidno until it finds the correct one. Returns a free GTID or one of the error codes.

Returns
generated gno, gno_generation_result (possible error states or ok code)
See also
Gno_generation_result for possible error states

◆ reserve_gtid_block() [1/2]

Gtid_generator_for_sidno::Assigned_intervals_it gr::Gtid_generator_for_sidno::reserve_gtid_block ( const std::string &  member_uuid,
const Gtid_set gtid_set 
)
private

Allocates GTID block for the given member.

Parameters
member_uuidUUID of a group member
gtid_setGtid set under consideration
Returns
Block assigned iterator, which may be invalid in case GNO intervals exhausted for this map

◆ reserve_gtid_block() [2/2]

Gtid_set::Interval gr::Gtid_generator_for_sidno::reserve_gtid_block ( longlong  block_size,
const Gtid_set gtid_set 
)
private

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

Parameters
block_sizeSize of the reserved block
gtid_setGtid set under consideration
Returns
Assigned interval

Member Data Documentation

◆ m_assigned_intervals

Assigned_intervals_container_type gr::Gtid_generator_for_sidno::m_assigned_intervals
private

Holds currently assigned intervals for the given member.

◆ m_available_intervals

Interval_container_type gr::Gtid_generator_for_sidno::m_available_intervals
private

Free intervals.

◆ m_block_size

long gr::Gtid_generator_for_sidno::m_block_size
private

Block size used to assign GTIDs.

◆ m_counter

std::size_t gr::Gtid_generator_for_sidno::m_counter
private

The number of assigned GTIDs.

◆ m_sidno

rpl_sidno gr::Gtid_generator_for_sidno::m_sidno
private

Sidno for which this map has been created.


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