MySQL 8.0.39
Source Code Documentation
MDL_context_backup_manager Class Reference

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_managerinstance ()
 Return singleton object. More...
 
static void destroy ()
 Cleanup and delete singleton object. More...
 

Private Types

typedef std::basic_string< ucharMDL_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_managerm_single = nullptr
 

Detailed Description

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.

Member Typedef Documentation

◆ Element_map_type

◆ MDL_context_backup_key

typedef std::basic_string<uchar> MDL_context_backup_manager::MDL_context_backup_key
private

Key for uniquely identifying MDL_context in the MDL_context_backup map.

Constructor & Destructor Documentation

◆ MDL_context_backup_manager() [1/2]

MDL_context_backup_manager::MDL_context_backup_manager ( PSI_memory_key  key)
private

◆ MDL_context_backup_manager() [2/2]

MDL_context_backup_manager::MDL_context_backup_manager ( const MDL_context_backup_manager )
delete

◆ ~MDL_context_backup_manager()

MDL_context_backup_manager::~MDL_context_backup_manager ( )
private

destroy mutex and clear backup map

Member Function Documentation

◆ check_key_exist()

bool MDL_context_backup_manager::check_key_exist ( const MDL_context_backup_key key_obj)
private

Check for presence of a record with specified key.

Parameters
[in]key_objKey to identity MDL_context
Returns
true if there is a record for specified key, else false

◆ create_backup() [1/2]

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.

Parameters
[in]contextMDL_context from which backup is created.
[in]keyKey to identity MDL_context
[in]keylenKey Length
Return values
trueError, e.g. Fail to create backup object, fail to clone locks.
falseSuccess or a backup already exist for this key.

◆ create_backup() [2/2]

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.

Parameters
[in]mdl_requestsRequests need to be processed and backed up.
[in]keyKey to identity MDL_context
[in]keylenKey Length
Return values
trueError, e.g. Fail to create backup object, fail to clone locks.
falseSuccess or a backup already exist for this key.

◆ delete_backup()

void MDL_context_backup_manager::delete_backup ( const uchar key,
const size_t  keylen 
)

Delete backup context and release associated locks.

Parameters
[in]keyKey to identity MDL_context
[in]keylenKey Length

◆ destroy()

void MDL_context_backup_manager::destroy ( )
static

Cleanup and delete singleton object.

◆ init()

bool MDL_context_backup_manager::init ( )
static

Initialize member variables and singleton object.

◆ init_psi_keys()

void MDL_context_backup_manager::init_psi_keys ( void  )
staticprivate

◆ instance()

MDL_context_backup_manager & MDL_context_backup_manager::instance ( )
static

Return singleton object.

◆ operator=()

void MDL_context_backup_manager::operator= ( const MDL_context_backup_manager )
delete

◆ restore_backup()

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.

Parameters
[out]mdl_contextMDL_context to which backup is restored.
[in]keyKey to identity MDL_context
[in]keylenKey Length
Return values
trueError, e.g. There is no element in the collection matching given key, fail to restore locks.
falseSuccess

Member Data Documentation

◆ m_backup_map

Element_map_type MDL_context_backup_manager::m_backup_map
private

◆ m_LOCK_mdl_context_backup

mysql_mutex_t MDL_context_backup_manager::m_LOCK_mdl_context_backup
private

◆ m_single

MDL_context_backup_manager * MDL_context_backup_manager::m_single = nullptr
staticprivate

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