CUBRID Engine  latest
lock_manager.h File Reference
#include "config.h"
#include "error_manager.h"
#include "locator.h"
#include "log_comm.h"
#include "oid.h"
#include "storage_common.h"
#include "thread_compat.hpp"
#include <time.h>
#include <stdio.h>
Include dependency graph for lock_manager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  lk_entry
 
struct  lk_acqobj_lock
 
struct  lk_acquired_locks
 
struct  lk_lockcomp_class
 
struct  lk_lockcomp
 
struct  lk_composite_lock
 
struct  lk_res_key
 
struct  lk_res
 

Typedefs

typedef struct lk_entry LK_ENTRY
 
typedef struct lk_acqobj_lock LK_ACQOBJ_LOCK
 
typedef struct lk_acquired_locks LK_ACQUIRED_LOCKS
 
typedef struct lk_lockcomp_class LK_LOCKCOMP_CLASS
 
typedef struct lk_lockcomp LK_LOCKCOMP
 
typedef struct lk_composite_lock LK_COMPOSITE_LOCK
 
typedef struct lk_res_key LK_RES_KEY
 
typedef struct lk_res LK_RES
 

Enumerations

enum  {
  LK_GRANTED = 1, LK_NOTGRANTED = 2, LK_NOTGRANTED_DUE_ABORTED = 3, LK_NOTGRANTED_DUE_TIMEOUT = 4,
  LK_NOTGRANTED_DUE_ERROR = 5, LK_GRANTED_PUSHINSET_LOCKONE = 6, LK_GRANTED_PUSHINSET_RELOCKALL = 7
}
 
enum  { LK_ZERO_WAIT = 0, LK_INFINITE_WAIT = -1, LK_FORCE_ZERO_WAIT = -2 }
 
enum  { LK_UNCOND_LOCK, LK_COND_LOCK }
 
enum  KEY_LOCK_ESCALATION { NO_KEY_LOCK_ESCALATION = 0, NEED_KEY_LOCK_ESCALATION = 1, KEY_LOCK_ESCALATED = 2 }
 
enum  LOCK_RESOURCE_TYPE { LOCK_RESOURCE_INSTANCE, LOCK_RESOURCE_CLASS, LOCK_RESOURCE_ROOT_CLASS, LOCK_RESOURCE_OBJECT }
 

Functions

int lock_initialize (void)
 
void lock_finalize (void)
 
int lock_hold_object_instant (THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock)
 
int lock_object_wait_msecs (THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int cond_flag, int wait_msecs)
 
int lock_object (THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int cond_flag)
 
int lock_subclass (THREAD_ENTRY *thread_p, const OID *subclass_oid, const OID *superclass_oid, LOCK lock, int cond_flag)
 
int lock_object_with_btid (THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, const BTID *btid, LOCK lock, int cond_flag)
 
int lock_scan (THREAD_ENTRY *thread_p, const OID *class_oid, int cond_flag, LOCK class_lock)
 
int lock_classes_lock_hint (THREAD_ENTRY *thread_p, LC_LOCKHINT *lockhint)
 
void lock_remove_object_lock (THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock)
 
void lock_unlock_object_donot_move_to_non2pl (THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock)
 
void lock_unlock_object (THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, bool force)
 
void lock_unlock_objects_lock_set (THREAD_ENTRY *thread_p, LC_LOCKSET *lockset)
 
void lock_unlock_classes_lock_hint (THREAD_ENTRY *thread_p, LC_LOCKHINT *lockhint)
 
void lock_unlock_all (THREAD_ENTRY *thread_p)
 
LOCK lock_get_object_lock (const OID *oid, const OID *class_oid)
 
bool lock_has_xlock (THREAD_ENTRY *thread_p)
 
bool lock_is_waiting_transaction (int tran_index)
 
LK_ENTRYlock_get_class_lock (THREAD_ENTRY *thread_p, const OID *class_oid)
 
void lock_notify_isolation_incons (THREAD_ENTRY *thread_p, bool(*fun)(const OID *class_oid, const OID *oid, void *args), void *args)
 
int lock_reacquire_crash_locks (THREAD_ENTRY *thread_p, LK_ACQUIRED_LOCKS *acqlocks, int tran_index)
 
