|
Zero
0.1.0
|
A shadow transaction object for RAW-style lock manager. More...
#include <lock_raw.h>
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) |
| RawLock * | allocate_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_raw * | lock_pool_next |
| XctState | state |
| bool | deadlock_detected_by_others |
| RawXct * | blocker |
| pthread_cond_t | lock_wait_cond |
| pthread_mutex_t | lock_wait_mutex |
| lsn_t | read_watermark |
| RawXctLockHashMap | private_hash_map |
| RawLock * | private_first |
| RawLock * | private_last |
Public Attributes inherited from GcPoolEntry | |
| gc_pointer_raw | gc_pointer |
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].
| enum RawXct::XctState |
| 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.
| void RawXct::deallocate_lock | ( | RawLock * | lock | ) |
Remove the lock object from transaction-private linked-list and hashmap, then deallocate.
| void RawXct::dump_lockinfo | ( | std::ostream & | out | ) | const |
debugout function.
|
inline |
Returns if this transaction has acquired any lock.
| void RawXct::init | ( | gc_thread_id | thread_id, |
| GcPoolForest< RawLock > * | lock_pool, | ||
| gc_pointer_raw * | lock_pool_next | ||
| ) |
| bool RawXct::is_deadlocked | ( | RawXct * | first_blocker | ) |
Recursively checks for the case where some blocker is this transaction itself.
| [in] | first_blocker | the transaction that blocks myself. |
[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.
| void RawXct::uninit | ( | ) |
|
inline |
| RawXct* RawXct::blocker |
If exists the transaction that is now blocking this transaction. NULL otherwise.
| bool RawXct::deadlock_detected_by_others |
Other transaction realized that this transaction is deadlocked.
| GcPoolForest<RawLock>* RawXct::lock_pool |
Pointer to object pool for RawLock.
| gc_pointer_raw* RawXct::lock_pool_next |
Pointer to thread-local allocation hint for lock_pool.
| pthread_cond_t RawXct::lock_wait_cond |
Used to wait in lock manager, paired with lock_wait_mutex.
| pthread_mutex_t RawXct::lock_wait_mutex |
Used to wait in lock manager, paired with lock_wait_cond.
| 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.
| 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.
| 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.
| 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).
| XctState RawXct::state |
Whether this transaction is waiting for another transaction.
| gc_thread_id RawXct::thread_id |
Identifier of the thread running this transaction, eg pthread_self().
1.8.12