MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
trx_lock_t Struct Reference

#include <trx0trx.h>

Collaboration diagram for trx_lock_t:

Public Attributes

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
 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.

Definition at line 567 of file trx0trx.h.

Member Data 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.

Definition at line 618 of file trx0trx.h.

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().

Definition at line 584 of file trx0trx.h.

mem_heap_t* trx_lock_t::lock_heap

memory heap for trx_locks; protected by lock_sys->mutex

Definition at line 605 of file trx0trx.h.

ulint trx_lock_t::n_active_thrs

number of active query threads

Definition at line 568 of file trx0trx.h.

trx_que_t trx_lock_t::que_state

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

Definition at line 570 of file trx0trx.h.

ib_vector_t* trx_lock_t::table_locks

All table locks requested by this transaction, including AUTOINC locks

Definition at line 615 of file trx0trx.h.

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

Definition at line 609 of file trx0trx.h.

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

Definition at line 574 of file trx0trx.h.

time_t trx_lock_t::wait_started

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

Definition at line 594 of file trx0trx.h.

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.

Definition at line 597 of file trx0trx.h.

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.

Definition at line 588 of file trx0trx.h.


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