MySQL 9.1.0
Source Code Documentation
anonymous_namespace{recovery.cc} Namespace Reference

Typedefs

using recovery_statistics = std::pair< std::tuple< size_t, size_t, size_t >, std::tuple< size_t, size_t, size_t > >
 Pair of tuples used to store the information about success and failures of committing, rolling back or preparing transactions. More...
 

Functions

void recover_one_internal_trx (xarecover_st const &info, handlerton &ht, XA_recover_txn const &xa_trx, my_xid xid, ::recovery_statistics &stats)
 Processes an internally coordinated transaction against the transaction coordinator internal state. More...
 
void recover_one_external_trx (xarecover_st const &info, handlerton &ht, XA_recover_txn const &xa_trx, ::recovery_statistics &stats)
 Processes an externally coordinated transaction against the transaction coordinator internal state. More...
 
template<size_t state, size_t counter>
void add_to_stats (::recovery_statistics &stats)
 Changes the given stats object by adding 1 to the given counter counter in the tuple state. More...
 
bool has_failures (::recovery_statistics const &stats)
 Checks if there are any non-zero failure counters in the fiven statistics object. More...
 
std::string print_stats (::recovery_statistics const &internal_stats, ::recovery_statistics const &external_stats)
 Composes a string presenting the statistics for the given objects. More...
 
bool print_stat (::recovery_statistics const &stats, std::string const &trx_type, std::ostringstream &oss)
 Prints to the given string stream the textual representation of the statistics stored in the given object. More...
 
template<typename ID >
void report_trx_recovery_error (int error, ID const &id, handlerton const &ht, enum xa_status_code failure_code, bool is_xa=false)
 Logs a message to the error log about failure to commit, rollback or prepare a transaction. More...
 
enum xa_status_code generate_xa_recovery_error ()
 Returns an XA status code according to active debug symbols. More...
 

Variables

constexpr size_t STATS_FAILURE = 0
 
constexpr size_t STATS_SUCCESS = 1
 
constexpr size_t STATS_COMMITTED = 0
 
constexpr size_t STATS_ROLLEDBACK = 1
 
constexpr size_t STATS_PREPARED = 2
 

Typedef Documentation

◆ recovery_statistics

using anonymous_namespace{recovery.cc}::recovery_statistics = typedef std::pair<std::tuple<size_t, size_t, size_t>, std::tuple<size_t, size_t, size_t> >

Pair of tuples used to store the information about success and failures of committing, rolling back or preparing transactions.

Counters are organized as follows

{ {Failed commits, Failed rollbacks, Failed prepares}, {Successful commits, Successful rallbacks, Successful prepares} }

Function Documentation

◆ add_to_stats()

template<size_t state, size_t counter>
void anonymous_namespace{recovery.cc}::add_to_stats ( ::recovery_statistics stats)

Changes the given stats object by adding 1 to the given counter counter in the tuple state.

Parameters
statsThe statistics object to change the counter for.

◆ generate_xa_recovery_error()

enum xa_status_code anonymous_namespace{recovery.cc}::generate_xa_recovery_error ( )

Returns an XA status code according to active debug symbols.

If none of the targeted debug symbols are active, will return XA_OK.

Returns
one of XAER_ASYNC, XAER_RMERR, XAER_NOTA, XAER_INVAL, XAER_PROTO, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE if associated debug symbol is active, XA_OK otherwise.

◆ has_failures()

bool anonymous_namespace{recovery.cc}::has_failures ( ::recovery_statistics const &  stats)

Checks if there are any non-zero failure counters in the fiven statistics object.

Parameters
statsThe statistics object to check for non-zero failure counters.
Returns
true if any non-zero failure counters were found, false otherwise.

◆ print_stat()

bool anonymous_namespace{recovery.cc}::print_stat ( ::recovery_statistics const &  stats,
std::string const &  trx_type,
std::ostringstream &  oss 
)

Prints to the given string stream the textual representation of the statistics stored in the given object.

Parameters
statsThe object containing the statistics.
trx_typeA string containing the textual description of the type of transaction the statistics refer to.
ossThe string stream to print the textual representation to.
Returns
true if any non-zero counter was found and something was written to the string stream, false otherwise.

