MySQL 8.0.40
Source Code Documentation
Xa_state_list Class Reference

Class to maintain list of externally coordinated transactions and their current state at recovery. More...

#include <handler.h>

Public Types

using pair = std::pair< const XID, enum_ha_recover_xa_state >
 
using allocator = Mem_root_allocator< Xa_state_list::pair >
 
using list = std::map< XID, enum_ha_recover_xa_state, std::less< XID >, Xa_state_list::allocator >
 
using iterator = std::map< XID, enum_ha_recover_xa_state, std::less< XID >, Xa_state_list::allocator >::iterator
 
using instantiation_tuple = std::tuple< std::unique_ptr< MEM_ROOT >, std::unique_ptr< Xa_state_list::allocator >, std::unique_ptr< Xa_state_list::list >, std::unique_ptr< Xa_state_list > >
 

Public Member Functions

 Xa_state_list (Xa_state_list::list &populated_by_tc)
 Class constructor. More...
 
virtual ~Xa_state_list ()=default
 
enum_ha_recover_xa_state find (XID const &to_find)
 Searches the underlying map to find an key that corresponds to the parameter. More...
 
enum_ha_recover_xa_state add (XID const &xid, enum_ha_recover_xa_state state)
 Adds a transaction and state to the underlying map. More...
 

Static Public Member Functions

static Xa_state_list::instantiation_tuple new_instance ()
 Factory like method to instantiate all the infra-structure needed to create an Xa_state_list. More...
 

Private Attributes

Xa_state_list::listm_underlying
 The underlying map holding the trx and states. More...
 

Detailed Description

Class to maintain list of externally coordinated transactions and their current state at recovery.

Member Typedef Documentation

◆ allocator

◆ instantiation_tuple

using Xa_state_list::instantiation_tuple = std::tuple< std::unique_ptr<MEM_ROOT>, std::unique_ptr<Xa_state_list::allocator>, std::unique_ptr<Xa_state_list::list>, std::unique_ptr<Xa_state_list> >

◆ iterator

◆ list

◆ pair

Constructor & Destructor Documentation

◆ Xa_state_list()

Xa_state_list::Xa_state_list ( Xa_state_list::list populated_by_tc)

Class constructor.

Parameters
populated_by_tcThe underlying list of XIDs and transaction states, after being populated by the transaction coodinator.

◆ ~Xa_state_list()

virtual Xa_state_list::~Xa_state_list ( )
virtualdefault

Member Function Documentation

◆ add()

enum_ha_recover_xa_state Xa_state_list::add ( XID const &  xid,
enum_ha_recover_xa_state  state 
)

Adds a transaction and state to the underlying map.

If the given XID already exists in the underlying map, the associated state changes according to the following rules:

  • If the parameter state is PREPARED_IN_SE it means that the transaction didn't reach PREPARED_IN_TC, COMMIT or ROLLBACK for sure. In that case: . If other participants state is COMMITTED/ROLLEDBACK, it would mean that it's a state inherited from a previous execution with the same XID and we should set the state to PREPARED_IN_SE. . If other participants state is PREPARED_IN_TC/ COMMITTED_WITH_ONEPHASE it means that the current participant didn't reach it but some other did so, keep the state as PREPARED_IN_TC/COMMITTED_WITH_ONEPHASE.
  • If the parameter state is PREPARED_IN_TC, it means that other participants must have persisted either the PREPARE, the COMMIT or the ROLLBACK. In that case, keep whatever state is already there and ensure that is not PREPARED_IN_SE.
  • If the parameter state is COMMITTED_WITH_ONEPHASE, COMMITTED or ROLLEDBACK, do nothing, only the active transaction coordinator has the ability, for now, to set the transaction state to those values.
Parameters
xidThe XID to be added (the key).
xidThe state to be added (the value).
Returns
The current value of the transaction state if the XID has already been added, Ha_recover_states::NOT_FOUND otherwise.

◆ find()

enum_ha_recover_xa_state Xa_state_list::find ( XID const &  to_find)

Searches the underlying map to find an key that corresponds to the parameter.

Parameters
to_findThe XID to find within the underlying map.
Returns
Ha_recover_states::NOT_FOUND if the transaction wasn't found, the state of the transaction, otherwise.

◆ new_instance()

Xa_state_list::instantiation_tuple Xa_state_list::new_instance ( )
static

Factory like method to instantiate all the infra-structure needed to create an Xa_state_list.

Since such infra-structuer is dependent on MEM_ROOT and Mem_root_allocator, the method returns a tuple containing unique pointers to all 4 objects needed: MEM_ROOT; Mem_root_allocator; Xa_state_list::list; Xa_state_list.

Returns
An std::tuple containing unique pointers to all 4 objects needed: MEM_ROOT; Mem_root_allocator; Xa_state_list::list; Xa_state_list.

Member Data Documentation

◆ m_underlying

Xa_state_list::list& Xa_state_list::m_underlying
private

The underlying map holding the trx and states.


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