MySQL 9.1.0
Source Code Documentation
|
Class responsible for managing a cache of Transaction_ctx
objects associated with XA transactions.
More...
#include <transaction_cache.h>
Public Types | |
using | transaction_ptr = std::shared_ptr< Transaction_ctx > |
using | unordered_map = malloc_unordered_map< std::string, transaction_ptr > |
using | list = std::vector< transaction_ptr > |
using | filter_predicate_t = std::function< bool(transaction_ptr const &)> |
Public Member Functions | |
virtual | ~Transaction_cache ()=default |
Transaction_cache (Transaction_cache const &)=delete | |
Transaction_cache (Transaction_cache &&)=delete | |
Transaction_cache & | operator= (Transaction_cache const &)=delete |
Transaction_cache & | operator= (Transaction_cache &&)=delete |
Static Public Member Functions | |
static bool | detach (Transaction_ctx *transaction) |
Transaction is marked in the cache as if it's recovered. More... | |
static void | remove (Transaction_ctx *transaction) |
Remove information about transaction from a cache. More... | |
static bool | insert (XID *xid, Transaction_ctx *transaction) |
Inserts a transaction context identified by a given XID. More... | |
static bool | insert (XID *xid) |
Creates a new transaction context for the recovering transaction identified by a given XID. More... | |
static transaction_ptr | find (XID *xid, filter_predicate_t filter=nullptr) |
Searches the cache for the transaction context identified by the given XID. More... | |
static list | get_cached_transactions () |
Retrieves the list of transaction contexts cached. More... | |
static void | initialize () |
Initializes the transaction cache underlying resources. More... | |
static void | dispose () |
Disposes of the transaction cache allocated resources. More... | |
Private Member Functions | |
Transaction_cache () | |
Class constructor. More... | |
Static Private Member Functions | |
static Transaction_cache & | instance () |
Initialize a cache to store Transaction_ctx and a mutex to protect access to the cache. More... | |
static bool | create_and_insert_new_transaction (XID *xid, bool is_binlogged_arg, const Transaction_ctx *src) |
Creates a new transaction context for the transaction with the given XID and adds it to the cache. More... | |
Private Attributes | |
mysql_mutex_t | m_LOCK_transaction_cache |
A lock to serialize the access to m_transaction_cache More... | |
PSI_mutex_key | m_key_LOCK_transaction_cache |
The PSI key for the above lock. More... | |
PSI_mutex_info | m_transaction_cache_mutexes [1] |
The PSI configuration of the above lock and key. More... | |
unordered_map | m_transaction_cache |
A map holding the cached transaction context, indexed by XID. More... | |
Class responsible for managing a cache of Transaction_ctx
objects associated with XA transactions.
The cache is used during the recovery stage of an XA transaction.
using xa::Transaction_cache::filter_predicate_t = std::function<bool(transaction_ptr const &)> |
using xa::Transaction_cache::list = std::vector<transaction_ptr> |
using xa::Transaction_cache::transaction_ptr = std::shared_ptr<Transaction_ctx> |
using xa::Transaction_cache::unordered_map = malloc_unordered_map<std::string, transaction_ptr> |
|
virtualdefault |
|
delete |
|
delete |
|
private |
Class constructor.
It's declared private since this class is a singleton class.
|
staticprivate |
Creates a new transaction context for the transaction with the given XID and adds it to the cache.
xid | The XID of the transaction to create and add. |
is_binlogged_arg | Whether or not the transaction has already been binlogged. |
src | The transaction context and info to be added to the newly created cache item. |
|
static |
Transaction is marked in the cache as if it's recovered.
The method allows to sustain prepared transaction disconnection.
transaction | Pointer to Transaction object that is replaced. |
false | success or a cache already contains XID_STATE for this XID value |
true | failure |
|
static |
Disposes of the transaction cache allocated resources.
|
static |
Searches the cache for the transaction context identified by the given XID.
An additional filtering predicate can be provided, to allow for further validations on values for mathching XID. The predicate is evaluated while holding the necessary locks to ensure the validaty of the Transaction_ctx
shared pointer.
A non-null value is returned if and only if:
Transaction_ctx::xid_state()get_xid()
) equals to the parameter xid
. This validation is necessary since the XID representation for the key used in the underlying map isn't an exact match for the full XID representation.true
.xid | The XID of the transaction to search the context for. |
filter | A predicate to be evaluated when an value for xid is found. If predicate returns false, the found element is filtered out. |
|
static |
Retrieves the list of transaction contexts cached.
|
static |
Initializes the transaction cache underlying resources.
|
static |
Creates a new transaction context for the recovering transaction identified by a given XID.
xid | The XID of the transaction being recovered. |
|
static |
Inserts a transaction context identified by a given XID.
xid | The XID of the transaction. |
transaction | The object containing the context of the transaction. |
|
staticprivate |
Initialize a cache to store Transaction_ctx and a mutex to protect access to the cache.
|
delete |
|
delete |
|
static |
Remove information about transaction from a cache.
transaction | Pointer to a Transaction_ctx that has to be removed from a cache. |
|
private |
The PSI key for the above lock.
|
private |
A lock to serialize the access to m_transaction_cache
|
private |
A map holding the cached transaction context, indexed by XID.
|
private |
The PSI configuration of the above lock and key.