MySQL 9.1.0
Source Code Documentation
lock_guid_t Struct Reference

Used to represent locks requests uniquely over time. More...

#include <lock0types.h>

Public Member Functions

 lock_guid_t ()=default
 Initializes the lock_guid_t object to a value which doesn't match any real lock. More...
 
 lock_guid_t (const lock_t &lock)
 Initializes lock_guid_t with data uniquely identifying the lock request(s) represented by lock_t object. More...
 
bool operator== (const lock_guid_t &rhs) const
 Checks if two guids represent the same lock (conceptually): they represent the same lock_t struct in memory and it was not reused. More...
 
bool operator!= (const lock_guid_t &rhs) const
 Checks if two guids represent two different locks (conceptually): they represent two different lock_t structs in memory or struct was reused. More...
 
 operator bool () const
 Checks if the instance is non-empty, i.e. More...
 

Public Attributes

trx_guid_t m_trx_guid {}
 The guid of lock->trx. More...
 
uint64_t m_immutable_id {}
 Id of the lock_t struct such that it does not change over time, and two different lock_t structs never have the same id. More...
 

Detailed Description

Used to represent locks requests uniquely over time.

Please note that in case of LOCK_REC there might be actually multiple "sub-requests" for many different heap_no associated with the same lock_t object which we ignore here and use same guid for all of them. Also, the lock mode and status and other properties of the lock can change over time and/or represent more than one actual request. This is also ignored here. What we try to achieve is some way to identify lock_t struct such that: (1) we can serialize and deserialize it (2) we don't have to be afraid of dangling pointers (3) if the same lock_t gets deallocated and then allocated again, or otherwise reused by a different transaction, we will have a different guid for it. Note, that a single transaction never dealloactes a lock_t and allocates it again, as all deallocations happen during commit (lock_trx_release_locks).

Constructor & Destructor Documentation

◆ lock_guid_t() [1/2]

lock_guid_t::lock_guid_t ( )
default

Initializes the lock_guid_t object to a value which doesn't match any real lock.

◆ lock_guid_t() [2/2]

lock_guid_t::lock_guid_t ( const lock_t lock)

Initializes lock_guid_t with data uniquely identifying the lock request(s) represented by lock_t object.

Parameters
[in]lockthe object representing the lock request(s)

Member Function Documentation

◆ operator bool()

lock_guid_t::operator bool ( ) const
inline

Checks if the instance is non-empty, i.e.

was not default-constructed, but rather initialized to correspond to a real lock_t.

Returns
true iff this guid was initialized to match a real lock

◆ operator!=()

bool lock_guid_t::operator!= ( const lock_guid_t rhs) const
inline

Checks if two guids represent two different locks (conceptually): they represent two different lock_t structs in memory or struct was reused.

Parameters
[in]rhsanother guid to compare against
Returns
true iff the two guids are different and thus represent different locks

◆ operator==()

bool lock_guid_t::operator== ( const lock_guid_t rhs) const
inline

Checks if two guids represent the same lock (conceptually): they represent the same lock_t struct in memory and it was not reused.

Parameters
[in]rhsanother guid to compare against
Returns
true iff the two guids are equal and thus represent same lock

Member Data Documentation

◆ m_immutable_id

uint64_t lock_guid_t::m_immutable_id {}

Id of the lock_t struct such that it does not change over time, and two different lock_t structs never have the same id.

However it may happen that two "different" locks at different points in time actually reuse the same lock_t struct and thus have the same immutable id - this is why we also store the transaction's guid

◆ m_trx_guid

trx_guid_t lock_guid_t::m_trx_guid {}

The guid of lock->trx.

Used to identify ABA problems when the same lock_t struct gets reused by a new transaction.


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