Zero  0.1.0
Public Types | Public Member Functions | Public Attributes | List of all members
RawXct Struct Reference

A shadow transaction object for RAW-style lock manager. More...

#include <lock_raw.h>

Inheritance diagram for RawXct:
GcPoolEntry

Public Types

enum  XctState { UNUSED = 0, ACTIVE, WAITING }
 

Public Member Functions

void init (gc_thread_id thread_id, GcPoolForest< RawLock > *lock_pool, gc_pointer_raw *lock_pool_next)
 
void uninit ()
 
bool is_deadlocked (RawXct *first_blocker)
 Recursively checks for the case where some blocker is this transaction itself. More...
 
void update_read_watermark (const lsn_t &tag)
 
RawLockallocate_lock (uint32_t hash, const okvl_mode &mode, RawLock::LockState state)
 
void deallocate_lock (RawLock *lock)
 
void dump_lockinfo (std::ostream &out) const
 
bool has_locks () const
 

Public Attributes

gc_thread_id thread_id
 
GcPoolForest< RawLock > * lock_pool
 
gc_pointer_rawlock_pool_next
 
XctState state
 
bool deadlock_detected_by_others
 
RawXctblocker
 
pthread_cond_t lock_wait_cond
 
pthread_mutex_t lock_wait_mutex
 
lsn_t read_watermark
 
RawXctLockHashMap private_hash_map
 
RawLockprivate_first
 
RawLockprivate_last
 
- Public Attributes inherited from GcPoolEntry
gc_pointer_raw gc_pointer
 

Detailed Description

A shadow transaction object for RAW-style lock manager.

Just like [JUNG13], we have additional (shadow) transaction objects that are used from the real transaction objects. The real transaction objects (xct_t) are immediately recycled after commit/abort while this object lives a bit longer until garbage collection kicks in. This is necessary to make sure the RAW style deadlock-detection does not reference an already revoked object. See Section 4.5 of [JUNG13].

Member Enumeration Documentation

§ XctState

Enumerator
UNUSED 

This object is in the pool and not used in any place.

ACTIVE 

This transaction is running without being blocked so far.

WAITING 

This transaction is waiting for some other transaction.

Member Function Documentation

§ allocate_lock()

RawLock * RawXct::allocate_lock ( uint32_t  hash,
const okvl_mode mode,
RawLock::LockState  state 
)

Newly allocate a lock object from the object pool and put it in transaction-private linked-list and hashmap.

§ deallocate_lock()

void RawXct::deallocate_lock ( RawLock lock)

Remove the lock object from transaction-private linked-list and hashmap, then deallocate.

§ dump_lockinfo()

void RawXct::dump_lockinfo ( std::ostream &  out) const

debugout function.

§ has_locks()

bool RawXct::has_locks ( ) const
inline

Returns if this transaction has acquired any lock.

§ init()

void RawXct::init ( gc_thread_id  thread_id,
GcPoolForest< RawLock > *  lock_pool,
gc_pointer_raw lock_pool_next 
)

§ is_deadlocked()

bool RawXct::is_deadlocked ( RawXct first_blocker)

Recursively checks for the case where some blocker is this transaction itself.

Parameters
[in]first_blockerthe transaction that blocks myself.
Returns
true if there is a cycle, meaning deadlock.

[JUNG13] does not clarify the algorithm to detect deadlocks. We have originally had Dreadlock, the spinning based detection based on fingerprint, but it would cause too many atomic operations from many threads in this RAW-style queue. I assume a traditional recursive check (who is my blocker's blocker's...) is appropriate with [JUNG13] approach.

Precondition
first_blocker != NULL

§ uninit()

void RawXct::uninit ( )

§ update_read_watermark()

void RawXct::update_read_watermark ( const lsn_t tag)
inline

Member Data Documentation

§ blocker

RawXct* RawXct::blocker

If exists the transaction that is now blocking this transaction. NULL otherwise.

§ deadlock_detected_by_others

bool RawXct::deadlock_detected_by_others

Other transaction realized that this transaction is deadlocked.

§ lock_pool

GcPoolForest<RawLock>* RawXct::lock_pool

Pointer to object pool for RawLock.

§ lock_pool_next

gc_pointer_raw* RawXct::lock_pool_next

Pointer to thread-local allocation hint for lock_pool.

§ lock_wait_cond

pthread_cond_t RawXct::lock_wait_cond

Used to wait in lock manager, paired with lock_wait_mutex.

§ lock_wait_mutex

pthread_mutex_t RawXct::lock_wait_mutex

Used to wait in lock manager, paired with lock_wait_cond.

§ private_first

RawLock* RawXct::private_first

A doubly linked-list for lock entries in transaction's private memory. first -> next -> next ... is used for unlock while commit/abort. NULL if zero entries.

§ private_hash_map

RawXctLockHashMap RawXct::private_hash_map

A hashmap for lock entries in transaction's private memory. Used to quickly check if the transaction already has a required lock.

§ private_last

RawLock* RawXct::private_last

A doubly linked-list for lock entries in transaction's private memory. last is used for appending a new lock. NULL if zero or one entries.

§ read_watermark

lsn_t RawXct::read_watermark

Whenever a transaction acquires some lock, this value is updated as _read_watermark=max(_read_watermark, lock_bucket.tag) so that we maintain a maximum commit LSN of transactions it depends on. This value is used to commit a read-only transaction with Safe SX-ELR to block until the log manager flushed the log buffer at least to this value. Assuming this protocol, we can do ELR for x-locks. See jira ticket:99 "ELR for X-lock" (originally trac ticket:101).

§ state

XctState RawXct::state

Whether this transaction is waiting for another transaction.

§ thread_id

gc_thread_id RawXct::thread_id

Identifier of the thread running this transaction, eg pthread_self().


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