void lock_unlock_all_shared_get_all_exclusive (THREAD_ENTRY *thread_p, LK_ACQUIRED_LOCKS *acqlocks)
 
void lock_dump_acquired (FILE *fp, LK_ACQUIRED_LOCKS *acqlocks)
 
void lock_start_instant_lock_mode (int tran_index)
 
void lock_stop_instant_lock_mode (THREAD_ENTRY *thread_p, int tran_index, bool need_unlock)
 
bool lock_is_instant_lock_mode (int tran_index)
 
void lock_clear_deadlock_victim (int tran_index)
 
unsigned int lock_get_number_object_locks (void)
 
int lock_initialize_composite_lock (THREAD_ENTRY *thread_p, LK_COMPOSITE_LOCK *comp_lock)
 
int lock_add_composite_lock (THREAD_ENTRY *thread_p, LK_COMPOSITE_LOCK *comp_lock, const OID *oid, const OID *class_oid)
 
int lock_finalize_composite_lock (THREAD_ENTRY *thread_p, LK_COMPOSITE_LOCK *comp_lock)
 
void lock_abort_composite_lock (LK_COMPOSITE_LOCK *comp_lock)
 
int lock_get_lock_holder_tran_index (THREAD_ENTRY *thread_p, char **out_buf, int waiter_index, LK_RES *res)
 
int lock_has_lock_on_object (const OID *oid, const OID *class_oid, LOCK lock)
 
int lock_rep_read_tran (THREAD_ENTRY *thread_p, LOCK lock, int cond_flag)
 
int lock_demote_class_lock (THREAD_ENTRY *thread_p, const OID *oid, LOCK lock, LOCK *ex_lock)
 
void lock_demote_read_class_lock_for_checksumdb (THREAD_ENTRY *thread_p, int tran_index, const OID *class_oid)
 
const char * lock_wait_state_to_string (int state)
 
void lock_force_thread_timeout_lock (THREAD_ENTRY *thread_p)
 

Typedef Documentation

Definition at line 103 of file lock_manager.h.

Definition at line 111 of file lock_manager.h.

Definition at line 145 of file lock_manager.h.

typedef struct lk_entry LK_ENTRY

Definition at line 78 of file lock_manager.h.

typedef struct lk_lockcomp LK_LOCKCOMP

Definition at line 136 of file lock_manager.h.

Definition at line 125 of file lock_manager.h.

typedef struct lk_res LK_RES

Definition at line 174 of file lock_manager.h.

typedef struct lk_res_key LK_RES_KEY

Definition at line 163 of file lock_manager.h.

Enumeration Type Documentation

anonymous enum
Enumerator
LK_GRANTED 
LK_NOTGRANTED 
LK_NOTGRANTED_DUE_ABORTED 
LK_NOTGRANTED_DUE_TIMEOUT 
LK_NOTGRANTED_DUE_ERROR 
LK_GRANTED_PUSHINSET_LOCKONE 
LK_GRANTED_PUSHINSET_RELOCKALL 

Definition at line 44 of file lock_manager.h.

anonymous enum
Enumerator
LK_ZERO_WAIT 
LK_INFINITE_WAIT 
LK_FORCE_ZERO_WAIT 

Definition at line 55 of file lock_manager.h.

anonymous enum
Enumerator
LK_UNCOND_LOCK 
LK_COND_LOCK 

Definition at line 65 of file lock_manager.h.

Enumerator
NO_KEY_LOCK_ESCALATION 
NEED_KEY_LOCK_ESCALATION 
KEY_LOCK_ESCALATED 

Definition at line 68 of file lock_manager.h.

Enumerator
LOCK_RESOURCE_INSTANCE 
LOCK_RESOURCE_CLASS 
LOCK_RESOURCE_ROOT_CLASS 
LOCK_RESOURCE_OBJECT 

Definition at line 152 of file lock_manager.h.

Function Documentation

void lock_clear_deadlock_victim ( int  tran_index)

Definition at line 8967 of file lock_manager.c.

References pthread_mutex_lock, pthread_mutex_unlock, rv, and TRAN_NORMAL.

Referenced by lock_unlock_all(), and qexec_execute_selupd_list().

Here is the caller graph for this function:

