InnoDB Plugin  1.0
Data Fields
trx_lock_t Struct Reference

#include <trx0trx.h>

Collaboration diagram for trx_lock_t:
Collaboration graph
[legend]

Data Fields

ulint n_active_thrs
trx_que_t que_state
lock_twait_lock
ib_uint64_t deadlock_mark
ibool was_chosen_as_deadlock_victim
time_t wait_started
que_thr_twait_thr
mem_heap_tlock_heap
ut_list_base< ib_lock_t > trx_locks
ib_vector_ttable_locks
ibool cancel

Detailed Description

Latching protocol for trx_lock_t::que_state. trx_lock_t::que_state captures the state of the query thread during the execution of a query. This is different from a transaction state. The query state of a transaction can be updated asynchronously by other threads. The other threads can be system threads, like the timeout monitor thread or user threads executing other queries. Another thing to be mindful of is that there is a delay between when a query thread is put into LOCK_WAIT state and before it actually starts waiting. Between these two events it is possible that the query thread is granted the lock it was waiting for, which implies that the state can be changed asynchronously.

All these operations take place within the context of locking. Therefore state changes within the locking code must acquire both the lock mutex and the trx->mutex when changing trx->lock.que_state to TRX_QUE_LOCK_WAIT or trx->lock.wait_lock to non-NULL but when the lock wait ends it is sufficient to only acquire the trx->mutex. To query the state either of the mutexes is sufficient within the locking code and no mutex is required when the query thread is no longer waiting. The locks and state of an active transaction. Protected by lock_sys->mutex, trx->mutex or both.

Field Documentation

ibool trx_lock_t::cancel

TRUE if the transaction is being rolled back either via deadlock detection or due to lock timeout. The caller has to acquire the trx_t::mutex in order to cancel the locks. In lock_trx_table_locks_remove() we check for this cancel of a transaction's locks and avoid reacquiring the trx mutex to prevent recursive deadlocks. Protected by both the lock sys mutex and the trx_t::mutex.

ib_uint64_t trx_lock_t::deadlock_mark

A mark field that is initialized to and checked against lock_mark_counter by lock_deadlock_recursive().

mem_heap_t* trx_lock_t::lock_heap

memory heap for trx_locks; protected by lock_sys->mutex

ulint trx_lock_t::n_active_thrs

number of active query threads

trx_que_t trx_lock_t::que_state

valid when trx->state == TRX_STATE_ACTIVE: TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT, ...

ib_vector_t* trx_lock_t::table_locks

All table locks requested by this transaction, including AUTOINC locks

ut_list_base< ib_lock_t > trx_lock_t::trx_locks

locks requested by the transaction; insertions are protected by trx->mutex and lock_sys->mutex; removals are protected by lock_sys->mutex

lock_t* trx_lock_t::wait_lock

if trx execution state is TRX_QUE_LOCK_WAIT, this points to the lock request, otherwise this is NULL; set to non-NULL when holding both trx->mutex and lock_sys->mutex; set to NULL when holding lock_sys->mutex; readers should hold lock_sys->mutex, except when they are holding trx->mutex and wait_lock==NULL

time_t trx_lock_t::wait_started

lock wait started at this time, protected only by lock_sys->mutex

que_thr_t* trx_lock_t::wait_thr

query thread belonging to this trx that is in QUE_THR_LOCK_WAIT state. For threads suspended in a lock wait, this is protected by lock_sys->mutex. Otherwise, this may only be modified by the thread that is serving the running transaction.

ibool trx_lock_t::was_chosen_as_deadlock_victim

when the transaction decides to wait for a lock, it sets this to FALSE; if another transaction chooses this transaction as a victim in deadlock resolution, it sets this to TRUE. Protected by trx->mutex.


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