Zero  0.1.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lock_core_m Class Reference

Lock table implementation class. More...

#include <lock_core.h>

Public Member Functions

 lock_core_m (const sm_options &options)
 
 ~lock_core_m ()
 
int collect (vtable_t &, bool names_too)
 
void assert_empty () const
 
void dump (std::ostream &o)
 
lil_global_tableget_lil_global_table ()
 
w_error_codes acquire_lock (RawXct *xct, uint32_t hash, const okvl_mode &mode, bool check, bool wait, bool acquire, int32_t timeout, RawLock **out)
 Adds a new lock in the given mode to this queue, waiting until it is granted. More...
 
w_error_codes retry_acquire (RawLock **lock, bool check_only, int32_t timeout)
 
void release_lock (RawLock *lock, lsn_t commit_lsn=lsn_t::null)
 
void release_duration (bool read_lock_only=false, lsn_t commit_lsn=lsn_t::null)
 
RawXctallocate_xct ()
 
void deallocate_xct (RawXct *xct)
 

Private Member Functions

uint32_t _table_bucket (uint32_t id) const
 

Private Attributes

GcPoolForest< RawLock > * _lock_pool
 
GcPoolForest< RawXct > * _xct_pool
 
RawLockCleanerFunctor_raw_lock_cleaner_functor
 
RawLockBackgroundThread_raw_lock_cleaner
 
RawLockQueue_htab
 
uint32_t _htabsz
 
lil_global_table_lil_global_table
 

Detailed Description

Lock table implementation class.

This is the gut of lock management in Foster B-trees. Most of the implementation has been moved to lock_raw.h/cpp.

Constructor & Destructor Documentation

§ lock_core_m()

lock_core_m::lock_core_m ( const sm_options options)

§ ~lock_core_m()

lock_core_m::~lock_core_m ( )

Member Function Documentation

§ _table_bucket()

uint32_t lock_core_m::_table_bucket ( uint32_t  id) const
inlineprivate

§ acquire_lock()

w_error_codes lock_core_m::acquire_lock ( RawXct xct,
uint32_t  hash,
const okvl_mode mode,
bool  check,
bool  wait,
bool  acquire,
int32_t  timeout,
RawLock **  out 
)

Adds a new lock in the given mode to this queue, waiting until it is granted.

Parameters
[in]xctthe transaction to own the new lock
[in]hashprecise hash of the resource to lock.
[in]moderequested lock mode
[in]checkIf true, this method doesn't wait at all and also it leaves the inserted lock entry even if it wasn't granted immediately.
[in]waitif false, this method doesn't actually create a new lock object but just checks if the requested lock mode can be granted or not.
[in]timeoutint maximum length to wait in milliseconds. negative number means forever. If conditional, this parameter is ignored.
[out]outout 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 != NULL

§ allocate_xct()

RawXct * lock_core_m::allocate_xct ( )

Instantiate shadow transaction object for RAW-style lock manager for the current thread.

§ assert_empty()

void lock_core_m::assert_empty ( ) const

implementation of dump/output/other debug utility functions in lock_core,lock_m.

§ collect()

int lock_core_m::collect ( vtable_t &  ,
bool  names_too 
)

§ deallocate_xct()

void lock_core_m::deallocate_xct ( RawXct xct)

§ dump()

void lock_core_m::dump ( std::ostream &  o)

§ get_lil_global_table()

lil_global_table* lock_core_m::get_lil_global_table ( )
inline

§ release_duration()

void lock_core_m::release_duration ( bool  read_lock_only = false,
lsn_t  commit_lsn = lsn_t::null 
)

§ release_lock()

void lock_core_m::release_lock ( RawLock lock,
lsn_t  commit_lsn = lsn_t::null 
)

§ retry_acquire()

w_error_codes lock_core_m::retry_acquire ( RawLock **  lock,
bool  check_only,
int32_t  timeout 
)

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.

Member Data Documentation

§ _htab

RawLockQueue* lock_core_m::_htab
private

§ _htabsz

uint32_t lock_core_m::_htabsz
private

§ _lil_global_table

lil_global_table* lock_core_m::_lil_global_table
private

Global lock table for Light-weight Intent Lock.

§ _lock_pool

GcPoolForest<RawLock>* lock_core_m::_lock_pool
private

§ _raw_lock_cleaner

RawLockBackgroundThread* lock_core_m::_raw_lock_cleaner
private

§ _raw_lock_cleaner_functor

RawLockCleanerFunctor* lock_core_m::_raw_lock_cleaner_functor
private

§ _xct_pool

GcPoolForest<RawXct>* lock_core_m::_xct_pool
private

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