int lock_demote_class_lock ( THREAD_ENTRY thread_p,
const OID oid,
LOCK  lock,
LOCK ex_lock 
)

Definition at line 4169 of file lock_manager.c.

References ARG_FILE_LINE, assert, assert_release, lk_res_key::class_oid, COPY_OID, cubregex::count(), CTIME_MAX, CUB_MAXHOSTNAMELEN, er_clear(), er_errid(), ER_ERROR_SEVERITY, ER_FAILED, ER_INTERRUPTED, ER_LK_DEADLOCK_CYCLE_DETECTED, ER_LK_NOTFOUND_IN_LOCK_HOLDER_LIST, er_log_debug, ER_NOTIFICATION_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), free_and_init, heap_get_class_name(), heap_get_visible_version(), heap_scancache_end(), heap_scancache_quick_start(), lk_res::holder, i, INCON_NON_TWO_PHASE_LOCK, IS_LOCK, IX_LOCK, lk_res::key, lock_Comp, LOCK_COMPAT_NO, LOCK_COMPAT_UNKNOWN, lock_Conv, lock_demote_read_class_lock_for_checksumdb(), lock_find_tran_hold_entry(), LOCK_RESOURCE_CLASS, LOCK_RESOURCE_INSTANCE, LOCK_RESOURCE_ROOT_CLASS, LOCK_TO_LOCKMODE_STRING, LOG_FIND_THREAD_TRAN_INDEX, log_state_string(), LOG_USERNAME_MAX, logtb_find_client_name_host_pid(), logtb_find_log_records_count(), logtb_find_state(), logtb_find_tranid(), logtb_find_wait_msecs(), logtb_has_deadlock_priority(), logtb_is_active(), MSGCAT_CATALOG_CUBRID, MSGCAT_LK_DEADLOCK_ABORT, MSGCAT_LK_DEADLOCK_ABORT_HDR, MSGCAT_LK_DEADLOCK_TIMEOUT, MSGCAT_LK_DEADLOCK_TIMEOUT_HDR, MSGCAT_LK_MVCC_INFO, MSGCAT_LK_NEWLINE, MSGCAT_LK_RES_BLOCKED_HOLDER_ENTRY, MSGCAT_LK_RES_BLOCKED_HOLDER_ENTRY_WITH_GRANULE, MSGCAT_LK_RES_BLOCKED_HOLDER_HEAD, MSGCAT_LK_RES_BLOCKED_WAITER_ENTRY, MSGCAT_LK_RES_BLOCKED_WAITER_HEAD, MSGCAT_LK_RES_CLASS_TYPE, MSGCAT_LK_RES_INSTANCE_TYPE, MSGCAT_LK_RES_LOCK_COUNT, MSGCAT_LK_RES_NON2PL_RELEASED_ENTRY, MSGCAT_LK_RES_NON2PL_RELEASED_HEAD, MSGCAT_LK_RES_NON_BLOCKED_HOLDER_ENTRY, MSGCAT_LK_RES_NON_BLOCKED_HOLDER_ENTRY_WITH_GRANULE, MSGCAT_LK_RES_NON_BLOCKED_HOLDER_HEAD, MSGCAT_LK_RES_OID, MSGCAT_LK_RES_ROOT_CLASS_TYPE, MSGCAT_LK_RES_RR_TYPE, MSGCAT_LK_RES_TOTAL_MODE, MSGCAT_LK_RES_UNKNOWN_TYPE, msgcat_message(), MSGCAT_SET_LOCK, MVCC_GET_DELID, MVCC_GET_INSID, MVCC_IS_FLAG_SET, MVCC_IS_HEADER_DELID_VALID, NA_LOCK, NO_ERROR, lk_res::non2pl, NULL, NULL_CHN, NULL_LOCK, NULL_TRAN_INDEX, NULL_TRANID, lk_res_key::oid, OID_AS_ARGS, oid_compare(), OID_EQ, OID_GET_REAL_CLASS_OF_DIR_OID, oid_get_rep_read_tran_oid(), OID_IS_VIRTUAL_CLASS_OF_DIR_OID, OID_ISNULL, OID_ISTEMP, OR_MVCC_FLAG_VALID_INSID, or_mvcc_get_header(), db_identifier::pageid, PEEK, pthread_mutex_lock, pthread_mutex_unlock, RECDES_INITIALIZER, lk_res::res_mutex, rv, S_LOCK, S_SUCCESS, SIX_LOCK, db_identifier::slotid, strlen, thread_get_tran_entry(), THREAD_TS_OBJ_LOCK_ENT, lk_res::total_holders_mode, lk_res::total_waiters_mode, lk_res_key::type, U_LOCK, db_identifier::volid, lk_res::waiter, X_LOCK, and xlock_dump().

