MySQL 5.6.14 Source Code Document
|
#include "lock0lock.h"
#include "lock0priv.h"
#include "ha_prototypes.h"
#include "usr0sess.h"
#include "trx0purge.h"
#include "dict0mem.h"
#include "dict0boot.h"
#include "trx0sys.h"
#include "pars0pars.h"
#include "que0que.h"
#include "row0mysql.h"
#include "row0sel.h"
#include "row0types.h"
#include "srv0mon.h"
#include "ut0vec.h"
#include "btr0btr.h"
#include <set>
Go to the source code of this file.
Classes | |
struct | lock_deadlock_ctx_t |
struct | lock_stack_t |
Macros | |
#define | LOCK_MODULE_IMPLEMENTATION |
#define | LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK 1000000 |
#define | LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK 200 |
#define | LOCK_RELEASE_INTERVAL 1000 |
#define | LOCK_PAGE_BITMAP_MARGIN 64 |
#define | LOCK_STACK_SIZE OS_THREAD_MAX_N |
#define | lock_deadlock_too_deep(c) |
#define | IS_LOCK_S_OR_X(lock) |
Enumerations | |
enum | lock_rec_req_status { LOCK_REC_FAIL, LOCK_REC_SUCCESS, LOCK_REC_SUCCESS_CREATED } |
Functions | |
UNIV_INLINE ibool | lock_rec_get_nth_bit (const lock_t *lock, ulint i) |
UNIV_INTERN void | lock_report_trx_id_insanity (trx_id_t trx_id, const rec_t *rec, dict_index_t *index, const ulint *offsets, trx_id_t max_trx_id) |
ut_ad (rec_offs_validate(rec, index, offsets)) | |
if (UNIV_UNLIKELY(!is_ok)) | |
return (is_ok) | |
UNIV_INTERN bool | lock_clust_rec_cons_read_sees (const rec_t *rec, dict_index_t *index, const ulint *offsets, read_view_t *view) |
UNIV_INTERN bool | lock_sec_rec_cons_read_sees (const rec_t *rec, const read_view_t *view) |
UNIV_INTERN void | lock_sys_create (ulint n_cells) |
UNIV_INTERN void | lock_sys_close (void) |
UNIV_INTERN ulint | lock_get_size (void) |
UNIV_INLINE enum lock_mode | lock_get_mode (const lock_t *lock) |
UNIV_INLINE ulint | lock_get_wait (const lock_t *lock) |
UNIV_INTERN dict_table_t * | lock_get_src_table (trx_t *trx, dict_table_t *dest, enum lock_mode *mode) |
UNIV_INTERN ibool | lock_is_table_exclusive (const dict_table_t *table, const trx_t *trx) |
UNIV_INLINE void | lock_set_lock_and_trx_wait (lock_t *lock, trx_t *trx) |
UNIV_INLINE void | lock_reset_lock_and_trx_wait (lock_t *lock) |
UNIV_INLINE ulint | lock_rec_get_gap (const lock_t *lock) |
UNIV_INLINE ulint | lock_rec_get_rec_not_gap (const lock_t *lock) |
UNIV_INLINE ulint | lock_rec_get_insert_intention (const lock_t *lock) |
UNIV_INLINE ulint | lock_mode_stronger_or_eq (enum lock_mode mode1, enum lock_mode mode2) |
UNIV_INLINE ulint | lock_mode_compatible (enum lock_mode mode1, enum lock_mode mode2) |
UNIV_INLINE ibool | lock_rec_has_to_wait (const trx_t *trx, ulint type_mode, const lock_t *lock2, ibool lock_is_on_supremum) |
UNIV_INTERN ibool | lock_has_to_wait (const lock_t *lock1, const lock_t *lock2) |
UNIV_INLINE ulint | lock_rec_get_n_bits (const lock_t *lock) |
UNIV_INLINE void | lock_rec_set_nth_bit (lock_t *lock, ulint i) |
UNIV_INTERN ulint | lock_rec_find_set_bit (const lock_t *lock) |
UNIV_INLINE void | lock_rec_reset_nth_bit (lock_t *lock, ulint i) |
UNIV_INLINE const lock_t * | lock_rec_get_next_on_page_const (const lock_t *lock) |
UNIV_INLINE lock_t * | lock_rec_get_next_on_page (lock_t *lock) |
UNIV_INLINE lock_t * | lock_rec_get_first_on_page_addr (ulint space, ulint page_no) |
UNIV_INTERN lock_t * | lock_rec_expl_exist_on_page (ulint space, ulint page_no) |
UNIV_INLINE lock_t * | lock_rec_get_first_on_page (const buf_block_t *block) |
UNIV_INLINE lock_t * | lock_rec_get_next (ulint heap_no, lock_t *lock) |
UNIV_INLINE const lock_t * | lock_rec_get_next_const (ulint heap_no, const lock_t *lock) |
UNIV_INLINE lock_t * | lock_rec_get_first (const buf_block_t *block, ulint heap_no) |
UNIV_INTERN const lock_t * | lock_rec_get_prev (const lock_t *in_lock, ulint heap_no) |
UNIV_INLINE const lock_t * | lock_table_has (const trx_t *trx, const dict_table_t *table, enum lock_mode mode) |
UNIV_INLINE lock_t * | lock_rec_has_expl (ulint precise_mode, const buf_block_t *block, ulint heap_no, const trx_t *trx) |
UNIV_INLINE lock_t * | lock_rec_find_similar_on_page (ulint type_mode, ulint heap_no, lock_t *lock, const trx_t *trx) |
UNIV_INTERN ulint | lock_number_of_rows_locked (const trx_lock_t *trx_lock) |
UNIV_INLINE enum lock_rec_req_status | lock_rec_lock_fast (ibool impl, ulint mode, const buf_block_t *block, ulint heap_no, dict_index_t *index, que_thr_t *thr) |
UNIV_INTERN void | lock_move_reorganize_page (const buf_block_t *block, const buf_block_t *oblock) |
UNIV_INTERN void | lock_move_rec_list_end (const buf_block_t *new_block, const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_move_rec_list_start (const buf_block_t *new_block, const buf_block_t *block, const rec_t *rec, const rec_t *old_end) |
UNIV_INTERN void | lock_update_split_right (const buf_block_t *right_block, const buf_block_t *left_block) |
UNIV_INTERN void | lock_update_merge_right (const buf_block_t *right_block, const rec_t *orig_succ, const buf_block_t *left_block) |
UNIV_INTERN void | lock_update_root_raise (const buf_block_t *block, const buf_block_t *root) |
UNIV_INTERN void | lock_update_copy_and_discard (const buf_block_t *new_block, const buf_block_t *block) |
UNIV_INTERN void | lock_update_split_left (const buf_block_t *right_block, const buf_block_t *left_block) |
UNIV_INTERN void | lock_update_merge_left (const buf_block_t *left_block, const rec_t *orig_pred, const buf_block_t *right_block) |
UNIV_INTERN void | lock_rec_reset_and_inherit_gap_locks (const buf_block_t *heir_block, const buf_block_t *block, ulint heir_heap_no, ulint heap_no) |
UNIV_INTERN void | lock_update_discard (const buf_block_t *heir_block, ulint heir_heap_no, const buf_block_t *block) |
UNIV_INTERN void | lock_update_insert (const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_update_delete (const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_rec_store_on_page_infimum (const buf_block_t *block, const rec_t *rec) |
UNIV_INTERN void | lock_rec_restore_from_page_infimum (const buf_block_t *block, const rec_t *rec, const buf_block_t *donator) |
UNIV_INLINE void | lock_deadlock_start_print () |
UNIV_INLINE void | lock_deadlock_fputs (const char *msg) |
UNIV_INLINE void | lock_deadlock_trx_print (const trx_t *trx, ulint max_query_len) |
UNIV_INLINE void | lock_deadlock_lock_print (const lock_t *lock) |
UNIV_INLINE lock_t * | lock_table_create (dict_table_t *table, ulint type_mode, trx_t *trx) |
UNIV_INLINE void | lock_table_pop_autoinc_locks (trx_t *trx) |
UNIV_INLINE void | lock_table_remove_autoinc_lock (lock_t *lock, trx_t *trx) |
UNIV_INLINE void | lock_table_remove_low (lock_t *lock) |
UNIV_INLINE const lock_t * | lock_table_other_has_incompatible (const trx_t *trx, ulint wait, const dict_table_t *table, enum lock_mode mode) |
UNIV_INTERN dberr_t | lock_table (ulint flags, dict_table_t *table, enum lock_mode mode, que_thr_t *thr) |
UNIV_INTERN void | lock_table_ix_resurrect (dict_table_t *table, trx_t *trx) |
UNIV_INTERN void | lock_rec_unlock (trx_t *trx, const buf_block_t *block, const rec_t *rec, enum lock_mode lock_mode) |
UNIV_INTERN void | lock_remove_all_on_table (dict_table_t *table, ibool remove_also_table_sx_locks) |
UNIV_INTERN void | lock_table_print (FILE *file, const lock_t *lock) |
UNIV_INTERN void | lock_rec_print (FILE *file, const lock_t *lock) |
UNIV_INTERN ibool | lock_print_info_summary (FILE *file, ibool nowait) |
UNIV_INTERN void | lock_print_info_all_transactions (FILE *file) |
UNIV_INTERN dberr_t | lock_rec_insert_check_and_lock (ulint flags, const rec_t *rec, buf_block_t *block, dict_index_t *index, que_thr_t *thr, mtr_t *mtr, ibool *inherit) |
UNIV_INTERN dberr_t | lock_clust_rec_modify_check_and_lock (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, const ulint *offsets, que_thr_t *thr) |
UNIV_INTERN dberr_t | lock_sec_rec_modify_check_and_lock (ulint flags, buf_block_t *block, const rec_t *rec, dict_index_t *index, que_thr_t *thr, mtr_t *mtr) |
UNIV_INTERN dberr_t | lock_sec_rec_read_check_and_lock (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, const ulint *offsets, enum lock_mode mode, ulint gap_mode, que_thr_t *thr) |
UNIV_INTERN dberr_t | lock_clust_rec_read_check_and_lock (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, const ulint *offsets, enum lock_mode mode, ulint gap_mode, que_thr_t *thr) |
UNIV_INTERN dberr_t | lock_clust_rec_read_check_and_lock_alt (ulint flags, const buf_block_t *block, const rec_t *rec, dict_index_t *index, enum lock_mode mode, ulint gap_mode, que_thr_t *thr) |
UNIV_INLINE void | lock_release_autoinc_last_lock (ib_vector_t *autoinc_locks) |
UNIV_INTERN ulint | lock_get_type (const lock_t *lock) |
UNIV_INTERN trx_id_t | lock_get_trx_id (const lock_t *lock) |
UNIV_INTERN const char * | lock_get_mode_str (const lock_t *lock) |
UNIV_INTERN const char * | lock_get_type_str (const lock_t *lock) |
UNIV_INLINE dict_table_t * | lock_get_table (const lock_t *lock) |
UNIV_INTERN table_id_t | lock_get_table_id (const lock_t *lock) |
UNIV_INTERN const char * | lock_get_table_name (const lock_t *lock) |
UNIV_INTERN const dict_index_t * | lock_rec_get_index (const lock_t *lock) |
UNIV_INTERN const char * | lock_rec_get_index_name (const lock_t *lock) |
UNIV_INTERN ulint | lock_rec_get_space_id (const lock_t *lock) |
UNIV_INTERN ulint | lock_rec_get_page_no (const lock_t *lock) |
UNIV_INTERN void | lock_cancel_waiting_and_release (lock_t *lock) |
UNIV_INTERN void | lock_unlock_table_autoinc (trx_t *trx) |
UNIV_INTERN void | lock_trx_release_locks (trx_t *trx) |
UNIV_INTERN dberr_t | lock_trx_handle_wait (trx_t *trx) |
UNIV_INTERN ulint | lock_table_get_n_locks (const dict_table_t *table) |
UNIV_INTERN ibool | lock_table_has_locks (const dict_table_t *table) |
Variables | |
UNIV_INTERN lock_sys_t * | lock_sys = NULL |
UNIV_INTERN ibool | lock_deadlock_found = FALSE |
static const rec_t * | rec |
static const rec_t dict_index_t * | index |
static const rec_t dict_index_t const ulint *offsets bool | is_ok = trx_id < max_trx_id |
trx_id_t | max_trx_id = trx_sys_get_max_trx_id() |
#define IS_LOCK_S_OR_X | ( | lock | ) |
Definition at line 4710 of file lock0lock.cc.
#define lock_deadlock_too_deep | ( | c | ) |
Check if the search is too deep.
Definition at line 3580 of file lock0lock.cc.
enum lock_rec_req_status |
Record locking request status
LOCK_REC_FAIL |
Failed to acquire a lock |
LOCK_REC_SUCCESS |
Succeeded in acquiring a lock (implicit or already acquired) |
LOCK_REC_SUCCESS_CREATED |
Explicitly created a new lock |
Definition at line 2068 of file lock0lock.cc.
UNIV_INTERN void lock_cancel_waiting_and_release | ( | lock_t * | lock | ) |
Cancels a waiting lock request and releases possible other transactions waiting behind it.
lock | in/out: waiting lock request |
Definition at line 6719 of file lock0lock.cc.
UNIV_INTERN bool lock_clust_rec_cons_read_sees | ( | const rec_t * | rec, |
dict_index_t * | index, | ||
const ulint * | offsets, | ||
read_view_t * | view | ||
) |
Checks that a record is seen in a consistent read.
rec | in: user record which should be read or passed over by a read cursor |
index | in: clustered index |
offsets | in: rec_get_offsets(rec, index) |
view | in: consistent read view |
Definition at line 526 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_clust_rec_modify_check_and_lock | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
que_thr_t * | thr | ||
) |
Checks if locks of other transactions prevent an immediate modify (update, delete mark, or delete unmark) of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record x-lock to the lock queue.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: record which should be modified |
index | in: clustered index |
offsets | in: rec_get_offsets(rec, index) |
thr | in: query thread |
Definition at line 6099 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_clust_rec_read_check_and_lock | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
enum lock_mode | mode, | ||
ulint | gap_mode, | ||
que_thr_t * | thr | ||
) |
Checks if locks of other transactions prevent an immediate read, or passing over by a read cursor, of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record lock to the lock queue. Sets the requested mode lock on the record.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: user record or page supremum record which should be read or passed over by a read cursor |
index | in: clustered index |
offsets | in: rec_get_offsets(rec, index) |
mode | in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE |
gap_mode | in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP |
thr | in: query thread |
Definition at line 6320 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_clust_rec_read_check_and_lock_alt | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
enum lock_mode | mode, | ||
ulint | gap_mode, | ||
que_thr_t * | thr | ||
) |
Checks if locks of other transactions prevent an immediate read, or passing over by a read cursor, of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a record lock to the lock queue. Sets the requested mode lock on the record. This is an alternative version of lock_clust_rec_read_check_and_lock() that does not require the parameter "offsets".
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: user record or page supremum record which should be read or passed over by a read cursor |
index | in: clustered index |
mode | in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE |
gap_mode | in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP |
thr | in: query thread |
Definition at line 6392 of file lock0lock.cc.
UNIV_INLINE void lock_deadlock_fputs | ( | const char * | msg | ) |
Print a message to the deadlock file and possibly to stderr.
msg | in: message to print |
Definition at line 3507 of file lock0lock.cc.
UNIV_INLINE void lock_deadlock_lock_print | ( | const lock_t * | lock | ) |
Print lock data to the deadlock file and possibly to stderr.
lock | in: record or table type lock |
Definition at line 3554 of file lock0lock.cc.
UNIV_INLINE void lock_deadlock_start_print | ( | ) |
rewind(3) the file used for storing the latest detected deadlock and print a heading message to stderr if printing of all deadlocks to stderr is enabled.
Definition at line 3486 of file lock0lock.cc.
UNIV_INLINE void lock_deadlock_trx_print | ( | const trx_t * | trx, |
ulint | max_query_len | ||
) |
Print transaction data to the deadlock file and possibly to stderr.
trx | in: transaction |
max_query_len | in: max query length to print, or 0 to use the default max length |
Definition at line 3524 of file lock0lock.cc.
UNIV_INLINE enum lock_mode lock_get_mode | ( | const lock_t * | lock | ) |
Gets the mode of a lock.
lock | in: lock |
Definition at line 664 of file lock0lock.cc.
UNIV_INTERN const char* lock_get_mode_str | ( | const lock_t * | lock | ) |
Gets the mode of a lock in a human readable string. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6537 of file lock0lock.cc.
UNIV_INTERN ulint lock_get_size | ( | void | ) |
Gets the size of a lock struct.
Definition at line 653 of file lock0lock.cc.
UNIV_INTERN dict_table_t* lock_get_src_table | ( | trx_t * | trx, |
dict_table_t * | dest, | ||
enum lock_mode * | mode | ||
) |
Gets the source table of an ALTER TABLE transaction. The table must be covered by an IX or IS table lock.
trx | in: transaction |
dest | in: destination of ALTER TABLE |
mode | out: lock mode of the source table |
Definition at line 696 of file lock0lock.cc.
UNIV_INLINE dict_table_t* lock_get_table | ( | const lock_t * | lock | ) |
Gets the table on which the lock is.
lock | in: lock |
Definition at line 6603 of file lock0lock.cc.
UNIV_INTERN table_id_t lock_get_table_id | ( | const lock_t * | lock | ) |
Gets the id of the table on which the lock is.
lock | in: lock |
Definition at line 6625 of file lock0lock.cc.
UNIV_INTERN const char* lock_get_table_name | ( | const lock_t * | lock | ) |
Gets the name of the table on which the lock is. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6642 of file lock0lock.cc.
Gets the id of the transaction owning a lock.
lock | in: lock |
Definition at line 6524 of file lock0lock.cc.
UNIV_INTERN ulint lock_get_type | ( | const lock_t * | lock | ) |
Gets the type of a lock. Non-inline version for using outside of the lock module.
lock | in: lock |
Definition at line 6512 of file lock0lock.cc.
UNIV_INTERN const char* lock_get_type_str | ( | const lock_t * | lock | ) |
Gets the type of a lock in a human readable string. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6584 of file lock0lock.cc.
UNIV_INLINE ulint lock_get_wait | ( | const lock_t * | lock | ) |
Gets the wait flag of a lock.
lock | in: lock |
Definition at line 678 of file lock0lock.cc.
Checks if a lock request lock1 has to wait for request lock2.
lock1 | in: waiting lock |
lock2 | in: another lock; NOTE that it is assumed that this has a lock bit set on the same record as in lock1 if the locks are record locks |
Definition at line 1034 of file lock0lock.cc.
UNIV_INTERN ibool lock_is_table_exclusive | ( | const dict_table_t * | table, |
const trx_t * | trx | ||
) |
Determine if the given table is exclusively "owned" by the given transaction, i.e., transaction holds LOCK_IX and possibly LOCK_AUTO_INC on the table.
table | in: table |
trx | in: transaction |
Definition at line 779 of file lock0lock.cc.
UNIV_INLINE ulint lock_mode_compatible | ( | enum lock_mode | mode1, |
enum lock_mode | mode2 | ||
) |
Calculates if lock mode 1 is compatible with lock mode 2.
mode1 | in: lock mode |
mode2 | in: lock mode |
Definition at line 935 of file lock0lock.cc.
UNIV_INLINE ulint lock_mode_stronger_or_eq | ( | enum lock_mode | mode1, |
enum lock_mode | mode2 | ||
) |
Calculates if lock mode 1 is stronger or equal to lock mode 2.
mode1 | in: lock mode |
mode2 | in: lock mode |
Definition at line 919 of file lock0lock.cc.
UNIV_INTERN void lock_move_rec_list_end | ( | const buf_block_t * | new_block, |
const buf_block_t * | block, | ||
const rec_t * | rec | ||
) |
Moves the explicit locks on user records to another page if a record list end is moved to another page.
new_block | in: index page to move to |
block | in: index page |
rec | in: record on page: this is the first record moved |
Definition at line 2886 of file lock0lock.cc.
UNIV_INTERN void lock_move_rec_list_start | ( | const buf_block_t * | new_block, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
const rec_t * | old_end | ||
) |
Moves the explicit locks on user records to another page if a record list start is moved to another page.
new_block | in: index page to move to |
block | in: index page |
rec | in: record on page: this is the first record NOT copied |
old_end | in: old previous-to-last record on new_page before the records were copied |
Definition at line 2975 of file lock0lock.cc.
UNIV_INTERN void lock_move_reorganize_page | ( | const buf_block_t * | block, |
const buf_block_t * | oblock | ||
) |
Updates the lock table when we have reorganized a page. NOTE: we copy also the locks set on the infimum of the page; the infimum may carry locks if an update of a record is occurring on the page, and its locks were temporarily stored on the infimum.
block | in: old index page, now reorganized |
oblock | in: copy of the old, not reorganized page |
Definition at line 2740 of file lock0lock.cc.
UNIV_INTERN ulint lock_number_of_rows_locked | ( | const trx_lock_t * | trx_lock | ) |
Return approximate number or record locks (bits set in the bitmap) for this transaction. Since delete-marked records may be removed, the record count will not be precise. The caller must be holding lock_sys->mutex.
trx_lock | in: transaction locks |
Definition at line 1698 of file lock0lock.cc.
UNIV_INTERN void lock_print_info_all_transactions | ( | FILE * | file | ) |
Prints info of locks for each transaction. This function assumes that the caller holds the lock mutex and more importantly it will release the lock mutex on behalf of the caller. (This should be fixed in the future).
file | in: file where to print |
Definition at line 5223 of file lock0lock.cc.
UNIV_INTERN ibool lock_print_info_summary | ( | FILE * | file, |
ibool | nowait | ||
) |
Prints info of locks for all transactions.
file | in: file where to print |
nowait | in: whether to wait for the lock mutex |
Definition at line 5137 of file lock0lock.cc.
UNIV_INTERN lock_t* lock_rec_expl_exist_on_page | ( | ulint | space, |
ulint | page_no | ||
) |
Determines if there are explicit record locks on a page.
space | in: space id |
page_no | in: page number |
Definition at line 1232 of file lock0lock.cc.
UNIV_INTERN ulint lock_rec_find_set_bit | ( | const lock_t * | lock | ) |
Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, if none found.
lock | in: record lock with at least one bit set |
Definition at line 1108 of file lock0lock.cc.
UNIV_INLINE lock_t* lock_rec_find_similar_on_page | ( | ulint | type_mode, |
ulint | heap_no, | ||
lock_t * | lock, | ||
const trx_t * | trx | ||
) |
Looks for a suitable type record lock struct by the same trx on the same page. This can be used to save space when a new record lock should be set on a page: no new struct is needed, if a suitable old is found.
type_mode | in: lock type_mode field |
heap_no | in: heap number of the record |
lock | in: lock_rec_get_first_on_page() |
trx | in: transaction |
Definition at line 1613 of file lock0lock.cc.
UNIV_INLINE lock_t* lock_rec_get_first | ( | const buf_block_t * | block, |
ulint | heap_no | ||
) |
Gets the first explicit lock request on a record.
block | in: block containing the record |
heap_no | in: heap number of the record |
Definition at line 1318 of file lock0lock.cc.
UNIV_INLINE lock_t* lock_rec_get_first_on_page | ( | const buf_block_t * | block | ) |
Gets the first record lock on a page, where the page is identified by a pointer to it.
block | in: buffer block |
Definition at line 1252 of file lock0lock.cc.
UNIV_INLINE lock_t* lock_rec_get_first_on_page_addr | ( | ulint | space, |
ulint | page_no | ||
) |
Gets the first record lock on a page, where the page is identified by its file address.
space | in: space |
page_no | in: page number |
Definition at line 1202 of file lock0lock.cc.
UNIV_INLINE ulint lock_rec_get_gap | ( | const lock_t * | lock | ) |
Gets the gap flag of a record lock.
lock | in: record lock |
Definition at line 874 of file lock0lock.cc.
UNIV_INTERN const dict_index_t* lock_rec_get_index | ( | const lock_t * | lock | ) |
For a record lock, gets the index on which the lock is.
lock | in: lock |
Definition at line 6658 of file lock0lock.cc.
UNIV_INTERN const char* lock_rec_get_index_name | ( | const lock_t * | lock | ) |
For a record lock, gets the name of the index on which the lock is. The string should not be free()'d or modified.
lock | in: lock |
Definition at line 6675 of file lock0lock.cc.
UNIV_INLINE ulint lock_rec_get_insert_intention | ( | const lock_t * | lock | ) |
Gets the waiting insert flag of a record lock.
lock | in: record lock |
Definition at line 904 of file lock0lock.cc.
UNIV_INLINE ulint lock_rec_get_n_bits | ( | const lock_t * | lock | ) |
Gets the number of bits in a record lock bitmap.
lock | in: record lock |
Definition at line 1072 of file lock0lock.cc.
Gets the next explicit lock request on a record.
heap_no | in: heap number of the record |
lock | in: lock |
Definition at line 1285 of file lock0lock.cc.
Gets the next explicit lock request on a record.
heap_no | in: heap number of the record |
lock | in: lock |
Definition at line 1305 of file lock0lock.cc.
Gets the first or next record lock on a page.
lock | in: a record lock |
Definition at line 1189 of file lock0lock.cc.
Gets the first or next record lock on a page.
lock | in: a record lock |
Definition at line 1153 of file lock0lock.cc.
UNIV_INLINE ibool lock_rec_get_nth_bit | ( | const lock_t * | lock, |
ulint | i | ||
) |
Gets the nth bit of a record lock.
lock | in: record lock |
i | in: index of the bit |
Definition at line 442 of file lock0lock.cc.
UNIV_INTERN ulint lock_rec_get_page_no | ( | const lock_t * | lock | ) |
For a record lock, gets the page number on which the lock is.
lock | in: lock |
Definition at line 6705 of file lock0lock.cc.
Gets the previous record lock set on a record.
in_lock | in: record lock |
heap_no | in: heap number of the record |
Definition at line 1385 of file lock0lock.cc.
UNIV_INLINE ulint lock_rec_get_rec_not_gap | ( | const lock_t * | lock | ) |
Gets the LOCK_REC_NOT_GAP flag of a record lock.
lock | in: record lock |
Definition at line 889 of file lock0lock.cc.
UNIV_INTERN ulint lock_rec_get_space_id | ( | const lock_t * | lock | ) |
For a record lock, gets the tablespace number on which the lock is.
lock | in: lock |
Definition at line 6691 of file lock0lock.cc.
UNIV_INLINE lock_t* lock_rec_has_expl | ( | ulint | precise_mode, |
const buf_block_t * | block, | ||
ulint | heap_no, | ||
const trx_t * | trx | ||
) |
Checks if a transaction has a GRANTED explicit lock on rec stronger or equal to precise_mode.
precise_mode | in: LOCK_S or LOCK_X possibly ORed to LOCK_GAP or LOCK_REC_NOT_GAP, for a supremum record we regard this always a gap type request |
block | in: buffer block containing the record |
heap_no | in: heap number of the record |
trx | in: transaction |
Definition at line 1478 of file lock0lock.cc.
UNIV_INLINE ibool lock_rec_has_to_wait | ( | const trx_t * | trx, |
ulint | type_mode, | ||
const lock_t * | lock2, | ||
ibool | lock_is_on_supremum | ||
) |
Checks if a lock request for a new lock has to wait for request lock2.
trx | in: trx of new lock |
type_mode | in: precise mode of the new lock to set: LOCK_S or LOCK_X, possibly ORed to LOCK_GAP or LOCK_REC_NOT_GAP, LOCK_INSERT_INTENTION |
lock2 | in: another record lock; NOTE that it is assumed that this has a lock bit set on the same record as in the new lock we are setting |
lock_is_on_supremum | in: TRUE if we are setting the lock on the 'supremum' record of an index page: we know then that the lock request is really for a 'gap' type lock |
Definition at line 951 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_rec_insert_check_and_lock | ( | ulint | flags, |
const rec_t * | rec, | ||
buf_block_t * | block, | ||
dict_index_t * | index, | ||
que_thr_t * | thr, | ||
mtr_t * | mtr, | ||
ibool * | inherit | ||
) |
Checks if locks of other transactions prevent an immediate insert of a record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a gap x-lock to the lock queue.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
rec | in: record after which to insert |
block | in/out: buffer block of rec |
index | in: index |
thr | in: query thread |
mtr | in/out: mini-transaction |
inherit | out: set to TRUE if the new inserted record maybe should inherit LOCK_GAP type locks from the successor record |
Definition at line 5881 of file lock0lock.cc.
UNIV_INLINE enum lock_rec_req_status lock_rec_lock_fast | ( | ibool | impl, |
ulint | mode, | ||
const buf_block_t * | block, | ||
ulint | heap_no, | ||
dict_index_t * | index, | ||
que_thr_t * | thr | ||
) |
This is a fast routine for locking a record in the most common cases: there are no explicit locks on the page, or there is just one lock, owned by this transaction, and of the right type_mode. This is a low-level function which does NOT look at implicit locks! Checks lock compatibility within explicit locks. This function sets a normal next-key lock, or in the case of a page supremum record, a gap type lock.
impl | in: if TRUE, no lock is set if no wait is necessary: we assume that the caller will set an implicit lock |
mode | in: lock mode: LOCK_X or LOCK_S possibly ORed to either LOCK_GAP or LOCK_REC_NOT_GAP |
block | in: buffer block containing the record |
heap_no | in: heap number of record |
index | in: index of record |
thr | in: query thread |
Definition at line 2087 of file lock0lock.cc.
UNIV_INTERN void lock_rec_print | ( | FILE * | file, |
const lock_t * | lock | ||
) |
Prints info of a record lock.
file | in: file where to print |
lock | in: record type lock |
Definition at line 5005 of file lock0lock.cc.
UNIV_INTERN void lock_rec_reset_and_inherit_gap_locks | ( | const buf_block_t * | heir_block, |
const buf_block_t * | block, | ||
ulint | heir_heap_no, | ||
ulint | heap_no | ||
) |
Resets the original locks on heir and replaces them with gap type locks inherited from rec.
heir_block | in: block containing the record which inherits |
block | in: block containing the record from which inherited; does NOT reset the locks on this record |
heir_heap_no | in: heap_no of the inheriting record |
heap_no | in: heap_no of the donating record |
Definition at line 3268 of file lock0lock.cc.
UNIV_INLINE void lock_rec_reset_nth_bit | ( | lock_t * | lock, |
ulint | i | ||
) |
Resets the nth bit of a record lock.
lock | in: record lock |
i | in: index of the bit which must be set to TRUE when this function is called |
Definition at line 1129 of file lock0lock.cc.
UNIV_INTERN void lock_rec_restore_from_page_infimum | ( | const buf_block_t * | block, |
const rec_t * | rec, | ||
const buf_block_t * | donator | ||
) |
Restores the state of explicit lock requests on a single record, where the state was stored on the infimum of the page.
block | in: buffer block containing rec |
rec | in: record whose lock state is restored |
donator | in: page (rec is not necessarily on this page) whose infimum stored the lock state; lock bits are reset on the infimum |
Definition at line 3458 of file lock0lock.cc.
UNIV_INLINE void lock_rec_set_nth_bit | ( | lock_t * | lock, |
ulint | i | ||
) |
Sets the nth bit of a record lock to TRUE.
lock | in: record lock |
i | in: index of the bit |
Definition at line 1083 of file lock0lock.cc.
UNIV_INTERN void lock_rec_store_on_page_infimum | ( | const buf_block_t * | block, |
const rec_t * | rec | ||
) |
Stores on the page infimum record the explicit locks of another record. This function is used to store the lock state of a record when it is updated and the size of the record changes in the update. The record is moved in such an update, perhaps to another page. The infimum record acts as a dummy carrier record, taking care of lock releases while the actual record is being moved.
block | in: buffer block containing rec |
rec | in: record whose lock state is stored on the infimum record of the same page; lock bits are reset on the record |
Definition at line 3433 of file lock0lock.cc.
UNIV_INTERN void lock_rec_unlock | ( | trx_t * | trx, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
enum lock_mode lock_mode | |||
) |
Removes a granted record lock of a transaction from the queue and grants locks to other transactions waiting in the queue if they now are entitled to a lock.
trx | in/out: transaction that has set a record lock |
block | in: buffer block containing rec |
rec | in: record |
Definition at line 4541 of file lock0lock.cc.
UNIV_INLINE void lock_release_autoinc_last_lock | ( | ib_vector_t * | autoinc_locks | ) |
Release the last lock from the transaction's autoinc locks.
autoinc_locks | in/out: vector of AUTOINC locks |
Definition at line 6436 of file lock0lock.cc.
UNIV_INTERN void lock_remove_all_on_table | ( | dict_table_t * | table, |
ibool | remove_also_table_sx_locks | ||
) |
Removes locks on a table to be dropped or truncated. If remove_also_table_sx_locks is TRUE then table-level S and X locks are also removed in addition to other table-level and record-level locks. No lock, that is going to be removed, is allowed to be a wait lock.
table | in: table to be dropped or truncated |
remove_also_table_sx_locks | in: also removes table S and X locks |
Definition at line 4891 of file lock0lock.cc.
UNIV_INTERN void lock_report_trx_id_insanity | ( | trx_id_t | trx_id, |
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
trx_id_t | max_trx_id | ||
) |
Reports that a transaction id is insensible, i.e., in the future.
trx_id | in: trx id |
rec | in: user record |
index | in: index |
offsets | in: rec_get_offsets(rec, index) |
max_trx_id | in: trx_sys_get_max_trx_id() |
Definition at line 466 of file lock0lock.cc.
UNIV_INLINE void lock_reset_lock_and_trx_wait | ( | lock_t * | lock | ) |
The back pointer to a waiting lock request in the transaction is set to NULL and the wait bit in lock type_mode is reset.
lock | in/out: record lock |
Definition at line 852 of file lock0lock.cc.
UNIV_INTERN bool lock_sec_rec_cons_read_sees | ( | const rec_t * | rec, |
const read_view_t * | view | ||
) |
Checks that a non-clustered index record is seen in a consistent read.
NOTE that a non-clustered index page contains so little information on its modifications that also in the case false, the present version of rec may be the right, but we must check this from the clustered index record.
rec | in: user record which should be read or passed over by a read cursor |
view | in: consistent read view |
Definition at line 560 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_sec_rec_modify_check_and_lock | ( | ulint | flags, |
buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
que_thr_t * | thr, | ||
mtr_t * | mtr | ||
) |
Checks if locks of other transactions prevent an immediate modify (delete mark or delete unmark) of a secondary index record.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in/out: buffer block of rec |
rec | in: record which should be modified; NOTE: as this is a secondary index, we always have to modify the clustered index record first: see the comment below |
index | in: secondary index |
thr | in: query thread (can be NULL if BTR_NO_LOCKING_FLAG) |
mtr | in/out: mini-transaction |
Definition at line 6157 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_sec_rec_read_check_and_lock | ( | ulint | flags, |
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
enum lock_mode | mode, | ||
ulint | gap_mode, | ||
que_thr_t * | thr | ||
) |
Like lock_clust_rec_read_check_and_lock(), but reads a secondary index record.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
block | in: buffer block of rec |
rec | in: user record or page supremum record which should be read or passed over by a read cursor |
index | in: secondary index |
offsets | in: rec_get_offsets(rec, index) |
mode | in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE |
gap_mode | in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP |
thr | in: query thread |
Definition at line 6242 of file lock0lock.cc.
Sets the wait flag of a lock and the back pointer in trx to lock.
lock | in: lock |
trx | in/out: trx |
Definition at line 832 of file lock0lock.cc.
UNIV_INTERN void lock_sys_close | ( | void | ) |
Closes the lock system at database shutdown.
Definition at line 628 of file lock0lock.cc.
UNIV_INTERN void lock_sys_create | ( | ulint | n_cells | ) |
Creates the lock system at database start.
n_cells | in: number of slots in lock hash table |
Definition at line 589 of file lock0lock.cc.
UNIV_INTERN dberr_t lock_table | ( | ulint | flags, |
dict_table_t * | table, | ||
enum lock_mode | mode, | ||
que_thr_t * | thr | ||
) |
Locks the specified database table in the mode given. If the lock cannot be granted immediately, the query thread is put to wait.
flags | in: if BTR_NO_LOCKING_FLAG bit is set, does nothing |
table | in/out: database table in dictionary cache |
mode | in: lock mode |
thr | in: query thread |
Definition at line 4372 of file lock0lock.cc.
UNIV_INLINE lock_t* lock_table_create | ( | dict_table_t * | table, |
ulint | type_mode, | ||
trx_t * | trx | ||
) |
Creates a table lock object and adds it as the last in the lock queue of the table. Does NOT check for deadlocks or lock compatibility.
table | in/out: database table in dictionary cache |
type_mode | in: lock mode possibly ORed with LOCK_WAIT |
trx | in: trx |
Definition at line 4040 of file lock0lock.cc.
UNIV_INTERN ulint lock_table_get_n_locks | ( | const dict_table_t * | table | ) |
Get the number of locks on a table.
table | in: table |
Definition at line 6897 of file lock0lock.cc.
UNIV_INLINE const lock_t* lock_table_has | ( | const trx_t * | trx, |
const dict_table_t * | table, | ||
enum lock_mode | mode | ||
) |
Checks if a transaction has the specified table lock, or stronger. This function should only be called by the thread that owns the transaction.
trx | in: transaction |
table | in: table |
mode | in: lock mode |
Definition at line 1427 of file lock0lock.cc.
UNIV_INTERN ibool lock_table_has_locks | ( | const dict_table_t * | table | ) |
Check if there are any locks (table or rec) against table.
table | in: check if there are any locks held on records in this table or on the table itself |
Definition at line 6971 of file lock0lock.cc.
UNIV_INTERN void lock_table_ix_resurrect | ( | dict_table_t * | table, |
trx_t * | trx | ||
) |
Creates a table IX lock object for a resurrected transaction.
table | in/out: table |
trx | in/out: transaction |
Definition at line 4440 of file lock0lock.cc.
UNIV_INLINE const lock_t* lock_table_other_has_incompatible | ( | const trx_t * | trx, |
ulint | wait, | ||
const dict_table_t * | table, | ||
enum lock_mode | mode | ||
) |
Checks if other transactions have an incompatible mode lock request in the lock queue.
trx | in: transaction, or NULL if all transactions should be included |
wait | in: LOCK_WAIT if also waiting locks are taken into account, or 0 if not |
table | in: table |
mode | in: lock mode |
Definition at line 4337 of file lock0lock.cc.
UNIV_INLINE void lock_table_pop_autoinc_locks | ( | trx_t * | trx | ) |
Pops autoinc lock requests from the transaction's autoinc_locks. We handle the case where there are gaps in the array and they need to be popped off the stack.
trx | in/out: transaction that owns the AUTOINC locks |
Definition at line 4107 of file lock0lock.cc.
UNIV_INTERN void lock_table_print | ( | FILE * | file, |
const lock_t * | lock | ||
) |
Prints info of a table lock.
file | in: file where to print |
lock | in: table type lock |
Definition at line 4966 of file lock0lock.cc.
Removes an autoinc lock request from the transaction's autoinc_locks.
lock | in: table lock |
trx | in/out: transaction that owns the lock |
Definition at line 4131 of file lock0lock.cc.
UNIV_INLINE void lock_table_remove_low | ( | lock_t * | lock | ) |
Removes a table lock request from the queue and the trx list of locks; this is a low-level function which does NOT check if waiting requests can now be granted.
lock | in/out: table lock |
Definition at line 4184 of file lock0lock.cc.
Check whether the transaction has already been rolled back because it was selected as a deadlock victim, or if it has to wait then cancel the wait lock.
trx | in/out: trx lock state |
Definition at line 6866 of file lock0lock.cc.
UNIV_INTERN void lock_trx_release_locks | ( | trx_t * | trx | ) |
Releases a transaction's locks, and releases possible other transactions waiting because of these locks. Change the state of the transaction to TRX_STATE_COMMITTED_IN_MEMORY.
trx | in/out: transaction |
Definition at line 6797 of file lock0lock.cc.
UNIV_INTERN void lock_unlock_table_autoinc | ( | trx_t * | trx | ) |
Unlocks AUTO_INC type locks that were possibly reserved by a trx. This function should be called at the the end of an SQL statement, by the connection thread that owns the transaction (trx->mysql_thd).
trx | in/out: transaction |
Definition at line 6766 of file lock0lock.cc.
UNIV_INTERN void lock_update_copy_and_discard | ( | const buf_block_t * | new_block, |
const buf_block_t * | block | ||
) |
Updates the lock table when a page is copied to another and the original page is removed from the chain of leaf pages, except if page is the root!
new_block | in: index page to which copied |
block | in: index page; NOT the root! |
Definition at line 3173 of file lock0lock.cc.
UNIV_INTERN void lock_update_delete | ( | const buf_block_t * | block, |
const rec_t * | rec | ||
) |
Updates the lock table when a record is removed.
block | in: buffer block containing rec |
rec | in: the record to be removed |
Definition at line 3388 of file lock0lock.cc.
UNIV_INTERN void lock_update_discard | ( | const buf_block_t * | heir_block, |
ulint | heir_heap_no, | ||
const buf_block_t * | block | ||
) |
Updates the lock table when a page is discarded.
heir_block | in: index page which will inherit the locks |
heir_heap_no | in: heap_no of the record which will inherit the locks |
block | in: index page which will be discarded |
Definition at line 3294 of file lock0lock.cc.
UNIV_INTERN void lock_update_insert | ( | const buf_block_t * | block, |
const rec_t * | rec | ||
) |
Updates the lock table when a new user record is inserted.
block | in: buffer block containing rec |
rec | in: the inserted record |
Definition at line 3357 of file lock0lock.cc.
UNIV_INTERN void lock_update_merge_left | ( | const buf_block_t * | left_block, |
const rec_t * | orig_pred, | ||
const buf_block_t * | right_block | ||
) |
Updates the lock table when a page is merged to the left.
left_block | in: left page to which merged |
orig_pred | in: original predecessor of supremum on the left page before merge |
right_block | in: merged index page which will be discarded |
Definition at line 3218 of file lock0lock.cc.
UNIV_INTERN void lock_update_merge_right | ( | const buf_block_t * | right_block, |
const rec_t * | orig_succ, | ||
const buf_block_t * | left_block | ||
) |
Updates the lock table when a page is merged to the right.
right_block | in: right page to which merged |
orig_succ | in: original successor of infimum on the right page before merge |
left_block | in: merged index page which will be discarded |
Definition at line 3111 of file lock0lock.cc.
UNIV_INTERN void lock_update_root_raise | ( | const buf_block_t * | block, |
const buf_block_t * | root | ||
) |
Updates the lock table when the root page is copied to another in btr_root_raise_and_insert. Note that we leave lock structs on the root page, even though they do not make sense on other than leaf pages: the reason is that in a pessimistic update the infimum record of the root page will act as a dummy carrier of the locks of the record to be updated.
block | in: index page to which copied |
root | in: root page |
Definition at line 3153 of file lock0lock.cc.
UNIV_INTERN void lock_update_split_left | ( | const buf_block_t * | right_block, |
const buf_block_t * | left_block | ||
) |
Updates the lock table when a page is split to the left.
right_block | in: right page |
left_block | in: left page |
Definition at line 3196 of file lock0lock.cc.
UNIV_INTERN void lock_update_split_right | ( | const buf_block_t * | right_block, |
const buf_block_t * | left_block | ||
) |
Updates the lock table when a page is split to the right.
right_block | in: right page |
left_block | in: left page |
Definition at line 3083 of file lock0lock.cc.
const rec_t dict_index_t* index |
in: index
Definition at line 500 of file lock0lock.cc.
is_ok = trx_id < max_trx_id |
< in: rec_get_offsets(rec, index)
Definition at line 500 of file lock0lock.cc.
UNIV_INTERN ibool lock_deadlock_found = FALSE |
We store info on the latest deadlock error to this buffer. InnoDB
Monitor will then fetch it and print
Definition at line 418 of file lock0lock.cc.
UNIV_INTERN lock_sys_t* lock_sys = NULL |
The lock system
Definition at line 414 of file lock0lock.cc.
const rec_t* rec |
< in: trx id in: user record
Definition at line 500 of file lock0lock.cc.