|
struct | Conflicting |
|
class | Global_exclusive_latch_guard |
| A RAII helper which latches global_latch in exclusive mode during constructor, and unlatches it during destruction, preventing any other threads from activity within lock_sys for it's entire scope. More...
|
|
class | Global_exclusive_try_latch |
| A RAII helper which tries to exclusively latch the global_lach in constructor and unlatches it, if needed, during destruction, preventing any other threads from activity within lock_sys for it's entire scope, if owns_lock(). More...
|
|
class | Global_shared_latch_guard |
| A RAII helper which latches global_latch in shared mode during constructor, and unlatches it during destruction, preventing any other thread from acquiring exclusive latch. More...
|
|
class | Latches |
| The class which handles the logic of latching of lock_sys queues themselves. More...
|
|
class | Shard_latch_guard |
| A RAII wrapper class which combines Global_shared_latch_guard and Shard_naked_latch_guard to s-latch the global lock_sys latch and latch the mutex protecting the specified shard for the duration of its scope. More...
|
|
class | Shard_latches_guard |
| A RAII wrapper class which s-latches the global lock_sys shard, and mutexes protecting specified shards for the duration of its scope. More...
|
|
class | Shard_naked_latch_guard |
| A RAII helper which latches the mutex protecting given shard during constructor, and unlatches it during destruction. More...
|
|
class | Shard_naked_latches_guard |
| A RAII helper which latches the mutexes protecting specified shards for the duration of its scope. More...
|
|
class | Trx_locks_cache |
| An object which can be passed to consecutive calls to rec_lock_has_to_wait(trx, mode, lock, is_supremum, trx_locks_cache) for the same trx and heap_no (which is implicitly the bit common to all lock objects passed) which can be used by this function to cache some partial results. More...
|
|
class | Unsafe_global_latch_manipulator |
|
|
bool | has_to_wait (const lock_t *lock1, const lock_t *lock2, Trx_locks_cache &lock1_cache) |
| Checks if a lock request lock1 has to wait for request lock2. More...
|
|
bool | owns_exclusive_global_latch () |
| Tests if lock_sys latch is exclusively owned by the current thread. More...
|
|
bool | owns_shared_global_latch () |
| Tests if lock_sys latch is owned in shared mode by the current thread. More...
|
|
bool | owns_page_shard (const page_id_t &page_id) |
| Tests if given page shard can be safely accessed by the current thread. More...
|
|
bool | owns_table_shard (const dict_table_t &table) |
| Test if given table shard can be safely accessed by the current thread. More...
|
|
bool | owns_lock_shard (const lock_t *lock) |
| Checks if shard which contains lock is latched (or that an exclusive latch on whole lock_sys is held) by current thread. More...
|
|
template<typename F > |
auto | latch_peeked_shard_and_do (const lock_t *peeked_lock, F &&f) |
| Temporarily releases trx->mutex, latches the lock-sys shard containing peeked_lock and latches trx->mutex again and calls f under protection of both latches. More...
|
|
template<typename F > |
void | run_if_waiting (const TrxVersion trx_version, F &&f) |
| Given a pointer to trx (which the caller guarantees will not be freed) and the expected value of trx->version, will call the provided function f, only if the trx is still in expected version and waiting for a lock, within a critical section which holds latches on the trx, and the shard containing the waiting lock. More...
|
|
static Conflict | rec_lock_check_conflict (const trx_t *trx, ulint type_mode, const lock_t *lock2, bool lock_is_on_supremum, Trx_locks_cache &trx_locks_cache) |
| Checks if a new request for a record lock has to wait for existing request. More...
|
|
static bool | rec_lock_has_to_wait (const lock_t *lock1, const lock_t *lock2, Trx_locks_cache &lock1_cache) |
| Checks if a record lock request lock1 has to wait for request lock2. More...
|
|
static void | add_to_trx_locks (lock_t *lock) |
| Adds the lock to the list of trx's locks. More...
|
|
static void | remove_from_trx_locks (lock_t *lock) |
| Removes the lock from the list of trx's locks. More...
|
|
template<typename F > |
static bool | try_relatch_trx_and_shard_and_do (const lock_t *lock, F &&f) |
| A helper function which solves a chicken-and-egg problem occurring when one needs to iterate over trx's locks and perform some actions on them. More...
|
|
static bool | try_release_read_locks_in_s_mode (trx_t *trx, bool only_gap) |
| Tries to release read locks of a transaction without latching the whole lock sys. More...
|
|
static bool | try_release_read_locks_in_x_mode (trx_t *trx, bool only_gap) |
| Release read locks of a transaction latching the whole lock-sys in exclusive mode, which is a bit too expensive to do by default. More...
|
|
static bool | try_release_all_locks (trx_t *trx) |
| Releases transaction locks, and releases possible other transactions waiting because of these locks. More...
|
|
static void | rec_queue_validate_latched (const buf_block_t *block, const rec_t *rec, const dict_index_t *index, const ulint *offsets) |
| Validates the lock queue on a single record. More...
|
|
static void | rec_queue_latch_and_validate (const buf_block_t *block, const rec_t *rec, const dict_index_t *index, const ulint *offsets) |
| Validates the lock queue on a single record. More...
|
|
static void | rec_queue_latch_and_validate (const buf_block_t *block, const rec_t *rec, const dict_index_t *index) |
| Validates the lock queue on a single record. More...
|
|
template<typename F >
auto locksys::latch_peeked_shard_and_do |
( |
const lock_t * |
peeked_lock, |
|
|
F && |
f |
|
) |
| |
Temporarily releases trx->mutex, latches the lock-sys shard containing peeked_lock and latches trx->mutex again and calls f under protection of both latches.
The latch on lock-sys shard will be released immediately after f returns. It is a responsibility of the caller to handle shared lock-sys latch, trx->mutex and verify inside f that the trx has not been finished, and the lock was not released meanwhile.
- Parameters
-
[in] | peeked_lock | A lock of the trx. (While trx->mutex is held it can't be freed, but can be released). It is used to determine the lock-sys shard to latch. |
[in] | f | The callback to call once the lock-sys shard is latched and trx->mutex is relatched. |
- Returns
- The value returned by f.
template<typename F >
void locksys::run_if_waiting |
( |
const TrxVersion |
trx_version, |
|
|
F && |
f |
|
) |
| |
Given a pointer to trx (which the caller guarantees will not be freed) and the expected value of trx->version, will call the provided function f, only if the trx is still in expected version and waiting for a lock, within a critical section which holds latches on the trx, and the shard containing the waiting lock.
If the transaction has meanwhile finished waiting for a lock, or committed or rolled back etc. the f will not be called. It may happen that the lock for which the trx is waiting during exectuion of f is not the same as the lock it was waiting at the moment of invocation.
- Parameters
-
[in] | trx_version | The version of the trx that we intend to wake up |
[in] | f | The callback to call if trx is still waiting for a lock and is still in version trx_version |
template<typename F >
static bool locksys::try_relatch_trx_and_shard_and_do |
( |
const lock_t * |
lock, |
|
|
F && |
f |
|
) |
| |
|
static |
A helper function which solves a chicken-and-egg problem occurring when one needs to iterate over trx's locks and perform some actions on them.
Iterating over this list requires trx->mutex (or exclusive global lock_sys latch), and operating on a lock requires lock_sys latches, yet the latching order requires lock_sys latches to be taken before trx->mutex. One way around it is to use exclusive global lock_sys latch, which heavily deteriorates concurrency. Another is to try to reacquire the latches in needed order, veryfing that the list wasn't modified meanwhile. This function performs following steps:
- releases trx->mutex,
- acquires proper lock_sys shard latch for given lock,
- reaquires trx->mutex
- executes f unless trx's locks list has changed Before and after this function following should hold:
- the shared global lock_sys latch is held
- the trx->mutex is held
- Parameters
-
[in] | lock | the lock we are interested in |
[in] | f | the function to execute when the shard is latched |
- Returns
- true if f was called, false if it couldn't be called because trx locks have changed while relatching trx->mutex