Referenced by xbtree_load_online_index(), and xlocator_demote_class_lock().

Here is the caller graph for this function:

void lock_demote_read_class_lock_for_checksumdb ( THREAD_ENTRY thread_p,
int  tran_index,
const OID class_oid 
)

Referenced by lock_demote_class_lock(), and xchksum_insert_repl_log_and_demote_table_lock().

Here is the caller graph for this function:

void lock_dump_acquired ( FILE *  fp,
LK_ACQUIRED_LOCKS acqlocks 
)
void lock_finalize ( void  )

Definition at line 5797 of file lock_manager.c.

References free_and_init, i, lf_freelist_destroy(), and pthread_mutex_destroy.

Referenced by lock_initialize(), and logtb_undefine_trantable().

Here is the caller graph for this function:

void lock_force_thread_timeout_lock ( THREAD_ENTRY thread_p)

Definition at line 7390 of file lock_manager.c.

References ARG_FILE_LINE, assert, ER_ERROR_SEVERITY, ER_LK_STRANGE_LOCK_WAIT, er_set(), LOCK_RESUMED_TIMEOUT, thread_lock_entry(), and thread_unlock_entry().

Referenced by css_stop_log_writer(), and css_stop_non_log_writer().

Here is the caller graph for this function:

int lock_get_lock_holder_tran_index ( THREAD_ENTRY thread_p,
char **  out_buf,
int  waiter_index,
LK_RES res 
)
unsigned int lock_get_number_object_locks ( void  )

Definition at line 8836 of file lock_manager.c.

Referenced by logpb_checkpoint().

Here is the caller graph for this function:

bool lock_has_xlock ( THREAD_ENTRY thread_p)

Definition at line 7181 of file lock_manager.c.

References IX_LOCK, lk_Standalone_has_xlock, LOG_FIND_THREAD_TRAN_INDEX, pthread_mutex_lock, pthread_mutex_unlock, rv, SCH_M_LOCK, SIX_LOCK, and X_LOCK.

Referenced by xtran_server_has_updated().

Here is the caller graph for this function:

int lock_hold_object_instant ( THREAD_ENTRY thread_p,
const OID oid,
const OID class_oid,
LOCK  lock 
)
int lock_initialize_composite_lock ( THREAD_ENTRY thread_p,
LK_COMPOSITE_LOCK comp_lock 
)
bool lock_is_instant_lock_mode ( int  tran_index)

Definition at line 8999 of file lock_manager.c.

References LOCK_RESOURCE_CLASS, and OID_IS_ROOTOID.

Referenced by qexec_execute_mainblock_internal(), and qexec_execute_selupd_list().

Here is the caller graph for this function:

bool lock_is_waiting_transaction ( int  tran_index)

Definition at line 7280 of file lock_manager.c.

References ARG_FILE_LINE, ER_LK_STRANGE_LOCK_WAIT, er_set(), ER_WARNING_SEVERITY, i, lock_get_transaction_lock_waiting_threads(), thread_lock_entry(), and thread_unlock_entry().

Referenced by xtran_is_blocked().

Here is the caller graph for this function:

int lock_object ( THREAD_ENTRY thread_p,
const OID oid,
const OID class_oid,
LOCK  lock,
int  cond_flag 
)

Definition at line 5904 of file lock_manager.c.

References ARG_FILE_LINE, assert, BU_LOCK, ER_ERROR_SEVERITY, ER_LK_BAD_ARGUMENT, er_log_debug, ER_MNT_WAITING_THREAD, ER_NOTIFICATION_SEVERITY, er_set(), if(), IS_LOCK, IX_LOCK, LK_COND_LOCK, LK_FORCE_ZERO_WAIT, LK_GRANTED, LK_NOTGRANTED, LK_NOTGRANTED_DUE_ERROR, LK_SET_STANDALONE_XLOCK, lock_get_class_lock(), lock_has_lock_on_object(), lock_is_class_lock_escalated(), lock_stop_instant_lock_mode(), LOG_FIND_THREAD_TRAN_INDEX, logtb_find_isolation(), logtb_find_wait_msecs(), MONITOR_WAITING_THREAD, NULL, NULL_LOCK, OID_IS_ROOTOID, oid_Root_class_oid, prm_get_integer_value(), PRM_ID_MNT_WAITING_THREAD, S_LOCK, SCH_S_LOCK, tsc_elapsed_time_usec(), tsc_getticks(), and TT_LOADDB.

Referenced by btree_check_by_class_oid(), btree_fk_object_does_exist(), btree_key_find_and_lock_unique_of_non_unique(), btree_load_check_fk(), btree_repair_prev_link_by_class_oid(), catalog_check_consistency(), catalog_get_cardinality_by_name(), catalog_start_access_with_dir_oid(), catcls_delete_instance(), file_tracker_get_and_protect(), heap_compact_pages(), heap_get_insert_location_with_lock(), heap_insert_logical(), locator_add_or_remove_index_internal(), locator_check_all_entries_of_all_btrees(), locator_check_by_class_oid(), locator_lock_and_get_object_internal(), locator_repair_btree_by_delete(), locator_repair_btree_by_insert(), locator_update_force(), locator_update_index(), lock_object_wait_msecs(), qexec_execute_insert(), qexec_for_update_set_class_locks(), qexec_set_class_locks(), scan_next_heap_scan(), scan_next_index_lookup_heap(), xboot_checkdb_table(), xbtree_find_unique(), xbtree_load_online_index(), xcache_find_xasl_id_for_execute(), xlocator_delete_class_name(), xlocator_fetch_all(), xlocator_fetch_lockhint_classes(), xlocator_find_class_oid(), xlocator_find_lockhint_class_oids(), xlocator_get_class(), xlocator_lock_and_fetch_all(), xlocator_reserve_class_name(), xserial_get_next_value(), xstats_get_statistics_from_server(), and xstats_update_statistics().

int lock_object_wait_msecs ( THREAD_ENTRY thread_p,
const OID oid,
const OID class_oid,
LOCK  lock,
int  cond_flag,
int  wait_msecs 
)

Definition at line 6238 of file lock_manager.c.

References LK_GRANTED, LK_SET_STANDALONE_XLOCK, lock_object(), and xlogtb_reset_wait_msecs().

Referenced by boot_compact_db(), and xlocator_lock_and_fetch_all().

Here is the caller graph for this function:

int lock_object_with_btid ( THREAD_ENTRY thread_p,
const OID oid,
const OID class_oid,
const BTID btid,
LOCK  lock,
int  cond_flag 
)
int lock_reacquire_crash_locks ( THREAD_ENTRY thread_p,
LK_ACQUIRED_LOCKS acqlocks,
int  tran_index 
)
void lock_remove_object_lock ( THREAD_ENTRY thread_p,
const OID oid,
const OID class_oid,
LOCK  lock 
)

Definition at line 6599 of file lock_manager.c.

References lock_unlock_object_lock_internal().

void lock_start_instant_lock_mode ( int  tran_index)

Definition at line 8853 of file lock_manager.c.

Referenced by qexec_execute_mainblock_internal(), and qexec_execute_selupd_list().

Here is the caller graph for this function:

void lock_stop_instant_lock_mode ( THREAD_ENTRY thread_p,
int  tran_index,
bool  need_unlock 
)

Definition at line 8875 of file lock_manager.c.

References assert, assert_release, and cubregex::count().

Referenced by lock_object(), qexec_execute_mainblock_internal(), and qexec_execute_selupd_list().

Here is the caller graph for this function:

void lock_unlock_all ( THREAD_ENTRY thread_p)

Definition at line 6837 of file lock_manager.c.

References assert, INCON_NON_TWO_PHASE_LOCK, lock_clear_deadlock_victim(), LOG_FIND_THREAD_TRAN_INDEX, and pgbuf_unfix_all().

Referenced by log_abort_local(), log_commit_local(), and log_complete_for_2pc().

Here is the caller graph for this function: