Lock Manager API.See Orthogonal Key Value Locking and Light-weight Intent Lock.
More...
#include <lock.h>
|
| | lock_m (const sm_options &options) |
| |
| | ~lock_m () |
| |
| void | assert_empty () const |
| | Unsafely check that the lock table is empty for debugging and assertions at shutdown, when MT-safety shouldn't be an issue. More...
|
| |
| void | dump (ostream &o) |
| | Unsafely dump the lock hash table (for debugging). More...
|
| |
| void | stats (u_long &buckets_used, u_long &max_bucket_len, u_long &min_bucket_len, u_long &mode_bucket_len, float &avg_bucket_len, float &var_bucket_len, float &std_bucket_len) const |
| |
| lil_global_table * | get_lil_global_table () |
| |
| okvl_mode | get_granted_mode (uint32_t hash, xct_t *xd=nullptr) |
| | Returns the lock granted to the given transaction for this lock. More...
|
| |
| rc_t | lock (uint32_t hash, const okvl_mode &m, bool check, bool wait, bool acquire, xct_t *=nullptr, int timeout=timeout_t::WAIT_SPECIFIED_BY_XCT, RawLock **out=nullptr) |
| | Acquires a lock of the given mode (or stronger) More...
|
| |
| rc_t | retry_lock (RawLock **lock, bool check_only, int timeout=timeout_t::WAIT_SPECIFIED_BY_XCT) |
| |
| rc_t | intent_store_lock (StoreID stid, okvl_mode::element_lock_mode m) |
| |
| void | unlock (RawLock *lock, lsn_t commit_lsn=lsn_t::null) |
| |
| rc_t | unlock_duration (bool read_lock_only=false, lsn_t commit_lsn=lsn_t::null) |
| |
| void | give_permission_to_violate (lsn_t commit_lsn=lsn_t::null) |
| |
| RawXct * | allocate_xct () |
| |
| void | deallocate_xct (RawXct *xct) |
| |
§ lock_m()
§ ~lock_m()
§ _convert_timeout() [1/2]
| int lock_m::_convert_timeout |
( |
int |
timeout | ) |
|
|
private |
§ _convert_timeout() [2/2]
| int lock_m::_convert_timeout |
( |
int |
timeout, |
|
|
xct_t * |
xd |
|
) |
| |
|
private |
§ allocate_xct()
| RawXct * lock_m::allocate_xct |
( |
| ) |
|
§ assert_empty()
| void lock_m::assert_empty |
( |
| ) |
const |
Unsafely check that the lock table is empty for debugging and assertions at shutdown, when MT-safety shouldn't be an issue.
§ core()
§ deallocate_xct()
| void lock_m::deallocate_xct |
( |
RawXct * |
xct | ) |
|
§ dump()
| void lock_m::dump |
( |
ostream & |
o | ) |
|
Unsafely dump the lock hash table (for debugging).
Doesn't acquire the mutexes it should for safety, but allows you dump the table while inside the lock manager core.
§ get_granted_mode()
| okvl_mode lock_m::get_granted_mode |
( |
uint32_t |
hash, |
|
|
xct_t * |
xd = nullptr |
|
) |
| |
Returns the lock granted to the given transaction for this lock.
- Returns
- the lock mode the transaction has for this lock. ALL_N_GAP_N if not any.
This method returns very quickly because it only checks transaction-private data.
- Precondition
- the current thread is the only thread running the current transaction
§ get_lil_global_table()
§ give_permission_to_violate()
§ intent_store_lock()
Take an intent lock on the given store.
§ lock()
Acquires a lock of the given mode (or stronger)
- Parameters
-
| [in] | hash | precise hash of the resource to lock. |
| [in] | m | requested lock mode |
| [in] | check | if true, this method doesn't actually create a new lock object but just checks if the requested lock mode can be granted or not. |
| [in] | wait | If false, this method doesn't wait at all and also it leaves the inserted lock entry even if it wasn't granted immediately. |
| [in] | xd | the transaction to own the new lock |
| [in] | timeout | maximum length to wait in milliseconds. negative number means forever. If conditional, this parameter is ignored. |
| [out] | out | pointer to the successfully acquired lock. it returns NULL if we couldn't get the lock except conditional==true case. |
check_only=true can give a false positive in concurrent unlock case, but give no false negative assuming a conflicting lock is not concurrently taken for the key. This assumption holds for our only check_only=true use case, which is the tentative NX lock check before inserting a new key, because we then have an EX latch! Thus, this is a safe and efficient check for B-tree insertion.
conditional locking is the standard way to take a lock in DBMS without leaving latches long time. B-tree first requests a lock without releasing latch (conditional). If it fails, it releases latch and unconditionally lock, which needs re-check of LSN after lock and re-latch. The purpose of this conditional parameter is that we don't want to insert the same lock entry twice when the first conditional locking fails. When conditional==true, we leave the lock entry and return it in out even if it wasn't granted. The caller MUST be responsible to call retry_acquire() after the failed acquire (which returns eCONDLOCKTIMEOUT if it failed) or release the lock. It is anyway released at commit time, but waiting lock entry should be removed before the transaction does anything else.
- Precondition
- out != nullptr
§ lock_stats()
| static void lock_m::lock_stats |
( |
u_long & |
locks, |
|
|
u_long & |
acquires, |
|
|
u_long & |
cache_hits, |
|
|
u_long & |
unlocks, |
|
|
bool |
reset |
|
) |
| |
|
static |
§ on_thread_destroy()
| static void lock_m::on_thread_destroy |
( |
| ) |
|
|
static |
§ on_thread_init()
| static void lock_m::on_thread_init |
( |
| ) |
|
|
static |
§ retry_lock()
Waits for the already-inserted lock entry. Used after a failed conditional locking.
- See also
- acquire()
- Note
- "lock" is a RawLock**, not RawLock*. It might be cleared after another failure, or become a new lock when it's automatically retried.
§ stats()
| void lock_m::stats |
( |
u_long & |
buckets_used, |
|
|
u_long & |
max_bucket_len, |
|
|
u_long & |
min_bucket_len, |
|
|
u_long & |
mode_bucket_len, |
|
|
float & |
avg_bucket_len, |
|
|
float & |
var_bucket_len, |
|
|
float & |
std_bucket_len |
|
) |
| const |
§ unlock()
§ unlock_duration()
§ _core
The documentation for this class was generated from the following files: