MySQL 8.0.40
Source Code Documentation
|
A collection of all MDL locks. More...
Public Member Functions | |
void | init () |
Initialize the container for all MDL locks. More... | |
void | destroy () |
Destroy the container for all MDL locks. More... | |
MDL_lock * | find (LF_PINS *pins, const MDL_key *key, bool *pinned) |
Find MDL_lock object corresponding to the key. More... | |
MDL_lock * | find_or_insert (LF_PINS *pins, const MDL_key *key, bool *pinned) |
Find MDL_lock object corresponding to the key, create it if it does not exist. More... | |
void | lock_object_used () |
Decrement unused MDL_lock objects counter. More... | |
void | lock_object_unused (MDL_context *ctx, LF_PINS *pins) |
Increment unused MDL_lock objects counter. More... | |
int32 | get_unused_locks_count () const |
Get number of unused MDL_lock objects in MDL_map cache. More... | |
LF_PINS * | get_pins () |
Allocate pins which are necessary for MDL_context/thread to be able to work with MDL_map container. More... | |
bool | is_lock_object_singleton (const MDL_key *mdl_key) const |
Check if MDL_lock object corresponding to the key is going to be singleton. More... | |
Private Member Functions | |
void | remove_random_unused (MDL_context *ctx, LF_PINS *pins, int32 *unused_locks) |
Try to find random MDL_lock object in MDL_map for which there are no "fast" path nor "slow" path locks. More... | |
Private Attributes | |
LF_HASH | m_locks |
LF_HASH with all locks in the server. More... | |
MDL_lock * | m_global_lock |
Pre-allocated MDL_lock object for GLOBAL namespace. More... | |
MDL_lock * | m_commit_lock |
Pre-allocated MDL_lock object for COMMIT namespace. More... | |
MDL_lock * | m_acl_cache_lock |
Pre-allocated MDL_lock object for ACL_CACHE namespace. More... | |
MDL_lock * | m_backup_lock |
Pre-allocated MDL_lock object for BACKUP_LOCK namespace. More... | |
std::atomic< int32 > | m_unused_lock_objects |
Number of unused MDL_lock objects in the server. More... | |
A collection of all MDL locks.
A singleton, there is only one instance of the map in the server.
void MDL_map::destroy | ( | ) |
Destroy the container for all MDL locks.
Find MDL_lock object corresponding to the key.
[in,out] | pins | LF_PINS to be used for pinning pointers during look-up and returned MDL_lock object. |
[in] | mdl_key | Key for which MDL_lock object needs to be found. |
[out] | pinned | true - if MDL_lock object is pinned, false - if MDL_lock object doesn't require pinning (i.e. it is an object for GLOBAL, COMMIT or ACL_CACHE namespaces). |
MY_LF_ERRPTR | - Failure (OOM) |
other-non-NULL | - MDL_lock object found. |
NULL | - Object not found. |
|
inline |
Find MDL_lock object corresponding to the key, create it if it does not exist.
[in,out] | pins | LF_PINS to be used for pinning pointers during look-up and returned MDL_lock object. |
[in] | mdl_key | Key for which MDL_lock object needs to be found. |
[out] | pinned | true - if MDL_lock object is pinned, false - if MDL_lock object doesn't require pinning (i.e. it is an object for GLOBAL, COMMIT or ACL_CACHE namespaces). |
non-NULL | - Success. MDL_lock instance for the key with locked MDL_lock::m_rwlock. |
NULL | - Failure (OOM). |
|
inline |
Allocate pins which are necessary for MDL_context/thread to be able to work with MDL_map container.
|
inline |
Get number of unused MDL_lock objects in MDL_map cache.
void MDL_map::init | ( | ) |
Initialize the container for all MDL locks.
|
inline |
Check if MDL_lock object corresponding to the key is going to be singleton.
|
inline |
Increment unused MDL_lock objects counter.
If number of such objects exceeds threshold and unused/total objects ratio is high enough try to free some of them.
|
inline |
Decrement unused MDL_lock objects counter.
|
private |
Try to find random MDL_lock object in MDL_map for which there are no "fast" path nor "slow" path locks.
If found - mark it as destroyed, remove object from MDL_map and return it back to allocator.
[in] | ctx | Context on which behalf we are trying to remove unused object. Primarily needed to generate random value to be used for random dive into the hash in MDL_map. |
[in,out] | pins | Pins for the calling thread to be used for hash lookup and deletion. |
[out] | unused_locks | Number of unused lock objects after operation. |
|
private |
Pre-allocated MDL_lock object for ACL_CACHE namespace.
|
private |
Pre-allocated MDL_lock object for BACKUP_LOCK namespace.
|
private |
Pre-allocated MDL_lock object for COMMIT namespace.
|
private |
Pre-allocated MDL_lock object for GLOBAL namespace.
|
private |
LF_HASH with all locks in the server.
|
private |
Number of unused MDL_lock objects in the server.
Updated using atomic operations, read using both atomic and ordinary reads. We assume that ordinary reads of 32-bit words can't result in partial results, but may produce stale results thanks to memory reordering, LF_HASH seems to be using similar assumption.
Note that due to fact that updates to this counter are not atomic with marking MDL_lock objects as used/unused it might easily get negative for some short period of time. Code which uses its value needs to take this into account.