MySQL 8.0.39
Source Code Documentation
|
Class which is used to store MDL locks associated with XA transactions in prepared state which clients have disconnected. More...
#include <mdl_context_backup.h>
Classes | |
class | MDL_context_backup |
Wrapper around MDL_context class which allows to store it in backup manager's collection. More... | |
Public Member Functions | |
MDL_context_backup_manager (const MDL_context_backup_manager &)=delete | |
void | operator= (const MDL_context_backup_manager &)=delete |
bool | create_backup (const MDL_context *context, const uchar *key, const size_t keylen) |
Create backup from given MDL_context by cloning all transactional locks to backup context and adds to backup context manager collection. More... | |
bool | create_backup (MDL_request_list *mdl_requests, const uchar *key, const size_t keylen) |
Create backup MDL_context, process request on it and add to backup context manager collection. More... | |
bool | restore_backup (MDL_context *mdl_context, const uchar *key, const size_t keylen) |
Restore locks from backup to given MDL_context. More... | |
void | delete_backup (const uchar *key, const size_t keylen) |
Delete backup context and release associated locks. More... | |
Static Public Member Functions | |
static bool | init () |
Initialize member variables and singleton object. More... | |
static MDL_context_backup_manager & | instance () |
Return singleton object. More... | |
static void | destroy () |
Cleanup and delete singleton object. More... | |
Private Types | |
typedef std::basic_string< uchar > | MDL_context_backup_key |
Key for uniquely identifying MDL_context in the MDL_context_backup map. More... | |
typedef std::map< MDL_context_backup_key, std::unique_ptr< MDL_context_backup >, std::less< MDL_context_backup_key >, Malloc_allocator< std::pair< const MDL_context_backup_key, std::unique_ptr< MDL_context_backup > > > > | Element_map_type |
Private Member Functions | |
MDL_context_backup_manager (PSI_memory_key key) | |
~MDL_context_backup_manager () | |
destroy mutex and clear backup map More... | |
bool | check_key_exist (const MDL_context_backup_key &key_obj) |
Check for presence of a record with specified key. More... | |
Static Private Member Functions | |
static void | init_psi_keys (void) |
Private Attributes | |
Element_map_type | m_backup_map |
mysql_mutex_t | m_LOCK_mdl_context_backup |
Static Private Attributes | |
static MDL_context_backup_manager * | m_single = nullptr |
Class which is used to store MDL locks associated with XA transactions in prepared state which clients have disconnected.
These locks are not associated with any particular THD/thread. Later they will be retrieved by the thread which attempts to process the prepared XA transaction.
This is singleton class. It contains map where each element represents MDL_context of disconnected prepared XA transaction and holds related metadata locks.
|
private |
|
private |
Key for uniquely identifying MDL_context in the MDL_context_backup map.
|
private |
|
delete |
|
private |
destroy mutex and clear backup map
|
private |
Check for presence of a record with specified key.
[in] | key_obj | Key to identity MDL_context |
bool MDL_context_backup_manager::create_backup | ( | const MDL_context * | context, |
const uchar * | key, | ||
const size_t | keylen | ||
) |
Create backup from given MDL_context by cloning all transactional locks to backup context and adds to backup context manager collection.
This method is used during user's session disconnect for storing MDL locks acquired by prepared XA transaction(s).
This function does not set error codes beyond what is set by the functions it calls.
[in] | context | MDL_context from which backup is created. |
[in] | key | Key to identity MDL_context |
[in] | keylen | Key Length |
true | Error, e.g. Fail to create backup object, fail to clone locks. |
false | Success or a backup already exist for this key. |
bool MDL_context_backup_manager::create_backup | ( | MDL_request_list * | mdl_requests, |
const uchar * | key, | ||
const size_t | keylen | ||
) |
Create backup MDL_context, process request on it and add to backup context manager collection.
This method is called during server start up in order to acquire MDL locks held by prepared XA transactions existed before server shutdown.
This function does not set error codes beyond what is set by the functions it calls.
[in] | mdl_requests | Requests need to be processed and backed up. |
[in] | key | Key to identity MDL_context |
[in] | keylen | Key Length |
true | Error, e.g. Fail to create backup object, fail to clone locks. |
false | Success or a backup already exist for this key. |
void MDL_context_backup_manager::delete_backup | ( | const uchar * | key, |
const size_t | keylen | ||
) |
Delete backup context and release associated locks.
[in] | key | Key to identity MDL_context |
[in] | keylen | Key Length |
|
static |
Cleanup and delete singleton object.
|
static |
Initialize member variables and singleton object.
|
staticprivate |
|
static |
Return singleton object.
|
delete |
bool MDL_context_backup_manager::restore_backup | ( | MDL_context * | mdl_context, |
const uchar * | key, | ||
const size_t | keylen | ||
) |
Restore locks from backup to given MDL_context.
This function does not set error codes beyond what is set by the functions it calls.
[out] | mdl_context | MDL_context to which backup is restored. |
[in] | key | Key to identity MDL_context |
[in] | keylen | Key Length |
true | Error, e.g. There is no element in the collection matching given key, fail to restore locks. |
false | Success |
|
private |
|
private |
|
staticprivate |