◆ print_stats()

std::string anonymous_namespace{recovery.cc}::print_stats ( ::recovery_statistics const &  internal_stats,
::recovery_statistics const &  external_stats 
)

Composes a string presenting the statistics for the given objects.

Parameters
internal_statsThe object containing statistics for internally coordinated transactions.
external_statsThe object containing statistics for externally transactions.
Returns
a string with the textual representation of the given statistics.

◆ recover_one_external_trx()

void anonymous_namespace{recovery.cc}::recover_one_external_trx ( xarecover_st const &  info,
handlerton ht,
XA_recover_txn const &  xa_trx,
::recovery_statistics stats 
)

Processes an externally coordinated transaction against the transaction coordinator internal state.

Searches the TC information on externally coordinated transactions, xarecover_st::xa_list for the XID of the transaction:

  1. If found, checks the state of the transaction: a. If the state is COMMITTED, the transaction is committed in the storage engine. b. If the state is ROLLEDBACK, the transaction is rolled back in the storage engine. c. If the state is PREPARED, the transaction is kept in prepared state, added to the list of recovered transactions, visible with XA RECOVER and storage engines are instructed to move the transaction to the PREPARED_IN_TC state.
  2. If not, rolls it back in the storage engine.
Parameters
infoTC internal state w.r.t to transaction state
htThe plugin interface for the storage engine to recover the transaction for
xa_trxThe information about the transaction to be recovered
statsRepository of statistical information about transaction recovery success and failures

◆ recover_one_internal_trx()

void anonymous_namespace{recovery.cc}::recover_one_internal_trx ( xarecover_st const &  info,
handlerton ht,
XA_recover_txn const &  xa_trx,
my_xid  xid,
::recovery_statistics stats 
)

Processes an internally coordinated transaction against the transaction coordinator internal state.

Searches the TC information on committed transactions, xarecover_st::commit_list for the XID of the transaction:

  1. If found and the TC recovery heuristics is TC_HEURISTIC_RECOVER_COMMIT, commits the transaction in the storage engine.
  2. If not, rolls it back in the storage engine.
Parameters
infoTC internal state w.r.t transaction state
htThe plugin interface for the storage engine to recover the transaction for
xa_trxThe information about the transaction to be recovered
xidThe internal XID of the transaction to be recovered
statsRepository of statistical information about transaction recovery success and failures

◆ report_trx_recovery_error()

template<typename ID >
void anonymous_namespace{recovery.cc}::report_trx_recovery_error ( int  error,
ID const &  id,
handlerton const &  ht,
enum xa_status_code  failure_code,
bool  is_xa = false 
)

Logs a message to the error log about failure to commit, rollback or prepare a transaction.

The severity level used is INFORMATION_LEVEL.

Parameters
errorThe error to be reported, one of ER_BINLOG_CRASH_RECOVERY_COMMIT_FAILED, ER_BINLOG_CRASH_RECOVERY_ROLLBACK_FAILED, ER_BINLOG_CRASH_RECOVERY_PREPARE_FAILED
idThe identifier of the transaction. A templated type is used to allow to print either the internal ID for internally coordinated transactions or the XID for externally coordinated transactions.
htThe handlerton for the storage engine that failed to complete the action.
failure_codeThe xa_status_code failure code returned by the SE. If no xa_status_code is returned from SE, XA_OK should passed to avoing adding the code to the message.
is_xaWhether or not the id refers to an XA transaction.

Variable Documentation

◆ STATS_COMMITTED

constexpr size_t anonymous_namespace{recovery.cc}::STATS_COMMITTED = 0
constexpr

◆ STATS_FAILURE

constexpr size_t anonymous_namespace{recovery.cc}::STATS_FAILURE = 0
constexpr

◆ STATS_PREPARED

constexpr size_t anonymous_namespace{recovery.cc}::STATS_PREPARED = 2

◆ STATS_ROLLEDBACK

constexpr size_t anonymous_namespace{recovery.cc}::STATS_ROLLEDBACK = 1

◆ STATS_SUCCESS

constexpr size_t anonymous_namespace{recovery.cc}::STATS_SUCCESS = 1