MySQL 9.2.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
Trx_by_id_with_min Class Reference

#include <trx0sys.h>

Classes

struct  Trx_track_hash
 

Public Member Functions

By_id const & by_id () const
 
trx_id_t min_id () const
 
trx_tget (trx_id_t trx_id) const
 
void insert (trx_t &trx)
 
void erase (trx_id_t trx_id)
 

Static Public Member Functions

static trx_id_t get_cheap_lower_bound_for_already_active_id ()
 Returns a value which is lower or equal to id of any transaction for which insert(id) happened before the call started, and erase(id) has not happened before the start of the call. More...
 
static trx_id_t get_better_lower_bound_for_already_active_id ()
 

Private Types

using By_id = std::unordered_map< trx_id_t, trx_t *, Trx_track_hash >
 

Static Private Member Functions

static void limit_to (std::atomic< trx_id_t > &a, trx_id_t upper_bound)
 Performs an equivalent of if(upper_bound<v)v=upper_bound atomically. More...
 

Private Attributes

By_id m_by_id
 
std::atomic< trx_id_tm_min_id {TRX_ID_MAX}
 For observers which use Trx_shard::mutex protection: each transaction id in the m_by_id is guaranteed to be at least m_min_id. More...
 

Static Private Attributes

static std::atomic< trx_id_ts_lower_bound {0}
 This value is guaranteed to be always smaller or equal than any id in any of the shards of transactions which finished calling insert(id). More...
 
static std::atomic< trx_id_ts_lower_bound_candidate {0}
 This is used during get_better_lower_bound_for_already_active_id() to announce that it is trying to establish new value for s_lower_bound, and this is the current candidate. More...
 

Member Typedef Documentation

◆ By_id

using Trx_by_id_with_min::By_id = std::unordered_map<trx_id_t, trx_t *, Trx_track_hash>
private

Member Function Documentation

◆ by_id()

By_id const & Trx_by_id_with_min::by_id ( ) const
inline

◆ erase()

void Trx_by_id_with_min::erase ( trx_id_t  trx_id)
inline

◆ get()

trx_t * Trx_by_id_with_min::get ( trx_id_t  trx_id) const
inline

◆ get_better_lower_bound_for_already_active_id()

trx_id_t Trx_by_id_with_min::get_better_lower_bound_for_already_active_id ( )
static
See also
get_cheap_lower_bound_for_already_active_id() from which this function differs by executing a tighter estimation. If it is indeed better, then as a side effect it will bump the value of s_lower_bound used by get_cheap_lower_bound_for_already_active_id()

◆ get_cheap_lower_bound_for_already_active_id()

static trx_id_t Trx_by_id_with_min::get_cheap_lower_bound_for_already_active_id ( )
inlinestatic

Returns a value which is lower or equal to id of any transaction for which insert(id) happened before the call started, and erase(id) has not happened before the start of the call.

See also
s_lower_bound Note that this value never increases unless someone calls
get_better_lower_bound_for_already_active_id()

◆ insert()

void Trx_by_id_with_min::insert ( trx_t trx)
inline

◆ limit_to()

static void Trx_by_id_with_min::limit_to ( std::atomic< trx_id_t > &  a,
trx_id_t  upper_bound 
)
inlinestaticprivate

Performs an equivalent of if(upper_bound<v)v=upper_bound atomically.

Parameters
[in]aThe atomic we want to limit to upper_bound
[in]upper_boundThe upper_bound we want to impose on a

◆ min_id()

trx_id_t Trx_by_id_with_min::min_id ( ) const
inline

Member Data Documentation

◆ m_by_id

By_id Trx_by_id_with_min::m_by_id
private

◆ m_min_id

std::atomic<trx_id_t> Trx_by_id_with_min::m_min_id {TRX_ID_MAX}
private

For observers which use Trx_shard::mutex protection: each transaction id in the m_by_id is guaranteed to be at least m_min_id.

Writes are protected with Trx_shard::mutex. Reads can be performed without any latch before accessing m_by_id, but care must be taken to interpret the result -

See also
trx_rw_is_active for details.

◆ s_lower_bound

std::atomic< trx_id_t > Trx_by_id_with_min::s_lower_bound {0}
staticprivate

This value is guaranteed to be always smaller or equal than any id in any of the shards of transactions which finished calling insert(id).

I.e. a shard can already contain an id smaller than this value, if insert(id) has still not finished. This is sufficient guarantee, if you only care about "active" transactions in the sense that insert(id) for them has happened before the call. For example, when you want to check if a record you look at could have been modified by any of active transactions, then this is a valid assumption as creating a record happens after insert(id). This value may be way lower than actual minimum, as it is only updated from time to time by get_better_lower_bound_for_already_active_id().

◆ s_lower_bound_candidate

std::atomic< trx_id_t > Trx_by_id_with_min::s_lower_bound_candidate {0}
staticprivate

This is used during get_better_lower_bound_for_already_active_id() to announce that it is trying to establish new value for s_lower_bound, and this is the current candidate.

This value is 0 if no such process is under way, and changed to non-zero by the only thread chosen to perform it, thus it also serves the purpose of "mutex". Transactions executing insert(id) should limit this atomic to id, to help the process.


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