54 #if defined(ENABLE_SYSTEMTAP) 75 #if defined (SERVER_MODE) 77 #define LK_OBJ_LOCK_HASH(oid,htsize) \ 78 ((OID_ISTEMP(oid)) ? (unsigned int)(-((oid)->pageid) % htsize) :\ 79 lock_get_hash_value(oid, htsize)) 82 #define LK_IS_LOCKWAIT_THREAD(thrd) \ 83 ((thrd)->lockwait != NULL \ 84 && (thrd)->lockwait_state == (int) LOCK_SUSPENDED) 87 #define LK_CAN_TIMEOUT(msecs) ((msecs) != LK_INFINITE_WAIT) 90 #define LK_ISYOUNGER(young_tranid, old_tranid) (young_tranid > old_tranid) 93 #define LK_MSG_LOCK_HELPER(entry, msgnum) \ 95 msgcat_message (MSGCAT_CATALOG_CUBRID, MSGCAT_SET_LOCK, msgnum)), \ 96 (entry)->tran_index, LOCK_TO_LOCKMODE_STRING((entry)->granted_mode), \ 97 (entry)->res_head->oid->volid, (entry)->res_head->oid->pageid, \ 100 #define LK_MSG_LOCK_ACQUIRED(entry) \ 101 LK_MSG_LOCK_HELPER(entry, MSGCAT_LK_OID_LOCK_ACQUIRED) 103 #define LK_MSG_LOCK_CONVERTED(entry) \ 104 LK_MSG_LOCK_HELPER(entry, MSGCAT_LK_OID_LOCK_CONVERTED) 106 #define LK_MSG_LOCK_WAITFOR(entry) \ 107 LK_MSG_LOCK_HELPER(entry, MSGCAT_LK_OID_LOCK_WAITFOR) 109 #define LK_MSG_LOCK_RELEASE(entry) \ 110 LK_MSG_LOCK_HELPER(entry, MSGCAT_LK_OID_LOCK_RELEASE) 112 #define LK_MSG_LOCK_DEMOTE(entry) \ 113 LK_MSG_LOCK_HELPER(entry, MSGCAT_LK_OID_LOCK_DEMOTE) 115 #define EXPAND_WAIT_FOR_ARRAY_IF_NEEDED() \ 118 if (nwaits == max_waits) \ 120 if (wait_for == wait_for_buf) \ 122 t = (int *) malloc (sizeof (int) * max_waits * 2); \ 125 memcpy (t, wait_for, sizeof (int) * max_waits); \ 130 t = (int *) realloc (wait_for, sizeof (int) * max_waits * 2); \ 145 #define SET_EMULATE_THREAD_WITH_LOCK_ENTRY(th,lock_entry) \ 148 THREAD_ENTRY *locked_thread_entry_p; \ 149 assert ((th)->emulate_tid == thread_id_t ()); \ 150 locked_thread_entry_p = logtb_find_thread_by_tran_index ((lock_entry)->tran_index); \ 151 if (locked_thread_entry_p != NULL) \ 153 (th)->emulate_tid = locked_thread_entry_p->get_id (); \ 158 #define CLEAR_EMULATE_THREAD(th) \ 161 (th)->emulate_tid = thread_id_t (); \ 167 #define RESOURCE_ALLOC_WAIT_TIME 10 168 #define KEY_LOCK_ESCALATION_THRESHOLD 10 169 #define MAX_NUM_LOCKS_DUMP_TO_EVENT_LOG 100 189 #define MSGCAT_LK_NEWLINE 1 190 #define MSGCAT_LK_SUSPEND_TRAN 2 191 #define MSGCAT_LK_RESUME_TRAN 3 192 #define MSGCAT_LK_OID_LOCK_ACQUIRED 4 193 #define MSGCAT_LK_VPID_LOCK_ACQUIRED 5 194 #define MSGCAT_LK_OID_LOCK_CONVERTED 6 195 #define MSGCAT_LK_VPID_LOCK_CONVERTED 7 196 #define MSGCAT_LK_OID_LOCK_WAITFOR 8 197 #define MSGCAT_LK_VPID_LOCK_WAITFOR 9 198 #define MSGCAT_LK_OID_LOCK_RELEASE 10 199 #define MSGCAT_LK_VPID_LOCK_RELEASE 11 200 #define MSGCAT_LK_OID_LOCK_DEMOTE 12 201 #define MSGCAT_LK_VPID_LOCK_DEMOTE 13 202 #define MSGCAT_LK_RES_OID 14 203 #define MSGCAT_LK_RES_ROOT_CLASS_TYPE 15 204 #define MSGCAT_LK_RES_CLASS_TYPE 16 205 #define MSGCAT_LK_RES_INSTANCE_TYPE 17 206 #define MSGCAT_LK_RES_UNKNOWN_TYPE 18 207 #define MSGCAT_LK_RES_TOTAL_MODE 19 208 #define MSGCAT_LK_RES_LOCK_COUNT 20 209 #define MSGCAT_LK_RES_NON_BLOCKED_HOLDER_HEAD 21 210 #define MSGCAT_LK_RES_BLOCKED_HOLDER_HEAD 22 211 #define MSGCAT_LK_RES_BLOCKED_WAITER_HEAD 23 212 #define MSGCAT_LK_RES_NON2PL_RELEASED_HEAD 24 213 #define MSGCAT_LK_RES_NON_BLOCKED_HOLDER_ENTRY 25 214 #define MSGCAT_LK_RES_NON_BLOCKED_HOLDER_ENTRY_WITH_GRANULE 26 215 #define MSGCAT_LK_RES_BLOCKED_HOLDER_ENTRY 27 216 #define MSGCAT_LK_RES_BLOCKED_HOLDER_ENTRY_WITH_GRANULE 28 217 #define MSGCAT_LK_RES_BLOCKED_WAITER_ENTRY 29 218 #define MSGCAT_LK_RES_NON2PL_RELEASED_ENTRY 30 219 #define MSGCAT_LK_RES_VPID 31 220 #define MSGCAT_LK_DUMP_LOCK_TABLE 32 221 #define MSGCAT_LK_DUMP_TRAN_IDENTIFIERS 33 222 #define MSGCAT_LK_DUMP_TRAN_ISOLATION 34 223 #define MSGCAT_LK_DUMP_TRAN_STATE 35 224 #define MSGCAT_LK_DUMP_TRAN_TIMEOUT_PERIOD 36 225 #define MSGCAT_LK_DEADLOCK_ABORT_HDR 37 226 #define MSGCAT_LK_DEADLOCK_ABORT 38 227 #define MSGCAT_LK_DEADLOCK_TIMEOUT_HDR 39 228 #define MSGCAT_LK_DEADLOCK_TIMEOUT 40 229 #define MSGCAT_LK_DEADLOCK_FUN_HDR 41 230 #define MSGCAT_LK_DEADLOCK_FUN 42 231 #define MSGCAT_LK_RES_INDEX_KEY_TYPE 43 232 #define MSGCAT_LK_INDEXNAME 44 233 #define MSGCAT_LK_RES_RR_TYPE 45 234 #define MSGCAT_LK_MVCC_INFO 46 235 #define MSGCAT_LK_LASTONE 47 237 #if defined(SERVER_MODE) 239 typedef struct lk_lockinfo LK_LOCKINFO;
250 typedef struct lk_WFG_node LK_WFG_NODE;
257 INT64 thrd_wait_stime;
258 int tran_edge_seq_num;
259 bool checked_by_deadlock_detector;
263 typedef struct lk_WFG_edge LK_WFG_EDGE;
270 INT64 edge_wait_stime;
273 typedef struct lk_deadlock_victim LK_DEADLOCK_VICTIM;
274 struct lk_deadlock_victim
277 int (*cycle_fun) (
int tran_index,
void *args);
284 int num_trans_in_cycle;
285 int *tran_index_in_cycle;
291 typedef struct lk_entry_block LK_ENTRY_BLOCK;
292 struct lk_entry_block
294 LK_ENTRY_BLOCK *next_block;
302 typedef struct lk_res_block LK_RES_BLOCK;
305 LK_RES_BLOCK *next_block;
313 typedef struct lk_tran_lock LK_TRAN_LOCK;
317 pthread_mutex_t hold_mutex;
322 int lk_entry_pool_count;
324 int class_hold_count;
329 pthread_mutex_t non2pl_mutex;
331 int num_incons_non2pl;
334 bool lock_escalation_on;
337 bool is_instant_duration;
340 #define LOCK_TRAN_LOCAL_POOL_MAX_SIZE 10 347 using lk_hashmap_iterator = lk_hashmap_type::iterator;
350 typedef struct lk_global_data LK_GLOBAL_DATA;
351 struct lk_global_data
356 lk_hashmap_type m_obj_hash_table;
361 LK_TRAN_LOCK *tran_lock_table;
364 pthread_mutex_t DL_detection_mutex;
365 struct timeval last_deadlock_run;
366 LK_WFG_NODE *TWFG_node;
367 LK_WFG_EDGE *TWFG_edge;
369 int TWFG_free_edge_idx;
370 int global_edge_seq_num;
373 short no_victim_case_count;
376 std::atomic_int deadlock_and_timeout_detector;
385 , m_obj_hash_table {}
388 , tran_lock_table (
NULL)
389 , DL_detection_mutex PTHREAD_MUTEX_INITIALIZER
390 , last_deadlock_run { 0, 0 }
394 , TWFG_free_edge_idx (0)
395 , global_edge_seq_num (0)
396 , no_victim_case_count (0)
397 , verbose_mode (
false)
398 , deadlock_and_timeout_detector { 0 }
407 LK_GLOBAL_DATA lk_Gl;
410 static const int SIZEOF_LK_LOCKINFO =
sizeof (LK_LOCKINFO);
411 static const int SIZEOF_LK_WFG_NODE =
sizeof (LK_WFG_NODE);
412 static const int SIZEOF_LK_WFG_EDGE =
sizeof (LK_WFG_EDGE);
413 static const int SIZEOF_LK_TRAN_LOCK =
sizeof (LK_TRAN_LOCK);
415 static const int SIZEOF_LK_RES =
sizeof (
LK_RES);
416 static const int SIZEOF_LK_ENTRY_BLOCK =
sizeof (LK_ENTRY_BLOCK);
417 static const int SIZEOF_LK_RES_BLOCK =
sizeof (LK_RES_BLOCK);
422 #define LK_MIN_OBJECT_LOCKS (MAX_NTRANS * 300) 425 static const float LK_RES_RATIO = 0.1f;
426 static const float LK_ENTRY_RATIO = 0.1f;
430 #define LK_MORE_RES_COUNT (MAX_NTRANS * 20 * LK_RES_RATIO) 431 #define LK_MORE_ENTRY_COUNT (MAX_NTRANS * 20 * LK_ENTRY_RATIO) 434 static const int LK_SLEEP_MAX_COUNT = 3;
435 #define LK_LOCKINFO_FIXED_COUNT 30 437 #define LK_MAX_VICTIM_COUNT 300 440 static const int LK_MIN_TWFG_EDGE_COUNT = 200;
442 #define LK_MID_TWFG_EDGE_COUNT 1000 444 #define LK_MAX_TWFG_EDGE_COUNT (MAX_NTRANS * MAX_NTRANS) 446 #define DEFAULT_WAIT_USERS 10 447 static const int LK_COMPOSITE_LOCK_OID_INCREMENT = 100;
450 #if defined(SERVER_MODE) 452 static LK_WFG_EDGE TWFG_edge_block[LK_MID_TWFG_EDGE_COUNT];
453 static LK_DEADLOCK_VICTIM victims[LK_MAX_VICTIM_COUNT];
454 static int victim_count;
457 #define LK_SET_STANDALONE_XLOCK(lock) \ 459 if ((lock) == SCH_M_LOCK || (lock) == X_LOCK || lock == IX_LOCK \ 460 || lock == SIX_LOCK) \ 462 lk_Standalone_has_xlock = true; \ 472 #if defined(SERVER_MODE) 473 static void lock_initialize_entry (
LK_ENTRY * entry_ptr);
474 static void lock_initialize_entry_as_granted (
LK_ENTRY * entry_ptr,
int tran_index,
LK_RES * res,
LOCK lock);
475 static void lock_initialize_entry_as_blocked (
LK_ENTRY * entry_ptr,
THREAD_ENTRY * thread_p,
int tran_index,
477 static void lock_initialize_entry_as_non2pl (
LK_ENTRY * entry_ptr,
int tran_index,
LK_RES * res,
LOCK lock);
478 static void lock_initialize_resource (
LK_RES * res_ptr);
479 static void lock_initialize_resource_as_allocated (
LK_RES * res_ptr,
LOCK lock);
480 static unsigned int lock_get_hash_value (
const OID * oid,
int htsize);
481 static int lock_initialize_tran_lock_table (
void);
482 static void lock_initialize_object_hash_table (
void);
483 static int lock_initialize_object_lock_entry_list (
void);
484 static int lock_initialize_deadlock_detection (
void);
486 static void lock_insert_into_tran_hold_list (
LK_ENTRY * entry_ptr,
int owner_tran_index);
487 static int lock_delete_from_tran_hold_list (
LK_ENTRY * entry_ptr,
int owner_tran_index);
488 static void lock_insert_into_tran_non2pl_list (
LK_ENTRY * non2pl,
int owner_tran_index);
489 static int lock_delete_from_tran_non2pl_list (
LK_ENTRY * non2pl,
int owner_tran_index);
496 static void lock_position_holder_entry (
LK_RES * res_ptr,
LK_ENTRY * entry_ptr);
498 static void lock_set_error_for_aborted (
LK_ENTRY * entry_ptr);
499 static void lock_set_tran_abort_reason (
int tran_index,
TRAN_ABORT_REASON abort_reason);
501 static void lock_resume (
LK_ENTRY * entry_ptr,
int state);
502 static bool lock_wakeup_deadlock_victim_timeout (
int tran_index);
503 static bool lock_wakeup_deadlock_victim_aborted (
int tran_index);
507 static bool lock_check_escalate (
THREAD_ENTRY * thread_p,
LK_ENTRY * class_entry, LK_TRAN_LOCK * tran_lock);
508 static int lock_escalate_if_needed (
THREAD_ENTRY * thread_p,
LK_ENTRY * class_entry,
int tran_index);
509 static int lock_internal_hold_lock_object_instant (
THREAD_ENTRY * thread_p,
int tran_index,
const OID * oid,
510 const OID * class_oid,
LOCK lock);
511 static int lock_internal_perform_lock_object (
THREAD_ENTRY * thread_p,
int tran_index,
const OID * oid,
512 const OID * class_oid,
LOCK lock,
int wait_msecs,
514 static void lock_internal_perform_unlock_object (
THREAD_ENTRY * thread_p,
LK_ENTRY * entry_ptr,
bool release_flag,
515 bool move_to_non2pl);
517 const OID * class_oid,
const OID * oid);
518 static void lock_unlock_inst_locks_of_class_by_isolation (
THREAD_ENTRY * thread_p,
int tran_index,
522 static void lock_demote_all_shared_class_locks (
THREAD_ENTRY * thread_p,
int tran_index);
523 static void lock_unlock_shared_inst_lock (
THREAD_ENTRY * thread_p,
int tran_index,
const OID * inst_oid);
524 static void lock_remove_all_class_locks (
THREAD_ENTRY * thread_p,
int tran_index,
LOCK lock);
526 static void lock_update_non2pl_list (
THREAD_ENTRY * thread_p,
LK_RES * res_ptr,
int tran_index,
LOCK lock);
527 static int lock_add_WFG_edge (
int from_tran_index,
int to_tran_index,
int holder_flag, INT64 edge_wait_stime);
528 static void lock_select_deadlock_victim (
THREAD_ENTRY * thread_p,
int s,
int t);
529 static void lock_dump_deadlock_victims (
THREAD_ENTRY * thread_p, FILE * outfile);
530 static int lock_compare_lock_info (
const void *lockinfo1,
const void *lockinfo2);
531 static float lock_wait_msecs_to_secs (
int msecs);
532 static void lock_dump_resource (
THREAD_ENTRY * thread_p, FILE * outfp,
LK_RES * res_ptr);
534 static void lock_increment_class_granules (
LK_ENTRY * class_entry);
536 static void lock_decrement_class_granules (
LK_ENTRY * class_entry);
537 static LK_ENTRY *lock_find_class_entry (
int tran_index,
const OID * class_oid);
539 static void lock_event_log_tran_locks (
THREAD_ENTRY * thread_p, FILE *
log_fp,
int tran_index);
543 static void lock_event_set_tran_wait_entry (
int tran_index,
LK_ENTRY * entry);
544 static void lock_event_set_xasl_id_to_entry (
int tran_index,
LK_ENTRY * entry);
546 #if defined (SERVER_MODE) 554 static void lock_check_timeout_expired_and_count_suspended_mapfunc (
THREAD_ENTRY & thread_ref,
bool & stop_mapper,
555 size_t & suspend_count);
566 static void lock_deadlock_detect_daemon_init ();
567 static void lock_deadlock_detect_daemon_destroy ();
571 static void *lock_alloc_entry (
void);
572 static int lock_dealloc_entry (
void *res);
573 static int lock_init_entry (
void *res);
574 static int lock_uninit_entry (
void *res);
596 static void *lock_alloc_resource (
void);
597 static int lock_dealloc_resource (
void *res);
598 static int lock_init_resource (
void *res);
599 static int lock_uninit_resource (
void *res);
600 static int lock_res_key_copy (
void *src,
void *dest);
601 static int lock_res_key_compare (
void *k1,
void *k2);
602 static unsigned int lock_res_key_hash (
void *key,
int htsize);
606 offsetof (
LK_RES, hash_next),
607 offsetof (
LK_RES, del_id),
609 offsetof (
LK_RES, res_mutex),
612 lock_dealloc_resource,
614 lock_uninit_resource,
616 lock_res_key_compare,
622 #if defined(SERVER_MODE) 624 lock_create_search_key (
OID * oid,
OID * class_oid)
638 if (class_oid != NULL)
669 lock_alloc_entry (
void)
675 lock_dealloc_entry (
void *res)
682 lock_init_entry (
void *entry)
685 if (entry_ptr != NULL)
697 lock_uninit_entry (
void *entry)
701 if (entry_ptr == NULL)
706 entry_ptr->tran_index = -1;
707 entry_ptr->thrd_entry =
NULL;
725 lock_alloc_resource (
void)
736 lock_dealloc_resource (
void *res)
753 lock_init_resource (
void *res)
773 lock_uninit_resource (
void *res)
792 lock_res_key_copy (
void *src,
void *dest)
797 if (src_k == NULL || dest_k == NULL)
829 lock_res_key_compare (
void *k1,
void *k2)
834 if (k1_k == NULL || k2_k == NULL)
869 lock_res_key_hash (
void *key,
int htsize)
875 return LK_OBJ_LOCK_HASH (&key_k->
oid, htsize);
886 lock_initialize_entry (
LK_ENTRY * entry_ptr)
888 entry_ptr->tran_index = -1;
889 entry_ptr->thrd_entry =
NULL;
890 entry_ptr->res_head =
NULL;
893 entry_ptr->next =
NULL;
894 entry_ptr->tran_next =
NULL;
895 entry_ptr->tran_prev =
NULL;
896 entry_ptr->class_entry =
NULL;
897 entry_ptr->ngranules = 0;
898 entry_ptr->instant_lock_count = 0;
899 entry_ptr->bind_index_in_tran = -1;
905 lock_initialize_entry_as_granted (
LK_ENTRY * entry_ptr,
int tran_index,
LK_RES * res,
LOCK lock)
907 entry_ptr->tran_index = tran_index;
908 entry_ptr->thrd_entry =
NULL;
909 entry_ptr->res_head = res;
910 entry_ptr->granted_mode = lock;
912 entry_ptr->count = 1;
913 entry_ptr->next =
NULL;
914 entry_ptr->tran_next =
NULL;
915 entry_ptr->tran_prev =
NULL;
916 entry_ptr->class_entry =
NULL;
917 entry_ptr->ngranules = 0;
918 entry_ptr->instant_lock_count = 0;
920 lock_event_set_xasl_id_to_entry (tran_index, entry_ptr);
928 entry_ptr->tran_index = tran_index;
929 entry_ptr->thrd_entry = thread_p;
930 entry_ptr->res_head = res;
932 entry_ptr->blocked_mode = lock;
933 entry_ptr->count = 1;
934 entry_ptr->next =
NULL;
935 entry_ptr->tran_next =
NULL;
936 entry_ptr->tran_prev =
NULL;
937 entry_ptr->class_entry =
NULL;
938 entry_ptr->ngranules = 0;
939 entry_ptr->instant_lock_count = 0;
941 lock_event_set_xasl_id_to_entry (tran_index, entry_ptr);
946 lock_initialize_entry_as_non2pl (
LK_ENTRY * entry_ptr,
int tran_index,
LK_RES * res,
LOCK lock)
948 entry_ptr->tran_index = tran_index;
949 entry_ptr->thrd_entry =
NULL;
950 entry_ptr->res_head = res;
951 entry_ptr->granted_mode = lock;
953 entry_ptr->count = 0;
954 entry_ptr->next =
NULL;
955 entry_ptr->tran_next =
NULL;
956 entry_ptr->tran_prev =
NULL;
957 entry_ptr->class_entry =
NULL;
958 entry_ptr->ngranules = 0;
959 entry_ptr->instant_lock_count = 0;
964 lock_initialize_resource (
LK_RES * res_ptr)
980 lock_initialize_resource_as_allocated (
LK_RES * res_ptr,
LOCK lock)
997 lock_get_hash_value (
const OID * oid,
int htsize)
999 unsigned int next_base_slotid, addr;
1010 next_base_slotid = 2;
1011 while (next_base_slotid <= (
unsigned) oid->
slotid)
1013 next_base_slotid = next_base_slotid * 2;
1016 addr = oid->
pageid + (htsize / next_base_slotid) * (2 * oid->
slotid - next_base_slotid + 1);
1019 return (addr % htsize);
1033 #if defined(SERVER_MODE) 1043 lock_initialize_tran_lock_table (
void)
1045 LK_TRAN_LOCK *tran_lock;
1053 lk_Gl.tran_lock_table = (LK_TRAN_LOCK *) malloc (SIZEOF_LK_TRAN_LOCK * lk_Gl.num_trans);
1054 if (lk_Gl.tran_lock_table == NULL)
1057 (
size_t) (SIZEOF_LK_TRAN_LOCK * lk_Gl.num_trans));
1062 memset (lk_Gl.tran_lock_table, 0, SIZEOF_LK_TRAN_LOCK * lk_Gl.num_trans);
1063 for (i = 0; i < lk_Gl.num_trans; i++)
1065 tran_lock = &lk_Gl.tran_lock_table[
i];
1069 for (j = 0; j < LOCK_TRAN_LOCAL_POOL_MAX_SIZE; j++)
1072 lock_initialize_entry (entry);
1073 entry->next = tran_lock->lk_entry_pool;
1074 tran_lock->lk_entry_pool = entry;
1076 tran_lock->lk_entry_pool_count = LOCK_TRAN_LOCAL_POOL_MAX_SIZE;
1083 #if defined(SERVER_MODE) 1092 lock_initialize_object_hash_table (
void)
1094 #define LK_INITIAL_OBJECT_LOCK_TABLE_SIZE 10000 1096 lk_Gl.max_obj_locks = LK_INITIAL_OBJECT_LOCK_TABLE_SIZE;
1098 const int obj_hash_size = MAX (lk_Gl.max_obj_locks, LK_MIN_OBJECT_LOCKS);
1100 const int block_count = 2;
1101 const int block_size = (int) MAX ((lk_Gl.max_obj_locks * LK_RES_RATIO) / block_count, 1);
1105 lk_Obj_lock_res_desc);
1109 #if defined(SERVER_MODE) 1122 lock_initialize_object_lock_entry_list (
void)
1124 int block_count, block_size, ret;
1128 block_size = (int) MAX ((lk_Gl.max_obj_locks * LK_ENTRY_RATIO), 1);
1139 #if defined(SERVER_MODE) 1148 lock_initialize_deadlock_detection (
void)
1153 gettimeofday (&lk_Gl.last_deadlock_run, NULL);
1156 lk_Gl.TWFG_node = (LK_WFG_NODE *) malloc (SIZEOF_LK_WFG_NODE * lk_Gl.num_trans);
1157 if (lk_Gl.TWFG_node == NULL)
1160 (
size_t) (SIZEOF_LK_WFG_NODE * lk_Gl.num_trans));
1164 for (i = 0; i < lk_Gl.num_trans; i++)
1166 lk_Gl.TWFG_node[
i].DL_victim =
false;
1167 lk_Gl.TWFG_node[
i].checked_by_deadlock_detector =
false;
1168 lk_Gl.TWFG_node[
i].thrd_wait_stime = 0;
1172 lk_Gl.TWFG_edge =
NULL;
1173 lk_Gl.max_TWFG_edge = 0;
1174 lk_Gl.TWFG_free_edge_idx = -1;
1175 lk_Gl.global_edge_seq_num = 0;
1181 #if defined(SERVER_MODE) 1194 assert (res_ptr != NULL);
1196 if (!lk_Gl.m_obj_hash_table.erase_locked (thread_p, res_ptr->
key, res_ptr))
1219 #if defined(SERVER_MODE) 1233 lock_insert_into_tran_hold_list (
LK_ENTRY * entry_ptr,
int owner_tran_index)
1235 LK_TRAN_LOCK *tran_lock;
1240 if (owner_tran_index != entry_ptr->tran_index)
1242 assert (owner_tran_index == entry_ptr->tran_index);
1246 tran_lock = &lk_Gl.tran_lock_table[entry_ptr->tran_index];
1249 switch (entry_ptr->res_head->key.type)
1252 #if defined(CUBRID_DEBUG) 1253 if (tran_lock->root_class_hold != NULL)
1255 fprintf (stderr,
"lk_insert_into_tran_hold_list() error.. (1)\n");
1258 entry_ptr->tran_next = tran_lock->root_class_hold;
1259 tran_lock->root_class_hold = entry_ptr;
1263 #if defined(CUBRID_DEBUG) 1264 if (tran_lock->class_hold_list != NULL)
1267 _ptr = tran_lock->class_hold_list;
1268 while (_ptr != NULL)
1270 if (_ptr->res_head == entry_ptr->res_head)
1274 _ptr = _ptr->tran_next;
1278 fprintf (stderr,
"lk_insert_into_tran_hold_list() error.. (2)\n");
1282 if (tran_lock->class_hold_list != NULL)
1284 tran_lock->class_hold_list->tran_prev = entry_ptr;
1286 entry_ptr->tran_next = tran_lock->class_hold_list;
1287 tran_lock->class_hold_list = entry_ptr;
1288 tran_lock->class_hold_count++;
1292 #if defined(CUBRID_DEBUG) 1293 if (tran_lock->inst_hold_list != NULL)
1296 _ptr = tran_lock->inst_hold_list;
1297 while (_ptr != NULL)
1299 if (_ptr->res_head == entry_ptr->res_head)
1303 _ptr = _ptr->tran_next;
1307 fprintf (stderr,
"lk_insert_into_tran_hold_list() error.. (3)\n");
1311 if (tran_lock->inst_hold_list != NULL)
1313 tran_lock->inst_hold_list->tran_prev = entry_ptr;
1315 entry_ptr->tran_next = tran_lock->inst_hold_list;
1316 tran_lock->inst_hold_list = entry_ptr;
1317 tran_lock->inst_hold_count++;
1328 #if defined(SERVER_MODE) 1341 lock_delete_from_tran_hold_list (
LK_ENTRY * entry_ptr,
int owner_tran_index)
1343 LK_TRAN_LOCK *tran_lock;
1349 if (owner_tran_index != entry_ptr->tran_index)
1351 assert (owner_tran_index == entry_ptr->tran_index);
1355 tran_lock = &lk_Gl.tran_lock_table[entry_ptr->tran_index];
1358 switch (entry_ptr->res_head->key.type)
1361 if (entry_ptr != tran_lock->root_class_hold)
1365 entry_ptr->res_head->key.oid.pageid, entry_ptr->res_head->key.oid.slotid, entry_ptr->tran_index,
1366 (tran_lock->root_class_hold == NULL ? 0 : 1));
1371 tran_lock->root_class_hold =
NULL;
1376 if (tran_lock->class_hold_list == entry_ptr)
1378 tran_lock->class_hold_list = entry_ptr->tran_next;
1379 if (entry_ptr->tran_next)
1381 entry_ptr->tran_next->tran_prev =
NULL;
1386 if (entry_ptr->tran_prev)
1388 entry_ptr->tran_prev->tran_next = entry_ptr->tran_next;
1390 if (entry_ptr->tran_next)
1392 entry_ptr->tran_next->tran_prev = entry_ptr->tran_prev;
1395 tran_lock->class_hold_count--;
1399 if (tran_lock->inst_hold_list == entry_ptr)
1401 tran_lock->inst_hold_list = entry_ptr->tran_next;
1402 if (entry_ptr->tran_next)
1404 entry_ptr->tran_next->tran_prev =
NULL;
1409 if (entry_ptr->tran_prev)
1411 entry_ptr->tran_prev->tran_next = entry_ptr->tran_next;
1413 if (entry_ptr->tran_next)
1415 entry_ptr->tran_next->tran_prev = entry_ptr->tran_prev;
1418 tran_lock->inst_hold_count--;
1423 entry_ptr->res_head->key.oid.volid, entry_ptr->res_head->key.oid.pageid,
1424 entry_ptr->res_head->key.oid.slotid);
1435 #if defined(SERVER_MODE) 1448 lock_insert_into_tran_non2pl_list (
LK_ENTRY * non2pl,
int owner_tran_index)
1450 LK_TRAN_LOCK *tran_lock;
1455 if (owner_tran_index != non2pl->tran_index)
1457 assert (owner_tran_index == non2pl->tran_index);
1461 tran_lock = &lk_Gl.tran_lock_table[non2pl->tran_index];
1464 non2pl->tran_next = tran_lock->non2pl_list;
1465 tran_lock->non2pl_list = non2pl;
1468 tran_lock->num_incons_non2pl += 1;
1475 #if defined(SERVER_MODE) 1488 lock_delete_from_tran_non2pl_list (
LK_ENTRY * non2pl,
int owner_tran_index)
1490 LK_TRAN_LOCK *tran_lock;
1497 if (owner_tran_index != non2pl->tran_index)
1499 assert (owner_tran_index == non2pl->tran_index);
1503 tran_lock = &lk_Gl.tran_lock_table[non2pl->tran_index];
1508 curr = tran_lock->non2pl_list;
1509 while (curr != NULL && curr != non2pl)
1512 curr = curr->tran_next;
1518 (non2pl->res_head != NULL ? non2pl->res_head->key.oid.volid : -2),
1519 (non2pl->res_head != NULL ? non2pl->res_head->key.oid.pageid : -2),
1520 (non2pl->res_head != NULL ? non2pl->res_head->key.oid.slotid : -2), non2pl->tran_index);
1528 tran_lock->non2pl_list = curr->tran_next;
1532 prev->tran_next = curr->tran_next;
1537 tran_lock->num_incons_non2pl -= 1;
1552 #if defined(SERVER_MODE) 1566 lock_find_class_entry (
int tran_index,
const OID * class_oid)
1568 LK_TRAN_LOCK *tran_lock;
1574 tran_lock = &lk_Gl.tran_lock_table[tran_index];
1579 entry_ptr = tran_lock->root_class_hold;
1583 entry_ptr = tran_lock->class_hold_list;
1584 while (entry_ptr != NULL)
1586 assert (tran_index == entry_ptr->tran_index);
1588 if (
OID_EQ (&entry_ptr->res_head->key.oid, class_oid))
1592 entry_ptr = entry_ptr->tran_next;
1602 #if defined(SERVER_MODE) 1621 LK_TRAN_LOCK *tran_lock;
1630 non2pl = res_ptr->
non2pl;
1631 while (non2pl != NULL)
1633 if (non2pl->tran_index == tran_index)
1637 non2pl = non2pl->next;
1644 tran_lock = &lk_Gl.tran_lock_table[tran_index];
1652 tran_lock->num_incons_non2pl += 1;
1657 compat =
lock_Comp[lock][non2pl->granted_mode];
1663 tran_lock->num_incons_non2pl += 1;
1667 non2pl->granted_mode =
lock_Conv[lock][non2pl->granted_mode];
1679 non2pl = lock_get_new_entry (tran_index, t_entry, &lk_Gl.obj_free_entry_list);
1682 lock_initialize_entry_as_non2pl (non2pl, tran_index, res_ptr, lock);
1683 non2pl->next = res_ptr->
non2pl;
1684 res_ptr->
non2pl = non2pl;
1685 lock_insert_into_tran_non2pl_list (non2pl, tran_index);
1696 #if defined(SERVER_MODE) 1714 lock_position_holder_entry (
LK_RES * res_ptr,
LK_ENTRY * entry_ptr)
1723 if (entry_ptr->blocked_mode ==
NULL_LOCK)
1742 ta = tb = tc =
NULL;
1743 tap = tbp = tcp =
NULL;
1754 compat1 =
lock_Comp[entry_ptr->blocked_mode][i->blocked_mode];
1763 compat1 =
lock_Comp[entry_ptr->blocked_mode][i->granted_mode];
1766 compat2 =
lock_Comp[i->blocked_mode][entry_ptr->granted_mode];
1790 else if (tb != NULL)
1794 else if (tc != NULL)
1803 entry_ptr->next = res_ptr->
holder;
1804 res_ptr->
holder = entry_ptr;
1808 entry_ptr->next = prev->next;
1809 prev->next = entry_ptr;
1825 #if defined(SERVER_MODE) 1838 const char *client_prog_name;
1839 const char *client_user_name;
1840 const char *client_host_name;
1842 char *waitfor_client_users_default = (
char *)
"";
1843 char *waitfor_client_users;
1845 int n,
i, nwaits, max_waits = DEFAULT_WAIT_USERS;
1846 int wait_for_buf[DEFAULT_WAIT_USERS];
1847 int *wait_for = wait_for_buf, *t;
1853 bool is_classname_alloced =
false;
1854 bool free_mutex_flag =
false;
1855 bool isdeadlock_timeout =
false;
1856 int compat1, compat2;
1860 waitfor_client_users = waitfor_client_users_default;
1866 res_ptr = entry_ptr->res_head;
1870 free_mutex_flag =
true;
1871 for (entry = res_ptr->
holder; entry != NULL; entry = entry->next)
1873 if (entry == entry_ptr)
1879 compat1 =
lock_Comp[entry->granted_mode][entry_ptr->blocked_mode];
1880 compat2 =
lock_Comp[entry->blocked_mode][entry_ptr->blocked_mode];
1885 EXPAND_WAIT_FOR_ARRAY_IF_NEEDED ();
1886 wait_for[nwaits++] = entry->tran_index;
1890 for (entry = res_ptr->
waiter; entry != NULL; entry = entry->next)
1892 if (entry == entry_ptr)
1898 compat1 =
lock_Comp[entry->blocked_mode][entry_ptr->blocked_mode];
1903 EXPAND_WAIT_FOR_ARRAY_IF_NEEDED ();
1904 wait_for[nwaits++] = entry->tran_index;
1909 free_mutex_flag =
false;
1911 if (nwaits == 0 || (waitfor_client_users = (
char *) malloc (unit_size * nwaits)) == NULL)
1913 waitfor_client_users = waitfor_client_users_default;
1917 for (ptr = waitfor_client_users, i = 0; i < nwaits; i++)
1921 n = sprintf (ptr,
"%s%s@%s|%s(%d)", ((i == 0) ?
"" :
", "), client_user_name, client_host_name,
1922 client_prog_name, client_pid);
1929 if (wait_for != wait_for_buf)
1934 if (free_mutex_flag)
1937 free_mutex_flag =
false;
1942 &client_host_name, &client_pid);
1944 if (entry_ptr->thrd_entry != NULL
1948 isdeadlock_timeout =
true;
1951 switch (entry_ptr->res_head->key.type)
1956 if (oid_rr != NULL &&
OID_EQ (&entry_ptr->res_head->key.oid, oid_rr))
1958 classname = (
char *)
"Generic object for Repeatable Read consistency";
1959 is_classname_alloced =
false;
1961 else if (
OID_ISTEMP (&entry_ptr->res_head->key.oid))
1976 COPY_OID (&real_class_oid, &entry_ptr->res_head->key.oid);
1983 else if (classname != NULL)
1985 is_classname_alloced =
true;
1989 if (classname != NULL)
1993 entry_ptr->tran_index, client_user_name, client_host_name, client_pid,
1995 if (is_classname_alloced)
2004 entry_ptr->tran_index, client_user_name, client_host_name, client_pid,
2006 entry_ptr->res_head->key.oid.pageid, entry_ptr->res_head->key.oid.slotid, waitfor_client_users);
2011 if (
OID_ISTEMP (&entry_ptr->res_head->key.class_oid))
2024 COPY_OID (&real_class_oid, &entry_ptr->res_head->key.class_oid);
2033 if (classname != NULL)
2037 entry_ptr->tran_index, client_user_name, client_host_name, client_pid,
2039 entry_ptr->res_head->key.oid.pageid, entry_ptr->res_head->key.oid.slotid, classname,
2040 waitfor_client_users);
2047 entry_ptr->tran_index, client_user_name, client_host_name, client_pid,
2049 entry_ptr->res_head->key.oid.pageid, entry_ptr->res_head->key.oid.slotid, waitfor_client_users);
2056 if (waitfor_client_users && waitfor_client_users != waitfor_client_users_default)
2061 if (isdeadlock_timeout ==
false)
2071 lock_event_log_blocked_lock (thread_p, log_fp, entry_ptr);
2072 lock_event_log_blocking_locks (thread_p, log_fp, entry_ptr);
2079 #if defined(SERVER_MODE) 2108 lock_set_error_for_aborted (
LK_ENTRY * entry_ptr)
2110 const char *client_prog_name;
2111 const char *client_user_name;
2112 const char *client_host_name;
2116 &client_host_name, &client_pid);
2118 client_host_name, client_pid);
2122 #if defined(SERVER_MODE) 2144 if (lk_Gl.verbose_mode)
2146 const char *__client_prog_name;
2147 const char *__client_user_name;
2148 const char *__client_host_name;
2154 &__client_host_name, &__client_pid);
2156 entry_ptr->thrd_entry->index, entry_ptr->tran_index, __client_prog_name, __client_user_name,
2157 __client_host_name, __client_pid);
2162 entry_ptr->thrd_entry->lockwait = (
void *) entry_ptr;
2163 gettimeofday (&tv, NULL);
2164 entry_ptr->thrd_entry->lockwait_stime = (tv.tv_sec * 1000000LL + tv.tv_usec) / 1000LL;
2165 entry_ptr->thrd_entry->lockwait_msecs = wait_msecs;
2168 lk_Gl.TWFG_node[entry_ptr->tran_index].thrd_wait_stime = entry_ptr->thrd_entry->lockwait_stime;
2169 lk_Gl.deadlock_and_timeout_detector++;
2181 lock_event_set_tran_wait_entry (entry_ptr->tran_index, entry_ptr);
2186 lk_Gl.deadlock_and_timeout_detector--;
2187 lk_Gl.TWFG_node[entry_ptr->tran_index].thrd_wait_stime = 0;
2194 lock_event_set_tran_wait_entry (entry_ptr->tran_index, NULL);
2215 while (entry_ptr->thrd_entry->tran_next_wait)
2217 p = entry_ptr->thrd_entry->tran_next_wait;
2218 entry_ptr->thrd_entry->tran_next_wait = p->tran_next_wait;
2219 p->tran_next_wait =
NULL;
2241 lock_set_error_for_aborted (entry_ptr);
2282 (void) lock_set_error_for_timeout (thread_p, entry_ptr);
2286 (void) lock_set_error_for_timeout (thread_p, entry_ptr);
2293 (void) lock_set_error_for_timeout (thread_p, entry_ptr);
2303 (void) lock_set_error_for_timeout (thread_p, entry_ptr);
2309 #if defined(SERVER_MODE) 2319 lock_resume (
LK_ENTRY * entry_ptr,
int state)
2323 if (lk_Gl.verbose_mode ==
true)
2325 const char *__client_prog_name;
2326 const char *__client_user_name;
2327 const char *__client_host_name;
2333 &__client_host_name, &__client_pid);
2335 entry_ptr->tran_index, entry_ptr->tran_index, __client_prog_name, __client_user_name, __client_host_name,
2341 entry_ptr->thrd_entry->lockwait =
NULL;
2342 entry_ptr->thrd_entry->lockwait_state = (int) state;
2346 pthread_cond_signal (&entry_ptr->thrd_entry->wakeup_cond);
2351 #if defined(SERVER_MODE) 2367 lock_wakeup_deadlock_victim_timeout (
int tran_index)
2371 size_t thrd_count,
i;
2373 bool wakeup_first =
false;
2377 thrd_array = tran_lock_waiters.data ();
2379 for (i = 0; i < thrd_count; i++)
2381 thrd_ptr = thrd_array[
i];
2383 if (thrd_ptr->tran_index == tran_index && LK_IS_LOCKWAIT_THREAD (thrd_ptr))
2387 wakeup_first =
true;
2391 if (thrd_ptr->lockwait != NULL || thrd_ptr->lockwait_state == (
int)
LOCK_SUSPENDED)
2395 thrd_ptr->lockwait_state, thrd_ptr->index, thrd_ptr->get_posix_id (), thrd_ptr->tran_index);
2403 return wakeup_first;
2407 #if defined(SERVER_MODE) 2423 lock_wakeup_deadlock_victim_aborted (
int tran_index)
2427 size_t thrd_count,
i;
2429 bool wakeup_first =
false;
2433 thrd_array = tran_lock_waiters.data ();
2435 for (i = 0; i < thrd_count; i++)
2437 thrd_ptr = thrd_array[
i];
2439 if (thrd_ptr->tran_index == tran_index && LK_IS_LOCKWAIT_THREAD (thrd_ptr))
2442 if (wakeup_first ==
false)
2448 lk_Gl.TWFG_node[tran_index].DL_victim =
true;
2450 wakeup_first =
true;
2459 if (thrd_ptr->lockwait != NULL || thrd_ptr->lockwait_state == (
int)
LOCK_SUSPENDED)
2463 thrd_ptr->lockwait_state, thrd_ptr->index, thrd_ptr->get_posix_id (), thrd_ptr->tran_index);
2471 return wakeup_first;
2483 #if defined(SERVER_MODE) 2503 holder = res_ptr->
holder;
2504 while (holder != NULL && holder->blocked_mode !=
NULL_LOCK)
2508 for (h = holder->next; h != NULL; h = h->next)
2530 if (LK_IS_LOCKWAIT_THREAD (holder->thrd_entry))
2535 for (prev = holder, h = holder->next; h != NULL; prev = h, h = h->next)
2545 if (prev_holder == NULL)
2547 res_ptr->
holder = holder->next;
2551 prev_holder->next = holder->next;
2554 holder->next = prev->next;
2555 prev->next = holder;
2559 holder->granted_mode = holder->blocked_mode;
2563 lock_update_non2pl_list (thread_p, res_ptr, holder->tran_index, holder->granted_mode);
2567 #if defined(LK_TRACE_OBJECT) 2568 LK_MSG_LOCK_ACQUIRED (entry_ptr);
2575 if (holder->thrd_entry->lockwait != NULL || holder->thrd_entry->lockwait_state == (
int)
LOCK_SUSPENDED)
2579 holder->thrd_entry->lockwait_state, holder->thrd_entry->index,
2580 holder->thrd_entry->get_posix_id (), holder->thrd_entry->tran_index);
2586 prev_holder = holder;
2589 if (prev_holder == NULL)
2591 holder = res_ptr->
holder;
2595 holder = prev_holder->next;
2602 #if defined(SERVER_MODE) 2617 bool change_total_waiters_mode =
false;
2624 waiter = res_ptr->
waiter;
2625 while (waiter != NULL)
2641 if (LK_IS_LOCKWAIT_THREAD (waiter->thrd_entry))
2643 int owner_tran_index;
2646 change_total_waiters_mode =
true;
2649 if (prev_waiter == NULL)
2651 res_ptr->
waiter = waiter->next;
2655 prev_waiter->next = waiter->next;
2659 waiter->granted_mode = waiter->blocked_mode;
2663 lock_position_holder_entry (res_ptr, waiter);
2672 lock_insert_into_tran_hold_list (waiter, owner_tran_index);
2675 lock_update_non2pl_list (thread_p, res_ptr, waiter->tran_index, waiter->granted_mode);
2679 #if defined(LK_TRACE_OBJECT) 2680 LK_MSG_LOCK_ACQUIRED (entry_ptr);
2688 if (waiter->thrd_entry->lockwait != NULL || waiter->thrd_entry->lockwait_state == (
int)
LOCK_SUSPENDED)
2692 waiter->thrd_entry->lockwait_state, waiter->thrd_entry->index,
2693 waiter->thrd_entry->get_posix_id (), waiter->thrd_entry->tran_index);
2700 prev_waiter = waiter;
2703 if (prev_waiter == NULL)
2705 waiter = res_ptr->
waiter;
2709 waiter = prev_waiter->next;
2713 if (change_total_waiters_mode ==
true)
2716 for (w = res_ptr->
waiter; w != NULL; w = w->next)
2729 #if defined(SERVER_MODE) 2756 while (check != from_whom)
2763 check = check->next;
2767 while (check != NULL)
2789 check = check->next;
2795 if (LK_IS_LOCKWAIT_THREAD (check->thrd_entry))
2797 int owner_tran_index;
2801 if (prev_check == NULL)
2803 res_ptr->
waiter = check->next;
2807 prev_check->next = check->next;
2811 check->granted_mode = check->blocked_mode;
2815 lock_position_holder_entry (res_ptr, check);
2824 lock_insert_into_tran_hold_list (check, owner_tran_index);
2827 lock_update_non2pl_list (thread_p, res_ptr, check->tran_index, check->granted_mode);
2831 #if defined(LK_TRACE_OBJECT) 2832 LK_MSG_LOCK_ACQUIRED (entry_ptr);
2840 if (check->thrd_entry->lockwait != NULL || check->thrd_entry->lockwait_state == (
int) LOCK_SUSPENDED)
2844 check->thrd_entry->lockwait_state, check->thrd_entry->index, check->thrd_entry->get_posix_id (),
2845 check->thrd_entry->tran_index);
2860 if (prev_check == NULL)
2866 check = prev_check->next;
2877 for (i = res_ptr->
waiter; i != NULL; i = i->next)
2889 #if defined(SERVER_MODE) 2900 lock_check_escalate (
THREAD_ENTRY * thread_p,
LK_ENTRY * class_entry, LK_TRAN_LOCK * tran_lock)
2904 if (class_entry->granted_mode ==
BU_LOCK)
2910 if (tran_lock->lock_escalation_on ==
true)
2918 if (class_entry == NULL)
2923 superclass_entry = class_entry->class_entry;
2926 if (superclass_entry != NULL && !
OID_IS_ROOTOID (&superclass_entry->res_head->key.oid))
2964 LK_TRAN_LOCK *tran_lock;
2971 tran_lock = &lk_Gl.tran_lock_table[tran_index];
2974 if (lock_check_escalate (thread_p, class_entry, tran_lock) ==
false)
2986 lock_set_error_for_aborted (class_entry);
2994 tran_lock->lock_escalation_on =
true;
2996 if (class_entry->granted_mode ==
NULL_LOCK || class_entry->granted_mode ==
S_LOCK 2997 || class_entry->granted_mode ==
X_LOCK || class_entry->granted_mode ==
SCH_M_LOCK)
3000 tran_lock->lock_escalation_on =
false;
3009 if (class_entry->granted_mode ==
IX_LOCK || class_entry->granted_mode ==
SIX_LOCK)
3027 granted = lock_internal_perform_lock_object (thread_p, tran_index, &class_entry->res_head->key.oid, NULL,
3028 max_class_lock, wait_msecs, &class_entry, NULL);
3035 tran_lock->lock_escalation_on =
false;
3041 lock_internal_perform_unlock_object (thread_p, class_entry,
false,
true);
3046 tran_lock->lock_escalation_on =
false;
3061 #if defined(SERVER_MODE) 3075 lock_internal_hold_lock_object_instant (
THREAD_ENTRY * thread_p,
int tran_index,
const OID * oid,
const OID * class_oid,
3083 int compat1, compat2;
3085 #if defined(LK_DUMP) 3086 if (lk_Gl.dump_level >= 1)
3089 "LK_DUMP::lk_internal_lock_object_instant()\n" 3090 " tran(%2d) : oid(%2d|%3d|%3d), class_oid(%2d|%3d|%3d), LOCK(%7s)\n", tran_index, oid->
volid,
3107 search_key = lock_create_search_key ((
OID *) oid, (
OID *) class_oid);
3108 res_ptr = lk_Gl.m_obj_hash_table.find (thread_p, search_key);
3109 if (res_ptr == NULL)
3119 for (entry_ptr = res_ptr->
holder; entry_ptr != NULL; entry_ptr = entry_ptr->next)
3121 if (entry_ptr->tran_index == tran_index)
3128 if (entry_ptr == NULL)
3151 new_mode =
lock_Conv[lock][entry_ptr->granted_mode];
3154 if (new_mode == entry_ptr->granted_mode)
3164 for (i = res_ptr->
holder; i != NULL; i = i->next)
3169 group_mode =
lock_Conv[i->granted_mode][group_mode];
3175 compat1 =
lock_Comp[new_mode][group_mode];
3192 #if defined(SERVER_MODE) 3217 lock_internal_perform_lock_object (
THREAD_ENTRY * thread_p,
int tran_index,
const OID * oid,
const OID * class_oid,
3224 LOCK group_mode, old_mode, new_mode;
3229 bool lock_conversion =
false;
3231 LK_TRAN_LOCK *tran_lock;
3232 bool is_instant_duration;
3234 bool is_res_mutex_locked =
false;
3237 UINT64 lock_wait_time;
3239 #if defined(ENABLE_SYSTEMTAP) 3240 const OID *class_oid_for_marker_p;
3241 const OID *oid_for_marker_p;
3247 #if defined(ENABLE_SYSTEMTAP) 3248 if (class_oid == NULL)
3254 class_oid_for_marker_p = class_oid;
3263 oid_for_marker_p = oid;
3266 CUBRID_LOCK_ACQUIRE_START (oid_for_marker_p, class_oid_for_marker_p, lock);
3269 if (thread_p == NULL)
3276 thrd_entry = thread_p;
3278 new_mode = group_mode = old_mode =
NULL_LOCK;
3279 #if defined(LK_DUMP) 3280 if (lk_Gl.dump_level >= 1)
3283 "LK_DUMP::lk_internal_lock_object()\n" 3284 " tran(%2d) : oid(%2d|%3d|%3d), class_oid(%2d|%3d|%3d), LOCK(%7s) wait_msecs(%d)\n", tran_index,
3295 *entry_addr_ptr =
NULL;
3298 tran_lock = &lk_Gl.tran_lock_table[tran_index];
3299 is_instant_duration = tran_lock->is_instant_duration;
3302 assert (!is_res_mutex_locked);
3309 ret_val = lock_escalate_if_needed (thread_p, class_entry, tran_index);
3331 entry_ptr = lock_find_class_entry (tran_index, oid);
3332 if (entry_ptr != NULL)
3334 res_ptr = entry_ptr->res_head;
3335 goto lock_tran_lk_entry;
3340 search_key = lock_create_search_key ((
OID *) oid, (
OID *) class_oid);
3341 (void) lk_Gl.m_obj_hash_table.find_or_insert (thread_p, search_key, res_ptr);
3342 if (res_ptr == NULL)
3348 is_res_mutex_locked =
true;
3356 lock_initialize_resource_as_allocated (res_ptr,
NULL_LOCK);
3358 entry_ptr = lock_get_new_entry (tran_index, t_entry_ent, &lk_Gl.obj_free_entry_list);
3359 if (entry_ptr == NULL)
3361 assert (is_res_mutex_locked);
3369 lock_initialize_entry_as_granted (entry_ptr, tran_index, res_ptr, lock);
3370 if (is_instant_duration)
3372 entry_ptr->instant_lock_count++;
3373 assert (entry_ptr->instant_lock_count > 0);
3377 res_ptr->
holder = entry_ptr;
3380 entry_ptr->class_entry = class_entry;
3381 lock_increment_class_granules (class_entry);
3384 lock_insert_into_tran_hold_list (entry_ptr, tran_index);
3390 #if defined(LK_TRACE_OBJECT) 3391 LK_MSG_LOCK_ACQUIRED (entry_ptr);
3395 assert (is_res_mutex_locked);
3398 *entry_addr_ptr = entry_ptr;
3407 entry_ptr = res_ptr->
holder;
3408 while (entry_ptr != NULL)
3410 if (entry_ptr->tran_index == tran_index)
3414 entry_ptr = entry_ptr->next;
3417 if (entry_ptr == NULL)
3430 entry_ptr = lock_get_new_entry (tran_index, t_entry_ent, &lk_Gl.obj_free_entry_list);
3431 if (entry_ptr == NULL)
3441 lock_initialize_entry_as_granted (entry_ptr, tran_index, res_ptr, lock);
3442 if (is_instant_duration)
3444 entry_ptr->instant_lock_count++;
3445 assert (entry_ptr->instant_lock_count > 0);
3449 entry_ptr->class_entry = class_entry;
3450 lock_increment_class_granules (class_entry);
3453 lock_position_holder_entry (res_ptr, entry_ptr);
3461 lock_insert_into_tran_hold_list (entry_ptr, tran_index);
3463 lock_update_non2pl_list (thread_p, res_ptr, tran_index, lock);
3467 #if defined(LK_TRACE_OBJECT) 3468 LK_MSG_LOCK_ACQUIRED (entry_ptr);
3471 assert (is_res_mutex_locked);
3473 *entry_addr_ptr = entry_ptr;
3482 assert (is_res_mutex_locked);
3486 if (entry_ptr == NULL)
3488 entry_ptr = lock_get_new_entry (tran_index, t_entry_ent, &lk_Gl.obj_free_entry_list);
3489 if (entry_ptr == NULL)
3495 lock_initialize_entry_as_blocked (entry_ptr, thread_p, tran_index, res_ptr, lock);
3496 if (is_instant_duration
3499 entry_ptr->instant_lock_count++;
3500 assert (entry_ptr->instant_lock_count > 0);
3503 (void) lock_set_error_for_timeout (thread_p, entry_ptr);
3505 lock_free_entry (tran_index, t_entry_ent, &lk_Gl.obj_free_entry_list, entry_ptr);
3513 wait_entry_ptr = res_ptr->
waiter;
3514 while (wait_entry_ptr != NULL)
3516 if (wait_entry_ptr->tran_index == tran_index)
3520 wait_entry_ptr = wait_entry_ptr->next;
3523 if (wait_entry_ptr != NULL)
3528 if (wait_entry_ptr->thrd_entry->lockwait == NULL)
3533 assert (is_res_mutex_locked);
3535 is_res_mutex_locked =
false;
3539 thrd_entry->tran_next_wait = wait_entry_ptr->thrd_entry->tran_next_wait;
3540 wait_entry_ptr->thrd_entry->tran_next_wait = thrd_entry;
3543 assert (is_res_mutex_locked);
3545 is_res_mutex_locked =
false;
3580 entry_ptr = lock_get_new_entry (tran_index, t_entry_ent, &lk_Gl.obj_free_entry_list);
3581 if (entry_ptr == NULL)
3583 assert (is_res_mutex_locked);
3590 lock_initialize_entry_as_blocked (entry_ptr, thread_p, tran_index, res_ptr, lock);
3591 if (is_instant_duration)
3593 entry_ptr->instant_lock_count++;
3594 assert (entry_ptr->instant_lock_count > 0);
3599 for (i = res_ptr->
waiter; i != NULL; i = i->next)
3605 res_ptr->
waiter = entry_ptr;
3609 prev->next = entry_ptr;
3622 lock_conversion =
true;
3623 old_mode = entry_ptr->granted_mode;
3625 new_mode =
lock_Conv[lock][entry_ptr->granted_mode];
3628 if (new_mode == entry_ptr->granted_mode)
3631 entry_ptr->count += 1;
3632 if (is_instant_duration)
3634 compat1 =
lock_Comp[lock][entry_ptr->granted_mode];
3637 if ((lock >=
IX_LOCK && (entry_ptr->instant_lock_count == 0 && entry_ptr->granted_mode >=
IX_LOCK))
3646 entry_ptr->instant_lock_count++;
3647 assert (entry_ptr->instant_lock_count > 0);
3651 if (is_res_mutex_locked)
3656 *entry_addr_ptr = entry_ptr;
3662 if (!is_res_mutex_locked)
3666 is_res_mutex_locked =
true;
3671 for (i = res_ptr->
holder; i != NULL; i = i->next)
3676 group_mode =
lock_Conv[i->granted_mode][group_mode];
3682 compat1 =
lock_Comp[new_mode][group_mode];
3687 entry_ptr->granted_mode = new_mode;
3688 entry_ptr->count += 1;
3689 if (is_instant_duration)
3691 entry_ptr->instant_lock_count++;
3692 assert (entry_ptr->instant_lock_count > 0);
3699 lock_update_non2pl_list (thread_p, res_ptr, tran_index, lock);
3700 assert (is_res_mutex_locked);
3703 goto lock_conversion_treatement;
3712 LK_ENTRY *p = lock_get_new_entry (tran_index, t_entry_ent,
3713 &lk_Gl.obj_free_entry_list);
3717 lock_initialize_entry_as_blocked (p, thread_p, tran_index, res_ptr, lock);
3718 lock_set_error_for_timeout (thread_p, p);
3719 lock_free_entry (tran_index, t_entry_ent, &lk_Gl.obj_free_entry_list, p);
3730 if (entry_ptr->blocked_mode !=
NULL_LOCK)
3736 if (entry_ptr->thrd_entry->lockwait == NULL)
3740 assert (is_res_mutex_locked);
3742 is_res_mutex_locked =
false;
3746 thrd_entry->tran_next_wait = entry_ptr->thrd_entry->tran_next_wait;
3747 entry_ptr->thrd_entry->tran_next_wait = thrd_entry;
3751 assert (is_res_mutex_locked);
3753 is_res_mutex_locked =
false;
3783 entry_ptr->blocked_mode = new_mode;
3784 entry_ptr->count += 1;
3785 if (is_instant_duration)
3787 entry_ptr->instant_lock_count++;
3788 assert (entry_ptr->instant_lock_count > 0);
3791 entry_ptr->thrd_entry = thread_p;
3800 while ((curr != NULL) && (curr != entry_ptr))
3807 res_ptr->
holder = entry_ptr->next;
3811 prev->next = entry_ptr->next;
3815 lock_position_holder_entry (res_ptr, entry_ptr);
3826 #if defined(LK_TRACE_OBJECT) 3827 LK_MSG_LOCK_WAITFOR (entry_ptr);
3831 if (is_res_mutex_locked)
3835 ret_val = lock_suspend (thread_p, entry_ptr, wait_msecs);
3841 lock_wait_time = tv_diff.tv_sec * 1000000LL + tv_diff.tv_usec;
3842 perfmon_lk_waited_time_on_objects (thread_p, lock, lock_wait_time);
3849 lock_internal_perform_unlock_object (thread_p, entry_ptr,
false,
false);
3869 lock_conversion_treatement:
3873 new_mode = entry_ptr->granted_mode;
3879 lock_remove_all_inst_locks (thread_p, tran_index, oid,
S_LOCK);
3886 lock_remove_all_inst_locks (thread_p, tran_index, oid,
S_LOCK);
3890 lock_remove_all_inst_locks (thread_p, tran_index, oid,
X_LOCK);
3896 lock_remove_all_inst_locks (thread_p, tran_index, oid,
X_LOCK);
3904 #if defined(LK_TRACE_OBJECT) 3905 LK_MSG_LOCK_CONVERTED (entry_ptr);
3909 if (lock_conversion ==
false)
3912 entry_ptr->class_entry = class_entry;
3913 lock_increment_class_granules (class_entry);
3916 *entry_addr_ptr = entry_ptr;
3920 #if defined(ENABLE_SYSTEMTAP) 3921 CUBRID_LOCK_ACQUIRE_END (oid_for_marker_p, class_oid_for_marker_p, lock, ret_val !=
LK_GRANTED);
3928 #if defined(SERVER_MODE) 3946 lock_internal_perform_unlock_object (
THREAD_ENTRY * thread_p,
LK_ENTRY * entry_ptr,
bool release_flag,
3947 bool move_to_non2pl)
3958 #if defined(LK_DUMP) 3959 if (lk_Gl.dump_level >= 1)
3962 "LK_DUMP::lk_internal_unlock_object()\n" 3963 " tran(%2d) : oid(%2d|%3d|%3d), class_oid(%2d|%3d|%3d), LOCK(%7s)\n", entry_ptr->tran_index,
3964 entry_ptr->res_head->oid.volid, entry_ptr->res_head->oid.pageid, entry_ptr->res_head->oid.slotid,
3965 entry_ptr->res_head->class_oid.volid, entry_ptr->res_head->class_oid.pageid,
3970 if (entry_ptr == NULL)
3973 "NULL entry pointer");
3978 if (entry_ptr->tran_index != tran_index)
3984 if (release_flag ==
false)
3989 entry_ptr->instant_lock_count--;
3990 assert (entry_ptr->instant_lock_count >= 0);
3993 if (entry_ptr->blocked_mode ==
NULL_LOCK && entry_ptr->count > 0)
4000 res_ptr = entry_ptr->res_head;
4006 while (curr != NULL)
4008 if (curr->tran_index == tran_index)
4021 while (curr != NULL)
4023 if (curr->tran_index == tran_index)
4034 from_whom = curr->next;
4039 res_ptr->
waiter = curr->next;
4043 prev->next = curr->next;
4047 lock_free_entry (tran_index, t_entry, &lk_Gl.obj_free_entry_list, curr);
4049 if (from_whom != NULL)
4052 lock_grant_blocked_waiter_partial (thread_p, res_ptr, from_whom);
4058 for (i = res_ptr->
waiter; i != NULL; i = i->next)
4085 res_ptr->
holder = curr->next;
4089 prev->next = curr->next;
4092 if (release_flag ==
false && curr->count > 0)
4096 lock_position_holder_entry (res_ptr, entry_ptr);
4101 (void) lock_delete_from_tran_hold_list (curr, tran_index);
4104 lock_decrement_class_granules (curr->class_entry);
4107 if (release_flag ==
false && move_to_non2pl ==
true)
4109 (void) lock_add_non2pl_lock (thread_p, res_ptr, tran_index, curr->granted_mode);
4112 lock_free_entry (tran_index, t_entry, &lk_Gl.obj_free_entry_list, curr);
4117 for (i = res_ptr->
holder; i != NULL; i = i->next)
4129 if (res_ptr->
holder == NULL && res_ptr->
waiter == NULL)
4131 if (res_ptr->
non2pl == NULL)
4134 (void) lock_remove_resource (thread_p, res_ptr);
4144 lock_grant_blocked_holder (thread_p, res_ptr);
4146 (void) lock_grant_blocked_waiter (thread_p, res_ptr);
4171 #if defined(SERVER_MODE) 4178 if (entry_ptr == NULL)
4180 assert (entry_ptr != NULL);
4184 return lock_internal_demote_class_lock (thread_p, entry_ptr, lock, ex_lock);
4185 #else // SERVER_MODE 4187 #endif // !SERVER_MODE = SA_MODE 4190 #if defined (SERVER_MODE) 4209 assert (entry_ptr != NULL);
4211 res_ptr = entry_ptr->res_head;
4219 for (holder = res_ptr->
holder; holder != NULL; holder = holder->next)
4221 if (holder == entry_ptr)
4241 #if defined(LK_DUMP) 4242 if (lk_Gl.dump_level >= 1)
4244 fprintf (stderr,
"LK_DUMP::lk_demote_class_lock ()\n" 4245 " tran(%2d) : oid(%d|%d|%d), class_oid(%d|%d|%d), LOCK(%7s -> %7s)\n", entry_ptr->tran_index,
4251 *ex_lock = holder->granted_mode;
4254 holder->granted_mode = to_be_lock;
4258 for (h = res_ptr->
holder; h != NULL; h = h->next)
4261 total_mode =
lock_Conv[h->granted_mode][total_mode];
4265 total_mode =
lock_Conv[h->blocked_mode][total_mode];
4271 lock_grant_blocked_holder (thread_p, res_ptr);
4272 (void) lock_grant_blocked_waiter (thread_p, res_ptr);
4289 #if defined(SERVER_MODE) 4313 if (entry_ptr == NULL)
4315 assert (entry_ptr != NULL);
4319 if (entry_ptr->granted_mode ==
S_LOCK)
4321 (void) lock_internal_demote_class_lock (thread_p, entry_ptr,
IS_LOCK, &ex_lock);
4326 #if defined(SERVER_MODE) 4338 lock_demote_all_shared_class_locks (
THREAD_ENTRY * thread_p,
int tran_index)
4340 LK_TRAN_LOCK *tran_lock;
4347 tran_lock = &lk_Gl.tran_lock_table[tran_index];
4350 curr = tran_lock->class_hold_list;
4351 while (curr != NULL)
4353 assert (tran_index == curr->tran_index);
4355 next = curr->tran_next;
4357 if (curr->granted_mode ==
S_LOCK)
4360 (void) lock_internal_demote_class_lock (thread_p, curr,
IS_LOCK, &ex_lock);
4362 else if (curr->granted_mode ==
SIX_LOCK)
4365 (void) lock_internal_demote_class_lock (thread_p, curr,
IX_LOCK, &ex_lock);
4372 curr = tran_lock->root_class_hold;
4375 assert (tran_index == curr->tran_index);
4377 if (curr->granted_mode ==
S_LOCK)
4380 (void) lock_internal_demote_class_lock (thread_p, curr,
IS_LOCK, &ex_lock);
4382 else if (curr->granted_mode ==
SIX_LOCK)
4385 (void) lock_internal_demote_class_lock (thread_p, curr,
IX_LOCK, &ex_lock);
4391 #if defined(SERVER_MODE) 4405 lock_unlock_shared_inst_lock (
THREAD_ENTRY * thread_p,
int tran_index,
const OID * inst_oid)
4412 if (entry_ptr != NULL && entry_ptr->granted_mode ==
S_LOCK)
4414 lock_internal_perform_unlock_object (thread_p, entry_ptr,
false,
true);
4419 #if defined(SERVER_MODE) 4431 lock_remove_all_class_locks (
THREAD_ENTRY * thread_p,
int tran_index,
LOCK lock)
4433 LK_TRAN_LOCK *tran_lock;
4439 tran_lock = &lk_Gl.tran_lock_table[tran_index];
4442 curr = tran_lock->class_hold_list;
4443 while (curr != NULL)
4445 assert (tran_index == curr->tran_index);
4447 next = curr->tran_next;
4448 if (curr->granted_mode <= lock)
4450 lock_internal_perform_unlock_object (thread_p, curr,
true,
false);
4456 curr = tran_lock->root_class_hold;
4459 assert (tran_index == curr->tran_index);
4461 if (curr->granted_mode <= lock)
4463 lock_internal_perform_unlock_object (thread_p, curr,
true,
false);
4470 #if defined(SERVER_MODE) 4483 lock_remove_all_inst_locks (
THREAD_ENTRY * thread_p,
int tran_index,
const OID * class_oid,
LOCK lock)
4485 LK_TRAN_LOCK *tran_lock;
4488 tran_lock = &lk_Gl.tran_lock_table[tran_index];
4491 curr = tran_lock->inst_hold_list;
4492 while (curr != NULL)
4494 assert (tran_index == curr->tran_index);
4496 next = curr->tran_next;
4497 if (class_oid == NULL ||
OID_ISNULL (class_oid) ||
OID_EQ (&curr->res_head->key.class_oid, class_oid))
4499 if (curr->granted_mode <= lock || lock ==
X_LOCK)
4502 lock_internal_perform_unlock_object (thread_p, curr,
true,
false);
4518 #if defined(SERVER_MODE) 4538 res_ptr = non2pl->res_head;
4544 while (curr != NULL)
4546 if (curr->tran_index == tran_index)
4562 res_ptr->
non2pl = curr->next;
4566 prev->next = curr->next;
4571 lock_free_entry (tran_index, t_entry, &lk_Gl.obj_free_entry_list, curr);
4575 (void) lock_remove_resource (thread_p, res_ptr);
4585 #if defined(SERVER_MODE) 4602 LK_TRAN_LOCK *tran_lock;
4610 while (curr != NULL)
4612 if (curr->tran_index == tran_index)
4618 res_ptr->
non2pl = curr->next;
4622 prev->next = curr->next;
4624 (void) lock_delete_from_tran_non2pl_list (curr, tran_index);
4625 lock_free_entry (tran_index, t_entry, &lk_Gl.obj_free_entry_list, curr);
4636 compat =
lock_Comp[lock][curr->granted_mode];
4642 tran_lock = &lk_Gl.tran_lock_table[curr->tran_index];
4644 tran_lock->num_incons_non2pl += 1;
4662 #if defined(SERVER_MODE) 4677 lock_add_WFG_edge (
int from_tran_index,
int to_tran_index,
int holder_flag, INT64 edge_wait_stime)
4686 if (lk_Gl.TWFG_node[from_tran_index].DL_victim ==
true || lk_Gl.TWFG_node[to_tran_index].DL_victim ==
true)
4692 lk_Gl.global_edge_seq_num++;
4694 if (lk_Gl.TWFG_node[from_tran_index].checked_by_deadlock_detector ==
false)
4697 if (lk_Gl.TWFG_node[from_tran_index].first_edge != -1)
4700 curr = lk_Gl.TWFG_node[from_tran_index].first_edge;
4704 curr = lk_Gl.TWFG_edge[curr].next;
4706 lk_Gl.TWFG_edge[prev].next = lk_Gl.TWFG_free_edge_idx;
4707 lk_Gl.TWFG_free_edge_idx = lk_Gl.TWFG_node[from_tran_index].first_edge;
4708 lk_Gl.TWFG_node[from_tran_index].first_edge = -1;
4710 lk_Gl.TWFG_node[from_tran_index].checked_by_deadlock_detector =
true;
4711 lk_Gl.TWFG_node[from_tran_index].tran_edge_seq_num = lk_Gl.global_edge_seq_num;
4714 if (lk_Gl.TWFG_node[to_tran_index].checked_by_deadlock_detector ==
false)
4717 if (lk_Gl.TWFG_node[to_tran_index].first_edge != -1)
4720 curr = lk_Gl.TWFG_node[to_tran_index].first_edge;
4724 curr = lk_Gl.TWFG_edge[curr].next;
4726 lk_Gl.TWFG_edge[prev].next = lk_Gl.TWFG_free_edge_idx;
4727 lk_Gl.TWFG_free_edge_idx = lk_Gl.TWFG_node[to_tran_index].first_edge;
4728 lk_Gl.TWFG_node[to_tran_index].first_edge = -1;
4730 lk_Gl.TWFG_node[to_tran_index].checked_by_deadlock_detector =
true;
4731 lk_Gl.TWFG_node[to_tran_index].tran_edge_seq_num = lk_Gl.global_edge_seq_num;
4738 if (lk_Gl.TWFG_free_edge_idx == -1)
4740 if (lk_Gl.max_TWFG_edge == LK_MIN_TWFG_EDGE_COUNT)
4742 lk_Gl.max_TWFG_edge = LK_MID_TWFG_EDGE_COUNT;
4743 for (i = LK_MIN_TWFG_EDGE_COUNT; i < lk_Gl.max_TWFG_edge; i++)
4745 lk_Gl.TWFG_edge[
i].to_tran_index = -1;
4746 lk_Gl.TWFG_edge[
i].next = (i + 1);
4748 lk_Gl.TWFG_edge[lk_Gl.max_TWFG_edge - 1].next = -1;
4749 lk_Gl.TWFG_free_edge_idx = LK_MIN_TWFG_EDGE_COUNT;
4751 else if (lk_Gl.max_TWFG_edge == LK_MID_TWFG_EDGE_COUNT)
4753 temp_ptr = (
char *) lk_Gl.TWFG_edge;
4754 lk_Gl.max_TWFG_edge = LK_MAX_TWFG_EDGE_COUNT;
4755 lk_Gl.TWFG_edge = (LK_WFG_EDGE *) malloc (SIZEOF_LK_WFG_EDGE * lk_Gl.max_TWFG_edge);
4756 if (lk_Gl.TWFG_edge == NULL)
4759 (
size_t) (SIZEOF_LK_WFG_EDGE * lk_Gl.max_TWFG_edge));
4762 (void) memcpy ((
char *) lk_Gl.TWFG_edge, temp_ptr, (SIZEOF_LK_WFG_EDGE * LK_MID_TWFG_EDGE_COUNT));
4763 for (i = LK_MID_TWFG_EDGE_COUNT; i < lk_Gl.max_TWFG_edge; i++)
4765 lk_Gl.TWFG_edge[
i].to_tran_index = -1;
4766 lk_Gl.TWFG_edge[
i].next = (i + 1);
4768 lk_Gl.TWFG_edge[lk_Gl.max_TWFG_edge - 1].next = -1;
4769 lk_Gl.TWFG_free_edge_idx = LK_MID_TWFG_EDGE_COUNT;
4773 #if defined(CUBRID_DEBUG) 4781 alloc_idx = lk_Gl.TWFG_free_edge_idx;
4782 lk_Gl.TWFG_free_edge_idx = lk_Gl.TWFG_edge[alloc_idx].next;
4785 lk_Gl.TWFG_edge[alloc_idx].to_tran_index = to_tran_index;
4786 lk_Gl.TWFG_edge[alloc_idx].edge_seq_num = lk_Gl.global_edge_seq_num;
4787 lk_Gl.TWFG_edge[alloc_idx].holder_flag = holder_flag;
4788 lk_Gl.TWFG_edge[alloc_idx].edge_wait_stime = edge_wait_stime;
4791 lk_Gl.TWFG_edge[alloc_idx].next = lk_Gl.TWFG_node[from_tran_index].first_edge;
4792 lk_Gl.TWFG_node[from_tran_index].first_edge = alloc_idx;
4798 #if defined(SERVER_MODE) 4810 lock_select_deadlock_victim (
THREAD_ENTRY * thread_p,
int s,
int t)
4812 LK_WFG_NODE *TWFG_node;
4813 LK_WFG_EDGE *TWFG_edge;
4818 bool false_dd_cycle =
false;
4819 bool lock_holder_found =
false;
4820 bool inact_trans_found =
false;
4822 #if defined(CUBRID_DEBUG) 4825 int tran_index_area[20];
4826 int *tran_index_set = &tran_index_area[0];
4828 char *cycle_info_string;
4830 int num_tran_in_cycle;
4832 const char *client_prog_name, *client_user_name, *client_host_name;
4835 int *tran_index_in_cycle =
NULL;
4836 int victim_tran_index;
4837 int tran_log_count, victim_tran_log_count;
4840 TWFG_node = lk_Gl.TWFG_node;
4841 TWFG_edge = lk_Gl.TWFG_edge;
4847 if (TWFG_node[t].current == -1)
4850 TWFG_edge[TWFG_node[s].current].to_tran_index = -2;
4851 false_dd_cycle =
true;
4855 if (TWFG_node[t].checked_by_deadlock_detector ==
false || TWFG_node[t].thrd_wait_stime == 0
4856 || (TWFG_node[t].thrd_wait_stime > TWFG_edge[TWFG_node[t].current].edge_wait_stime))
4860 TWFG_node[t].first_edge = -1;
4861 TWFG_node[t].current = -1;
4863 TWFG_edge[TWFG_node[s].current].to_tran_index = -2;
4864 false_dd_cycle =
true;
4868 if (TWFG_edge[TWFG_node[s].current].edge_seq_num < TWFG_node[t].tran_edge_seq_num)
4871 TWFG_edge[TWFG_node[s].current].to_tran_index = -2;
4872 false_dd_cycle =
true;
4880 for (v = s; v != t;)
4882 u = lk_Gl.TWFG_node[v].ancestor;
4883 if (TWFG_node[v].current == -1)
4886 TWFG_edge[TWFG_node[u].current].to_tran_index = -2;
4887 false_dd_cycle =
true;
4891 if (TWFG_node[v].checked_by_deadlock_detector ==
false || TWFG_node[v].thrd_wait_stime == 0
4892 || (TWFG_node[v].thrd_wait_stime > TWFG_edge[TWFG_node[v].current].edge_wait_stime))
4896 TWFG_node[v].first_edge = -1;
4897 TWFG_node[v].current = -1;
4899 TWFG_edge[TWFG_node[u].current].to_tran_index = -2;
4900 false_dd_cycle =
true;
4904 if (TWFG_edge[TWFG_node[u].current].edge_seq_num < TWFG_node[v].tran_edge_seq_num)
4907 TWFG_edge[TWFG_node[u].current].to_tran_index = -2;
4908 false_dd_cycle =
true;
4919 if (false_dd_cycle ==
true)
4921 for (v = s; v != t;)
4923 w = TWFG_node[v].ancestor;
4924 TWFG_node[v].ancestor = -1;
4934 #if defined(CUBRID_DEBUG) 4935 num_WFG_nodes = tot_WFG_nodes;
4936 if (num_WFG_nodes > 20)
4938 tran_index_set = (
int *) malloc (
sizeof (
int) * num_WFG_nodes);
4939 if (tran_index_set == NULL)
4942 tran_index_set = &tran_index_area[0];
4947 if (TWFG_node[t].checked_by_deadlock_detector ==
false)
4952 if (TWFG_edge[TWFG_node[s].current].holder_flag)
4958 inact_trans_found =
true;
4959 #if defined(CUBRID_DEBUG) 4961 "Inactive transaction is found in a deadlock cycle\n(tran_index=%d, tranid=%d, state=%s)\n",
4963 tran_index_set[WFG_nidx] = t;
4969 victims[victim_count].tran_index = t;
4970 victims[victim_count].tranid = tranid;
4972 lock_holder_found =
true;
4978 #if defined(CUBRID_DEBUG) 4979 tran_index_set[WFG_nidx] = t;
4984 victims[victim_count].tran_index_in_cycle =
NULL;
4985 victims[victim_count].num_trans_in_cycle = 0;
4987 num_tran_in_cycle = 1;
4988 for (v = s; v != t; v = TWFG_node[v].ancestor)
4990 num_tran_in_cycle++;
4993 cycle_info_string = (
char *) malloc (unit_size * num_tran_in_cycle);
4994 tran_index_in_cycle = (
int *) malloc (
sizeof (
int) * num_tran_in_cycle);
4996 if (cycle_info_string != NULL && tran_index_in_cycle != NULL)
5000 ptr = cycle_info_string;
5002 for (i = 0, v = s; i < num_tran_in_cycle; i++, v = TWFG_node[v].ancestor)
5008 snprintf (ptr, unit_size,
"%s%s@%s|%s(%d)", ((v == s) ?
"" :
", "), client_user_name, client_host_name,
5009 client_prog_name, client_pid);
5011 assert_release (ptr < cycle_info_string + unit_size * num_tran_in_cycle);
5013 tran_index_in_cycle[
i] = v;
5018 (cycle_info_string) ? cycle_info_string :
"");
5020 if (cycle_info_string != NULL)
5025 for (v = s; v != t;)
5027 #if defined(CUBRID_DEBUG) 5028 if (TWFG_node[v].checked_by_deadlock_detector ==
false)
5033 if (TWFG_node[v].candidate ==
true)
5036 victim_tran_index = victims[victim_count].tran_index;
5039 inact_trans_found =
true;
5040 #if defined(CUBRID_DEBUG) 5042 "Inactive transaction is found in a deadlock cycle\n" 5043 "(tran_index=%d, tranid=%d, state=%s)\n", v, tranid,
5045 tran_index_set[WFG_nidx] = v;
5052 lock_holder_found =
true;
5056 victim_tranid = tranid;
5063 victim_tranid = tranid;
5071 if (tran_log_count != victim_tran_log_count)
5073 if (tran_log_count < victim_tran_log_count)
5076 victim_tranid = tranid;
5085 if ((victims[victim_count].can_timeout ==
false && can_timeout ==
true)
5086 || (victims[victim_count].can_timeout == can_timeout
5087 && (LK_ISYOUNGER (tranid, victims[victim_count].tranid))))
5089 victim_tranid = tranid;
5096 victims[victim_count].tran_index = v;
5097 victims[victim_count].tranid = victim_tranid;
5098 victims[victim_count].can_timeout = can_timeout;
5102 #if defined(CUBRID_DEBUG) 5105 tran_index_set[WFG_nidx] = v;
5109 v = TWFG_node[v].ancestor;
5114 #if defined(CUBRID_DEBUG) 5115 if (TWFG_node[victims[victim_count].tran_index].checked_by_deadlock_detector ==
false)
5120 TWFG_node[victims[victim_count].tran_index].current = -1;
5121 victims[victim_count].tran_index_in_cycle = tran_index_in_cycle;
5122 victims[victim_count].num_trans_in_cycle = num_tran_in_cycle;
5128 for (i = 0, v = s; i < num_tran_in_cycle; v = TWFG_node[v].ancestor, i++)
5130 assert_release (TWFG_node[v].current >= 0 && TWFG_node[v].current < lk_Gl.max_TWFG_edge);
5132 next_node = TWFG_edge[TWFG_node[v].current].to_tran_index;
5134 if (TWFG_node[next_node].checked_by_deadlock_detector ==
false || TWFG_node[next_node].thrd_wait_stime == 0
5135 || TWFG_node[next_node].thrd_wait_stime > TWFG_edge[TWFG_node[next_node].current].edge_wait_stime)
5138 TWFG_node[next_node].first_edge = -1;
5139 TWFG_node[next_node].current = -1;
5140 TWFG_edge[TWFG_node[v].current].to_tran_index = -2;
5141 TWFG_node[v].current = TWFG_edge[TWFG_node[v].current].next;
5146 if (i == num_tran_in_cycle)
5149 TWFG_edge[TWFG_node[s].current].to_tran_index = -2;
5150 TWFG_node[s].current = TWFG_edge[TWFG_node[s].current].next;
5153 if (tran_index_in_cycle != NULL)
5158 #if defined(CUBRID_DEBUG) 5160 if (lock_holder_found ==
false)
5164 if (inact_trans_found ==
true)
5169 lk_Gl.TWFG_free_edge_idx, lk_Gl.global_edge_seq_num);
5172 for (WFG_nidx = 0; WFG_nidx < num_WFG_nodes; WFG_nidx++)
5175 if ((WFG_nidx + 1) == num_WFG_nodes || (WFG_nidx % 10) == 9)
5183 for (v = s; v != t;)
5185 w = TWFG_node[v].ancestor;
5186 TWFG_node[v].ancestor = -1;
5192 #if defined(SERVER_MODE) 5199 lock_dump_deadlock_victims (
THREAD_ENTRY * thread_p, FILE * outfile)
5203 fprintf (outfile,
"*** Deadlock Victim Information ***\n");
5204 fprintf (outfile,
"Victim count = %d\n", victim_count);
5208 for (k = 0; k < victim_count; k++)
5210 if (!victims[k].can_timeout)
5213 victims[k].tran_index);
5214 if ((count % 10) == 9)
5225 for (k = 0; k < victim_count; k++)
5227 if (victims[k].can_timeout)
5230 victims[k].tran_index);
5231 if ((count % 10) == 9)
5252 #if defined(SERVER_MODE) 5264 lock_compare_lock_info (
const void *lockinfo1,
const void *lockinfo2)
5269 oid1 = &(((LK_LOCKINFO *) (lockinfo1))->oid);
5270 oid2 = &(((LK_LOCKINFO *) (lockinfo2))->oid);
5276 #if defined(SERVER_MODE) 5285 lock_wait_msecs_to_secs (
int msecs)
5289 return (
float) msecs / 1000;
5292 return (
float) msecs;
5296 #if defined(SERVER_MODE) 5310 #define TEMP_BUFFER_SIZE 128 5313 int num_holders, num_blocked_holders, num_waiters;
5315 size_t time_str_len;
5320 memset (time_val, 0,
sizeof (time_val));
5334 if (oid_rr != NULL &&
OID_EQ (&res_ptr->
key.
oid, oid_rr))
5372 bool is_virtual_directory_oid;
5377 is_virtual_directory_oid =
true;
5382 is_virtual_directory_oid =
false;
5416 char str_insid[128], str_delid[128];
5419 sprintf (str_insid,
"%llu", (
unsigned long long int)
MVCC_GET_INSID (&mvcc_rec_header));
5423 strcpy (str_insid,
"missing");
5427 sprintf (str_delid,
"%llu", (
unsigned long long int)
MVCC_GET_DELID (&mvcc_rec_header));
5431 strcpy (str_delid,
"missing");
5434 str_insid, str_delid);
5450 num_holders = num_blocked_holders = 0;
5451 if (res_ptr->
holder != NULL)
5453 entry_ptr = res_ptr->
holder;
5454 while (entry_ptr != NULL)
5456 if (entry_ptr->blocked_mode ==
NULL_LOCK)
5462 num_blocked_holders++;
5464 entry_ptr = entry_ptr->next;
5468 if (res_ptr->
waiter != NULL)
5470 entry_ptr = res_ptr->
waiter;
5471 while (entry_ptr != NULL)
5474 entry_ptr = entry_ptr->next;
5479 num_blocked_holders, num_waiters);
5482 if (num_holders > 0)
5486 entry_ptr = res_ptr->
holder;
5487 while (entry_ptr != NULL)
5489 if (entry_ptr->blocked_mode ==
NULL_LOCK)
5504 entry_ptr->ngranules);
5507 entry_ptr = entry_ptr->next;
5511 if (num_blocked_holders > 0)
5515 entry_ptr = res_ptr->
holder;
5516 while (entry_ptr != NULL)
5518 if (entry_ptr->blocked_mode !=
NULL_LOCK)
5520 time_t stime = (time_t) (entry_ptr->thrd_entry->lockwait_stime / 1000LL);
5521 if (ctime_r (&stime, time_val) ==
NULL)
5523 strcpy (time_val,
"???");
5526 time_str_len =
strlen (time_val);
5527 if (time_str_len > 0 && time_val[time_str_len - 1] ==
'\n')
5529 time_val[time_str_len - 1] = 0;
5537 lock_wait_msecs_to_secs (entry_ptr->thrd_entry->lockwait_msecs));
5546 lock_wait_msecs_to_secs (entry_ptr->thrd_entry->lockwait_msecs));
5549 entry_ptr = entry_ptr->next;
5554 if (res_ptr->
waiter != NULL)
5557 entry_ptr = res_ptr->
waiter;
5558 while (entry_ptr != NULL)
5560 time_t stime = (time_t) (entry_ptr->thrd_entry->lockwait_stime / 1000LL);
5561 (void) ctime_r (&stime, time_val);
5563 time_str_len =
strlen (time_val);
5564 if (time_str_len > 0 && time_val[time_str_len - 1] ==
'\n')
5566 time_val[time_str_len - 1] = 0;
5570 lock_wait_msecs_to_secs (entry_ptr->thrd_entry->lockwait_msecs));
5571 entry_ptr = entry_ptr->next;
5576 if (res_ptr->
non2pl != NULL)
5579 entry_ptr = res_ptr->
non2pl;
5580 while (entry_ptr != NULL)
5583 "", entry_ptr->tran_index,
5586 entry_ptr = entry_ptr->next;
5606 #if !defined (SERVER_MODE) 5607 lk_Standalone_has_xlock =
false;
5610 const char *env_value;
5613 error_code = lock_initialize_tran_lock_table ();
5618 lock_initialize_object_hash_table ();
5619 error_code = lock_initialize_object_lock_entry_list ();
5624 error_code = lock_initialize_deadlock_detection ();
5631 #if defined(CUBRID_DEBUG) 5632 lk_Gl.verbose_mode =
true;
5633 lk_Gl.no_victim_case_count = 0;
5635 env_value =
envvar_get (
"LK_VERBOSE_SUSPENDED");
5636 if (env_value != NULL)
5638 lk_Gl.verbose_mode = (
bool) atoi (env_value);
5639 if (lk_Gl.verbose_mode !=
false)
5641 lk_Gl.verbose_mode =
true;
5644 lk_Gl.no_victim_case_count = 0;
5647 #if defined(LK_DUMP) 5648 lk_Gl.dump_level = 0;
5650 if (env_value != NULL)
5652 lk_Gl.dump_level = atoi (env_value);
5653 if (lk_Gl.dump_level < 0 || lk_Gl.dump_level > 3)
5655 lk_Gl.dump_level = 0;
5660 lock_deadlock_detect_daemon_init ();
5671 #if defined(SERVER_MODE) 5682 lock_check_timeout_expired_and_count_suspended_mapfunc (
THREAD_ENTRY & thread_ref,
bool & stop_mapper,
5683 size_t & suspend_count)
5693 if (thread_ref.lockwait == NULL)
5728 if (lk_Gl.deadlock_and_timeout_detector == 0)
5735 size_t lock_wait_count = 0;
5745 #if defined(SERVER_MODE) 5750 lock_deadlock_detect_daemon_init ()
5752 assert (lock_Deadlock_detect_daemon == NULL);
5762 #if defined(SERVER_MODE) 5767 lock_deadlock_detect_daemon_destroy ()
5773 #if defined(SERVER_MODE) 5778 lock_deadlock_detect_daemon_get_stats (UINT64 * statsp)
5780 if (lock_Deadlock_detect_daemon != NULL)
5782 lock_Deadlock_detect_daemon->
get_stats (statsp);
5799 #if !defined (SERVER_MODE) 5800 lk_Standalone_has_xlock =
false;
5802 LK_TRAN_LOCK *tran_lock;
5809 if (lk_Gl.TWFG_node != NULL)
5816 if (lk_Gl.tran_lock_table != NULL)
5818 for (i = 0; i < lk_Gl.num_trans; i++)
5820 tran_lock = &lk_Gl.tran_lock_table[
i];
5823 while (tran_lock->lk_entry_pool != NULL)
5825 LK_ENTRY *entry = tran_lock->lk_entry_pool;
5826 tran_lock->lk_entry_pool = tran_lock->lk_entry_pool->next;
5833 lk_Gl.num_trans = 0;
5837 lk_Gl.max_obj_locks = 0;
5840 lk_Gl.m_obj_hash_table.destroy ();
5843 lock_deadlock_detect_daemon_destroy ();
5862 #if !defined (SERVER_MODE) 5872 if (class_oid == NULL)
5883 return lock_internal_hold_lock_object_instant (thread_p, tran_index, oid, class_oid, lock);
5906 #if !defined (SERVER_MODE) 5913 LOCK new_class_lock;
5914 LOCK old_class_lock;
5919 #if defined (EnableThreadMonitoring) 5929 if (class_oid == NULL)
5940 #if defined (EnableThreadMonitoring) 6001 granted = lock_internal_perform_lock_object (thread_p, tran_index, oid, NULL, lock, wait_msecs,
6002 &root_class_entry, NULL);
6019 old_class_lock = (class_entry) ? class_entry->granted_mode :
NULL_LOCK;
6023 if (old_class_lock < new_class_lock)
6025 granted = lock_internal_perform_lock_object (thread_p, tran_index, class_oid, NULL, new_class_lock,
6026 wait_msecs, &root_class_entry, NULL);
6037 granted = lock_internal_perform_lock_object (thread_p, tran_index, oid, NULL, lock, wait_msecs, &class_entry,
6043 if (old_class_lock < new_class_lock)
6045 if (class_entry != NULL && class_entry->class_entry != NULL
6046 && !
OID_IS_ROOTOID (&class_entry->class_entry->res_head->key.oid))
6049 superclass_entry = class_entry->class_entry;
6057 lock_internal_perform_lock_object (thread_p, tran_index, class_oid, NULL, new_class_lock, wait_msecs,
6058 &class_entry, superclass_entry);
6077 granted = lock_internal_perform_lock_object (thread_p, tran_index, oid, class_oid, lock, wait_msecs, &inst_entry,
6083 #if defined (EnableThreadMonitoring) 6118 #if !defined (SERVER_MODE) 6122 LOCK new_superclass_lock, old_superclass_lock;
6128 #if defined (EnableThreadMonitoring) 6133 if (subclass_oid == NULL)
6139 if (superclass_oid == NULL)
6150 #if defined (EnableThreadMonitoring) 6171 new_superclass_lock =
IS_LOCK;
6175 new_superclass_lock =
IX_LOCK;
6181 old_superclass_lock = (superclass_entry) ? superclass_entry->granted_mode :
NULL_LOCK;
6184 if (old_superclass_lock < new_superclass_lock)
6187 granted = lock_internal_perform_lock_object (thread_p, tran_index, superclass_oid, NULL, new_superclass_lock,
6188 wait_msecs, &superclass_entry, NULL);
6200 granted = lock_internal_perform_lock_object (thread_p, tran_index, subclass_oid, NULL, lock, wait_msecs,
6201 &subclass_entry, superclass_entry);
6203 #if defined (EnableThreadMonitoring) 6241 #if !defined (SERVER_MODE) 6246 int lock_result =
lock_object (thread_p, oid, class_oid, lock, cond_flag);
6270 #if !defined (SERVER_MODE) 6279 #if defined (EnableThreadMonitoring) 6284 if (class_oid == NULL)
6290 #if defined (EnableThreadMonitoring) 6312 granted = lock_internal_perform_lock_object (thread_p, tran_index, class_oid, NULL, class_lock, wait_msecs,
6313 &class_entry, root_class_entry);
6316 #if defined (EnableThreadMonitoring) 6349 #if !defined (SERVER_MODE) 6357 lk_Standalone_has_xlock =
true;
6366 LK_LOCKINFO cls_lockinfo_space[LK_LOCKINFO_FIXED_COUNT];
6367 LK_LOCKINFO *cls_lockinfo;
6372 LOCK intention_mode;
6375 #if defined (EnableThreadMonitoring) 6380 if (lockhint == NULL)
6383 "NULL lockhint pointer");
6393 #if defined (EnableThreadMonitoring) 6408 wait_msecs = INT_MAX;
6412 if (lockhint->
num_classes <= LK_LOCKINFO_FIXED_COUNT)
6414 cls_lockinfo = &cls_lockinfo_space[0];
6419 if (cls_lockinfo == NULL)
6442 granted = lock_internal_perform_lock_object (thread_p, tran_index, root_oidp, NULL, root_lock, wait_msecs,
6443 &root_class_entry, NULL);
6460 cls_lockinfo[cls_count].org_oidp = &lockhint->
classes[
i].
oid;
6461 cls_lockinfo[cls_count].lock = lockhint->
classes[
i].
lock;
6471 (void) qsort (cls_lockinfo, cls_count, SIZEOF_LK_LOCKINFO, lock_compare_lock_info);
6477 for (i = 0; i < cls_count; i++)
6480 if (cls_lockinfo[i].lock <=
S_LOCK)
6489 if (root_class_entry == NULL || root_class_entry->granted_mode < intention_mode)
6491 granted = lock_internal_perform_lock_object (thread_p, tran_index,
oid_Root_class_oid, NULL, intention_mode,
6492 wait_msecs, &root_class_entry, NULL);
6505 granted = lock_internal_perform_lock_object (thread_p, tran_index, &cls_lockinfo[i].oid, NULL,
6506 cls_lockinfo[i].lock, wait_msecs, &class_entry, root_class_entry);
6520 if (cls_lockinfo != &cls_lockinfo_space[0])
6525 #if defined (EnableThreadMonitoring) 6542 if (cls_lockinfo != &cls_lockinfo_space[0])
6552 int release_flag,
int move_to_non2pl)
6554 #if !defined (SERVER_MODE) 6567 if (entry_ptr != NULL)
6569 lock_internal_perform_unlock_object (thread_p, entry_ptr, release_flag, move_to_non2pl);
6618 #if !defined (SERVER_MODE) 6631 if (class_oid == NULL)
6644 #if defined(ENABLE_SYSTEMTAP) 6645 CUBRID_LOCK_RELEASE_START (oid, class_oid, lock);
6650 if (entry_ptr != NULL)
6652 lock_internal_perform_unlock_object (thread_p, entry_ptr,
false,
true);
6655 #if defined(ENABLE_SYSTEMTAP) 6656 CUBRID_LOCK_RELEASE_END (oid, class_oid, lock);
6678 #if defined(ENABLE_SYSTEMTAP) 6679 CUBRID_LOCK_RELEASE_START (oid, class_oid, lock);
6683 lock_unlock_object_by_isolation (thread_p, tran_index, isolation, class_oid, oid);
6685 #if defined(ENABLE_SYSTEMTAP) 6686 CUBRID_LOCK_RELEASE_END (oid, class_oid, lock);
6710 #if !defined (SERVER_MODE) 6715 LOCK reqobj_class_unlock;
6716 OID *oid, *class_oid;
6719 if (lockset == NULL)
6722 "NULL lockset pointer");
6743 if (reqobj_class_unlock ==
X_LOCK)
6763 lock_unlock_object_by_isolation (thread_p, tran_index, isolation, class_oid, oid);
6780 #if !defined (SERVER_MODE) 6787 if (lockhint == NULL)
6790 "NULL lockhint pointer");
6816 lock_unlock_inst_locks_of_class_by_isolation (thread_p, tran_index, isolation, &lockhint->
classes[i].
oid);
6839 #if !defined (SERVER_MODE) 6840 lk_Standalone_has_xlock =
false;
6846 LK_TRAN_LOCK *tran_lock;
6850 tran_lock = &lk_Gl.tran_lock_table[tran_index];
6853 entry_ptr = tran_lock->inst_hold_list;
6854 while (entry_ptr != NULL)
6856 assert (tran_index == entry_ptr->tran_index);
6858 lock_internal_perform_unlock_object (thread_p, entry_ptr,
true,
false);
6859 entry_ptr = tran_lock->inst_hold_list;
6863 entry_ptr = tran_lock->class_hold_list;
6864 while (entry_ptr != NULL)
6866 assert (tran_index == entry_ptr->tran_index);
6868 lock_internal_perform_unlock_object (thread_p, entry_ptr,
true,
false);
6869 entry_ptr = tran_lock->class_hold_list;
6873 entry_ptr = tran_lock->root_class_hold;
6874 if (entry_ptr != NULL)
6876 assert (tran_index == entry_ptr->tran_index);
6878 lock_internal_perform_unlock_object (thread_p, entry_ptr,
true,
false);
6882 while (tran_lock->non2pl_list != NULL)
6885 entry_ptr = tran_lock->non2pl_list;
6886 tran_lock->non2pl_list = entry_ptr->tran_next;
6888 assert (tran_index == entry_ptr->tran_index);
6892 tran_lock->num_incons_non2pl -= 1;
6895 lock_remove_non2pl (thread_p, entry_ptr, tran_index);
6907 #if !defined (SERVER_MODE) 6916 return lock_find_class_entry (tran_index, oid);
6920 search_key = lock_create_search_key ((
OID *) oid, NULL);
6926 res_ptr = lk_Gl.m_obj_hash_table.find (thread_p, search_key);
6927 if (res_ptr == NULL)
6933 entry_ptr = res_ptr->
holder;
6934 for (; entry_ptr !=
NULL; entry_ptr = entry_ptr->next)
6936 if (entry_ptr->tran_index == tran_index)
6961 #if !defined (SERVER_MODE) 6965 LK_TRAN_LOCK *tran_lock;
6979 tran_index = thread_p->conn_entry->get_tran_index ();
6993 tran_lock = &lk_Gl.tran_lock_table[tran_index];
7002 if (tran_lock->root_class_hold != NULL)
7004 lock_mode = tran_lock->root_class_hold->granted_mode;
7017 if (entry_ptr != NULL)
7019 lock_mode = entry_ptr->granted_mode;
7025 if (entry_ptr != NULL)
7027 lock_mode = entry_ptr->granted_mode;
7050 if (entry_ptr != NULL)
7052 lock_mode = entry_ptr->granted_mode;
7075 #if !defined (SERVER_MODE) 7079 LK_TRAN_LOCK *tran_lock;
7093 tran_index = thread_p->conn_entry->get_tran_index ();
7116 tran_lock = &lk_Gl.tran_lock_table[tran_index];
7125 if (tran_lock->root_class_hold != NULL)
7127 granted_lock_mode = tran_lock->root_class_hold->granted_mode;
7130 return (
lock_Conv[lock][granted_lock_mode] == granted_lock_mode);
7140 if (entry_ptr != NULL)
7142 granted_lock_mode = entry_ptr->granted_mode;
7144 return (
lock_Conv[lock][granted_lock_mode] == granted_lock_mode);
7148 if (entry_ptr != NULL)
7150 granted_lock_mode = entry_ptr->granted_mode;
7151 if (
lock_Conv[lock][granted_lock_mode] == granted_lock_mode)
7162 if (entry_ptr != NULL)
7164 granted_lock_mode = entry_ptr->granted_mode;
7183 #if !defined (SERVER_MODE) 7187 LK_TRAN_LOCK *tran_lock;
7198 tran_lock = &lk_Gl.tran_lock_table[tran_index];
7202 if (tran_lock->root_class_hold != NULL)
7204 lock_mode = tran_lock->root_class_hold->granted_mode;
7213 entry_ptr = tran_lock->class_hold_list;
7214 while (entry_ptr != NULL)
7216 lock_mode = entry_ptr->granted_mode;
7222 entry_ptr = entry_ptr->tran_next;
7233 #if defined(ENABLE_UNUSED_FUNCTION) 7245 lock_has_lock_transaction (
int tran_index)
7247 #if !defined (SERVER_MODE) 7250 LK_TRAN_LOCK *tran_lock;
7254 tran_lock = &lk_Gl.tran_lock_table[tran_index];
7256 if (tran_lock->root_class_hold != NULL || tran_lock->class_hold_list != NULL || tran_lock->inst_hold_list != NULL
7257 || tran_lock->non2pl_list != NULL)
7282 #if !defined (SERVER_MODE) 7287 size_t thrd_count,
i;
7292 thrd_array = tran_lock_waiters.data ();
7294 for (i = 0; i < thrd_count; i++)
7296 thrd_ptr = thrd_array[
i];
7298 if (LK_IS_LOCKWAIT_THREAD (thrd_ptr))
7305 if (thrd_ptr->lockwait != NULL || thrd_ptr->lockwait_state == (
int) LOCK_SUSPENDED)
7309 thrd_ptr->lockwait_state, thrd_ptr->index, thrd_ptr->get_posix_id (), thrd_ptr->tran_index);
7333 #if !defined (SERVER_MODE) 7338 LK_TRAN_LOCK *tran_lock;
7342 if (class_oid == NULL)
7345 "NULL ClassOID pointer");
7357 tran_index = thread_p->conn_entry->get_tran_index ();
7371 tran_lock = &lk_Gl.tran_lock_table[tran_index];
7377 entry_ptr = tran_lock->root_class_hold;
7392 #if defined (SERVER_MODE) 7394 if (LK_IS_LOCKWAIT_THREAD (thrd))
7401 if (thrd->lockwait != NULL || thrd->lockwait_state == (
int) LOCK_SUSPENDED)
7406 thrd->lockwait_state, thrd->index, thrd->get_posix_id (), thrd->tran_index);
7411 #endif // SERVER_MODE 7431 #if !defined (SERVER_MODE) 7437 assert (thrd_entry != NULL);
7442 if (LK_IS_LOCKWAIT_THREAD (thrd))
7450 else if (LK_CAN_TIMEOUT (thrd->lockwait_msecs))
7455 (void) gettimeofday (&tv, NULL);
7456 etime = (tv.tv_sec * 1000000LL + tv.tv_usec) / 1000LL;
7457 if (etime - thrd->lockwait_stime > thrd->lockwait_msecs)
7471 if (thrd->lockwait != NULL || thrd->lockwait_state == (
int) LOCK_SUSPENDED)
7476 thrd->lockwait_state, thrd->index, thrd->get_posix_id (), thrd->tran_index);
7505 #if !defined (SERVER_MODE) 7510 LK_TRAN_LOCK *tran_lock;
7524 tran_lock = &lk_Gl.tran_lock_table[tran_index];
7528 curr = tran_lock->non2pl_list;
7529 while (tran_lock->num_incons_non2pl > 0 && curr != NULL)
7534 curr = curr->tran_next;
7541 ret_val = (*fun) (&curr->res_head->key.class_oid, &curr->res_head->key.oid, args);
7542 if (ret_val !=
true)
7552 next = curr->tran_next;
7555 tran_lock->non2pl_list = next;
7559 prev->tran_next = next;
7562 tran_lock->num_incons_non2pl -= 1;
7565 curr->tran_next =
NULL;
7566 if (incon_non2pl_list_header == NULL)
7568 incon_non2pl_list_header = curr;
7569 incon_non2pl_list_tail = curr;
7573 incon_non2pl_list_tail->tran_next = curr;
7574 incon_non2pl_list_tail = curr;
7585 curr = incon_non2pl_list_header;
7586 while (curr != NULL)
7588 next = curr->tran_next;
7591 lock_remove_non2pl (thread_p, curr, tran_index);
7610 #if defined (SERVER_MODE) 7611 struct timeval now, elapsed;
7615 gettimeofday (&now, NULL);
7617 elapsed_sec = elapsed.tv_sec + (elapsed.tv_usec / 1000000.0);
7625 lk_Gl.last_deadlock_run = now;
7642 #if defined (SERVER_MODE) 7643 if (thread_ref.lockwait == NULL)
7647 int tran_index = thread_ref.tran_index;
7648 if (lock_wakeup_deadlock_victim_timeout (tran_index))
7654 #endif // SERVER_MODE 7684 #if !defined (SERVER_MODE) 7690 LK_WFG_NODE *TWFG_node;
7691 LK_WFG_EDGE *TWFG_edge;
7702 for (i = 1; i < lk_Gl.num_trans; i++)
7704 lk_Gl.TWFG_node[
i].first_edge = -1;
7705 lk_Gl.TWFG_node[
i].tran_edge_seq_num = 0;
7706 lk_Gl.TWFG_node[
i].checked_by_deadlock_detector =
true;
7710 lk_Gl.TWFG_edge = &TWFG_edge_block[0];
7711 lk_Gl.max_TWFG_edge = LK_MIN_TWFG_EDGE_COUNT;
7712 for (i = 0; i < LK_MIN_TWFG_EDGE_COUNT; i++)
7714 lk_Gl.TWFG_edge[
i].to_tran_index = -1;
7715 lk_Gl.TWFG_edge[
i].next = (i + 1);
7717 lk_Gl.TWFG_edge[lk_Gl.max_TWFG_edge - 1].next = -1;
7718 lk_Gl.TWFG_free_edge_idx = 0;
7721 lk_Gl.global_edge_seq_num = 0;
7730 lk_hashmap_iterator iterator { thread_p, lk_Gl.m_obj_hash_table };
7732 for (res_ptr = iterator.iterate (); res_ptr !=
NULL; res_ptr = iterator.iterate ())
7735 if (res_ptr->
holder == NULL)
7737 if (res_ptr->
waiter == NULL)
7743 #if defined(CUBRID_DEBUG) 7748 lk_fp = fopen (
"lock_waiter_only_info.log",
"a");
7751 cur_time = time (NULL);
7752 (void) ctime_r (&cur_time, time_val);
7753 fprintf (lk_fp,
"##########################################\n");
7754 fprintf (lk_fp,
"# current time: %s\n", time_val);
7755 lock_dump_resource (lk_fp, res_ptr);
7756 fprintf (lk_fp,
"##########################################\n");
7767 (void) lock_grant_blocked_waiter (thread_p, res_ptr);
7772 for (hi = res_ptr->
holder; hi != NULL; hi = hi->next)
7778 for (hj = hi->next; hj != NULL; hj = hj->next)
7783 compat1 =
lock_Comp[hj->blocked_mode][hi->granted_mode];
7784 compat2 =
lock_Comp[hj->blocked_mode][hi->blocked_mode];
7789 (void) lock_add_WFG_edge (hj->tran_index, hi->tran_index,
true, hj->thrd_entry->lockwait_stime);
7792 compat1 =
lock_Comp[hi->blocked_mode][hj->granted_mode];
7797 (void) lock_add_WFG_edge (hi->tran_index, hj->tran_index,
true, hi->thrd_entry->lockwait_stime);
7803 for (hi = res_ptr->
holder; hi != NULL; hi = hi->next)
7805 for (hj = res_ptr->
waiter; hj != NULL; hj = hj->next)
7810 compat1 =
lock_Comp[hj->blocked_mode][hi->granted_mode];
7811 compat2 =
lock_Comp[hj->blocked_mode][hi->blocked_mode];
7816 (void) lock_add_WFG_edge (hj->tran_index, hi->tran_index,
true, hj->thrd_entry->lockwait_stime);
7822 for (hi = res_ptr->
waiter; hi != NULL; hi = hi->next)
7824 for (hj = hi->next; hj != NULL; hj = hj->next)
7828 compat1 =
lock_Comp[hj->blocked_mode][hi->blocked_mode];
7833 (void) lock_add_WFG_edge (hj->tran_index, hi->tran_index,
false, hj->thrd_entry->lockwait_stime);
7843 TWFG_node = lk_Gl.TWFG_node;
7844 TWFG_edge = lk_Gl.TWFG_edge;
7850 for (k = 1; k < lk_Gl.num_trans; k++)
7852 TWFG_node[k].current = TWFG_node[k].first_edge;
7853 TWFG_node[k].ancestor = -1;
7855 for (k = 1; k < lk_Gl.num_trans; k++)
7857 if (TWFG_node[k].current == -1)
7862 TWFG_node[s].ancestor = -2;
7865 if (TWFG_node[s].checked_by_deadlock_detector ==
false || TWFG_node[s].thrd_wait_stime == 0
7866 || (TWFG_node[s].current != -1
7867 && (TWFG_node[s].thrd_wait_stime > TWFG_edge[TWFG_node[s].current].edge_wait_stime)))
7870 TWFG_node[s].first_edge = -1;
7871 TWFG_node[s].current = -1;
7874 if (TWFG_node[s].current == -1)
7876 t = TWFG_node[s].ancestor;
7877 TWFG_node[s].ancestor = -1;
7879 if (s != -2 && TWFG_node[s].current != -1)
7881 assert_release (TWFG_node[s].current >= 0 && TWFG_node[s].current < lk_Gl.max_TWFG_edge);
7882 TWFG_node[s].current = TWFG_edge[TWFG_node[s].current].next;
7887 assert_release (TWFG_node[s].current >= 0 && TWFG_node[s].current < lk_Gl.max_TWFG_edge);
7889 t = TWFG_edge[TWFG_node[s].current].to_tran_index;
7893 TWFG_node[s].current = TWFG_edge[TWFG_node[s].current].next;
7897 if (TWFG_node[t].current == -1)
7899 TWFG_edge[TWFG_node[s].current].to_tran_index = -2;
7900 TWFG_node[s].current = TWFG_edge[TWFG_node[s].current].next;
7904 if (TWFG_node[t].checked_by_deadlock_detector ==
false || TWFG_node[t].thrd_wait_stime == 0
7905 || TWFG_node[t].thrd_wait_stime > TWFG_edge[TWFG_node[t].current].edge_wait_stime)
7907 TWFG_node[t].first_edge = -1;
7908 TWFG_node[t].current = -1;
7909 TWFG_edge[TWFG_node[s].current].to_tran_index = -2;
7910 TWFG_node[s].current = TWFG_edge[TWFG_node[s].current].next;
7914 if (TWFG_edge[TWFG_node[s].current].edge_seq_num < TWFG_node[t].tran_edge_seq_num)
7916 TWFG_edge[TWFG_node[s].current].to_tran_index = -2;
7917 TWFG_node[s].current = TWFG_edge[TWFG_node[s].current].next;
7921 if (TWFG_node[t].ancestor != -1)
7924 lock_select_deadlock_victim (thread_p, s, t);
7925 if (victim_count >= LK_MAX_VICTIM_COUNT)
7932 TWFG_node[t].ancestor = s;
7933 TWFG_node[t].candidate = TWFG_edge[TWFG_node[s].current].holder_flag;
7941 #if defined(ENABLE_SYSTEMTAP) 7942 if (victim_count > 0)
7944 CUBRID_TRAN_DEADLOCK ();
7948 #if defined (ENABLE_UNUSED_FUNCTION) 7949 if (victim_count > 0)
7957 lock_dump_deadlock_victims (thread_p, fp);
7971 for (k = 0; k < victim_count; k++)
7973 if (victims[k].tran_index_in_cycle == NULL)
7981 for (i = 0; i < victims[k].num_trans_in_cycle; i++)
7983 tran_index = victims[k].tran_index_in_cycle[
i];
7985 lock_event_log_tran_locks (thread_p, log_fp, tran_index);
7995 for (k = 0; k < victim_count; k++)
7997 if (victims[k].can_timeout)
7999 (void) lock_wakeup_deadlock_victim_timeout (victims[k].tran_index);
8003 (void) lock_wakeup_deadlock_victim_aborted (victims[k].tran_index);
8008 if (lk_Gl.max_TWFG_edge > LK_MID_TWFG_EDGE_COUNT)
8013 if (victim_count == 0)
8015 if (lk_Gl.no_victim_case_count < 60)
8017 lk_Gl.no_victim_case_count += 1;
8027 lk_Gl.no_victim_case_count = 0;
8051 lk_global_deadlock_detection (
void)
8053 #if !defined (SERVER_MODE) 8057 WFG_CYCLE *cycles, *cur_cycle;
8058 WFG_CYCLE_CASE cycle_case;
8060 int tot_num_victims = 0;
8061 LK_DEADLOCK_VICTIM victims[LK_MAX_VICTIM_COUNT];
8062 LK_DEADLOCK_VICTIM *v_p;
8069 bool isvictim_tg_waiting;
8070 bool iscandidate_tg_waiting;
8073 cycle_case = WFG_CYCLE_YES_PRUNE;
8074 while (cycle_case == WFG_CYCLE_YES_PRUNE)
8076 error = wfg_detect_cycle (&cycle_case, &cycles);
8078 if (error ==
NO_ERROR && (cycle_case == WFG_CYCLE_YES_PRUNE || cycle_case == WFG_CYCLE_YES))
8083 for (cur_cycle = cycles; cur_cycle != NULL && num_victims < LK_MAX_VICTIM_COUNT; cur_cycle = cur_cycle->next)
8086 victims[num_victims].can_timeout =
false;
8087 already_picked =
false;
8090 for (i = 0; i < cur_cycle->num_trans && already_picked ==
false; i++)
8092 tran_index = cur_cycle->waiters[
i].tran_index;
8093 for (j = 0; j < num_victims; j++)
8095 if (tran_index == victims[j].tran_index)
8098 already_picked =
true;
8102 if (already_picked !=
true)
8126 isvictim_tg_waiting = wfg_is_tran_group_waiting (victims[num_victims].tran_index);
8128 iscandidate_tg_waiting = wfg_is_tran_group_waiting (tran_index);
8130 if (isvictim_tg_waiting !=
NO_ERROR)
8132 if (iscandidate_tg_waiting ==
NO_ERROR 8133 || (victims[num_victims].can_timeout ==
false && can_timeout ==
true)
8134 || (victims[num_victims].can_timeout == can_timeout
8135 && LK_ISYOUNGER (tranid, victims[num_victims].tranid)))
8142 if (iscandidate_tg_waiting ==
NO_ERROR 8143 && ((victims[num_victims].can_timeout ==
false && can_timeout ==
true)
8144 || (victims[num_victims].can_timeout == can_timeout
8145 && LK_ISYOUNGER (tranid, victims[num_victims].tranid))))
8154 victims[num_victims].tran_index = tran_index;
8155 victims[num_victims].tranid = tranid;
8156 victims[num_victims].can_timeout = can_timeout;
8157 victims[num_victims].cycle_fun = cur_cycle->waiters[
i].cycle_fun;
8158 victims[num_victims].args = cur_cycle->waiters[
i].args;
8162 if (already_picked !=
true && victims[num_victims].tran_index !=
NULL_TRAN_INDEX)
8169 for (i = 0; i < num_victims; i++)
8172 if (v_p->cycle_fun != NULL)
8175 if ((*v_p->cycle_fun) (v_p->tran_index, v_p->args) ==
NO_ERROR)
8189 if (v_p->can_timeout ==
false)
8191 if (lock_wakeup_deadlock_victim_aborted (v_p->tran_index) ==
false)
8192 msql_tm_abort_detected (v_p->tran_index, NULL);
8196 if (lock_wakeup_deadlock_victim_timeout (v_p->tran_index) ==
false)
8197 msql_tm_timeout_detected (v_p->tran_index, NULL);
8201 wfg_free_cycle (cycles);
8203 tot_num_victims += num_victims;
8205 if (num_victims >= LK_MAX_VICTIM_COUNT)
8206 cycle_case = WFG_CYCLE_YES_PRUNE;
8236 #if !defined (SERVER_MODE) 8243 if (acqlocks == NULL)
8246 "NULL acqlocks pointer");
8257 r = lock_internal_perform_lock_object (thread_p, tran_index, &acqlocks->
obj[i].
oid, &acqlocks->
obj[i].
class_oid,
8288 #if !defined (SERVER_MODE) 8290 if (acqlocks != NULL)
8297 LK_TRAN_LOCK *tran_lock;
8308 lock_demote_all_shared_class_locks (thread_p, tran_index);
8309 lock_remove_all_inst_locks (thread_p, tran_index, NULL,
S_LOCK);
8310 lock_remove_all_class_locks (thread_p, tran_index,
S_LOCK);
8315 if (acqlocks != NULL)
8318 tran_lock = &lk_Gl.tran_lock_table[tran_index];
8324 acqlocks->
nobj_locks = (
unsigned int) (tran_lock->class_hold_count + tran_lock->inst_hold_count);
8325 if (tran_lock->root_class_hold != NULL)
8332 if (acqlocks->
obj == NULL)
8336 (
size_t) (SIZEOF_LK_ACQOBJ_LOCK * acqlocks->
nobj_locks));
8345 entry_ptr = tran_lock->root_class_hold;
8346 if (entry_ptr != NULL)
8348 assert (tran_index == entry_ptr->tran_index);
8352 acqlocks->
obj[idx].
lock = entry_ptr->granted_mode;
8357 for (entry_ptr = tran_lock->class_hold_list; entry_ptr != NULL; entry_ptr = entry_ptr->tran_next)
8359 assert (tran_index == entry_ptr->tran_index);
8361 COPY_OID (&acqlocks->
obj[idx].
oid, &entry_ptr->res_head->key.oid);
8363 acqlocks->
obj[idx].
lock = entry_ptr->granted_mode;
8368 for (entry_ptr = tran_lock->inst_hold_list; entry_ptr != NULL; entry_ptr = entry_ptr->tran_next)
8370 assert (tran_index == entry_ptr->tran_index);
8372 COPY_OID (&acqlocks->
obj[idx].
oid, &entry_ptr->res_head->key.oid);
8374 acqlocks->
obj[idx].
lock = entry_ptr->granted_mode;
8396 #if !defined (SERVER_MODE) 8404 fprintf (fp,
"Object_locks: count = %d\n", acqlocks->
nobj_locks);
8431 #if !defined (SERVER_MODE) 8434 const char *client_prog_name;
8435 const char *client_user_name;
8436 const char *client_host_name;
8441 int old_wait_msecs = 0;
8445 float lock_timeout_sec;
8446 char lock_timeout_string[64];
8462 for (tran_index = 0; tran_index < lk_Gl.num_trans; tran_index++)
8473 lock_timeout_sec = lock_wait_msecs_to_secs (wait_msecs);
8475 if (lock_timeout_sec > 0)
8477 sprintf (lock_timeout_string,
": %.2f", lock_timeout_sec);
8481 sprintf (lock_timeout_string,
": No wait");
8485 sprintf (lock_timeout_string,
": Infinite wait");
8490 sprintf (lock_timeout_string,
": %d", (
int) lock_timeout_sec);
8494 tran_index, client_prog_name, client_user_name, client_host_name, client_pid);
8500 lock_timeout_string);
8505 num_locked = (int) lk_Gl.m_obj_hash_table.get_element_count ();
8508 fprintf (outfp,
"Object Lock Table:\n");
8509 fprintf (outfp,
"\tCurrent number of objects which are locked = %d\n", num_locked);
8510 fprintf (outfp,
"\tMaximum number of objects which can be locked = %d\n\n", lk_Gl.max_obj_locks);
8513 lk_hashmap_iterator iterator { thread_p, lk_Gl.m_obj_hash_table };
8515 for (res_ptr = iterator.iterate (); res_ptr !=
NULL; res_ptr = iterator.iterate ())
8517 lock_dump_resource (thread_p, outfp, res_ptr);
8535 #if !defined (SERVER_MODE) 8562 #if !defined (SERVER_MODE) 8575 for (lockcomp_class = lockcomp->
class_list; lockcomp_class != NULL; lockcomp_class = lockcomp_class->
next)
8583 if (lockcomp_class == NULL)
8587 if (lockcomp_class == NULL)
8604 if (lock_internal_perform_lock_object (thread_p, lockcomp->
tran_index, class_oid, NULL,
IX_LOCK,
8619 lockcomp_class->
max_inst_oids = LK_COMPOSITE_LOCK_OID_INCREMENT;
8649 if ((lockcomp_class->
max_inst_oids + LK_COMPOSITE_LOCK_OID_INCREMENT) <
8652 max_oids = lockcomp_class->
max_inst_oids + LK_COMPOSITE_LOCK_OID_INCREMENT;
8716 #if !defined (SERVER_MODE) 8725 for (lockcomp_class = lockcomp->
class_list; lockcomp_class != NULL; lockcomp_class = lockcomp_class->
next)
8731 value = lock_internal_perform_lock_object (thread_p, lockcomp->
tran_index, &lockcomp_class->
class_oid, NULL,
8743 value = lock_internal_perform_lock_object (thread_p, lockcomp->
tran_index,
8776 #if !defined (SERVER_MODE) 8810 #if !defined (SERVER_MODE) 8838 #if defined(SA_MODE) 8841 return (
unsigned int) lk_Gl.m_obj_hash_table.get_element_count ();
8855 #if !defined (SERVER_MODE) 8858 LK_TRAN_LOCK *tran_lock;
8860 tran_lock = &lk_Gl.tran_lock_table[tran_index];
8861 tran_lock->is_instant_duration =
true;
8877 #if !defined (SERVER_MODE) 8880 LK_TRAN_LOCK *tran_lock;
8884 tran_lock = &lk_Gl.tran_lock_table[tran_index];
8886 if (!tran_lock->is_instant_duration)
8893 entry_ptr = tran_lock->inst_hold_list;
8894 while (entry_ptr != NULL)
8896 assert (tran_index == entry_ptr->tran_index);
8898 next_ptr = entry_ptr->tran_next;
8899 count = entry_ptr->instant_lock_count;
8906 lock_internal_perform_unlock_object (thread_p, entry_ptr,
false,
true);
8910 entry_ptr->instant_lock_count = 0;
8911 entry_ptr = next_ptr;
8915 entry_ptr = tran_lock->class_hold_list;
8916 while (entry_ptr != NULL)
8918 assert (tran_index == entry_ptr->tran_index);
8920 next_ptr = entry_ptr->tran_next;
8921 count = entry_ptr->instant_lock_count;
8928 lock_internal_perform_unlock_object (thread_p, entry_ptr,
false,
true);
8932 entry_ptr->instant_lock_count = 0;
8933 entry_ptr = next_ptr;
8937 entry_ptr = tran_lock->root_class_hold;
8938 if (entry_ptr != NULL)
8940 assert (tran_index == entry_ptr->tran_index);
8942 count = entry_ptr->instant_lock_count;
8949 lock_internal_perform_unlock_object (thread_p, entry_ptr,
false,
true);
8953 entry_ptr->instant_lock_count = 0;
8957 tran_lock->is_instant_duration =
false;
8969 #if !defined (SERVER_MODE) 8975 if (lk_Gl.TWFG_node[tran_index].checked_by_deadlock_detector)
8977 lk_Gl.TWFG_node[tran_index].checked_by_deadlock_detector =
false;
8979 if (lk_Gl.TWFG_node[tran_index].DL_victim)
8982 lk_Gl.TWFG_node[tran_index].DL_victim =
false;
8986 lock_set_tran_abort_reason (tran_index,
TRAN_NORMAL);
9001 #if !defined (SERVER_MODE) 9004 LK_TRAN_LOCK *tran_lock;
9006 tran_lock = &lk_Gl.tran_lock_table[tran_index];
9007 return tran_lock->is_instant_duration;
9011 #if defined(SERVER_MODE) 9019 lock_increment_class_granules (
LK_ENTRY * class_entry)
9026 class_entry->ngranules++;
9027 if (class_entry->class_entry != NULL && !
OID_IS_ROOTOID (&class_entry->class_entry->res_head->key.oid))
9030 class_entry->class_entry->ngranules++;
9041 lock_decrement_class_granules (
LK_ENTRY * class_entry)
9048 class_entry->ngranules--;
9049 if (class_entry->class_entry != NULL && !
OID_IS_ROOTOID (&class_entry->class_entry->res_head->key.oid))
9052 class_entry->class_entry->ngranules--;
9070 #if !defined (SERVER_MODE) 9076 if (out_buf == NULL)
9088 #define HOLDER_ENTRY_LENGTH (12) 9091 int holder_number = 0;
9092 int buf_size, n, remained_size;
9093 bool is_valid =
false;
9101 if (out_buf == NULL)
9122 while (waiter != NULL)
9124 if (waiter->tran_index == waiter_index)
9129 waiter = waiter->next;
9132 if (is_valid ==
false)
9135 while (holder != NULL)
9137 if (holder->blocked_mode !=
NULL_LOCK && holder->tran_index == waiter_index)
9142 holder = holder->next;
9146 if (is_valid ==
false)
9154 while (holder != NULL)
9156 if (holder->tran_index != waiter_index)
9160 holder = holder->next;
9163 if (holder_number == 0)
9169 buf_size = holder_number * HOLDER_ENTRY_LENGTH + 1;
9170 buf = (
char *) malloc (
sizeof (
char) * buf_size);
9180 remained_size = buf_size;
9185 while (holder && holder->tran_index == waiter_index)
9187 holder = holder->next;
9192 n = snprintf (p, remained_size,
"%d", holder->tran_index);
9198 holder = holder->next;
9199 while (holder != NULL)
9201 if (holder->tran_index != waiter_index)
9203 n = snprintf (p, remained_size,
", %d", holder->tran_index);
9208 holder = holder->next;
9230 case LOCK_SUSPENDED:
9235 return "RESUMED_TIMEOUT";
9237 return "RESUMED_DEADLOCK_TIMEOUT";
9239 return "RESUMED_ABORTED";
9241 return "RESUMED_ABORTED_FIRST";
9243 return "RESUMED_ABORTED_OTHER";
9245 return "RESUMED_INTERRUPT";
9254 #if defined(SERVER_MODE) 9267 int rv,
i, indent = 2;
9268 LK_TRAN_LOCK *tran_lock;
9273 fprintf (log_fp,
"hold:\n");
9275 tran_lock = &lk_Gl.tran_lock_table[tran_index];
9278 entry = tran_lock->inst_hold_list;
9281 assert (tran_index == entry->tran_index);
9285 SET_EMULATE_THREAD_WITH_LOCK_ENTRY (thread_p, entry);
9286 lock_event_log_lock_info (thread_p, log_fp, entry);
9291 fprintf (log_fp,
"\n");
9293 CLEAR_EMULATE_THREAD (thread_p);
9298 fprintf (log_fp,
"%*c...\n", indent,
' ');
9301 entry = tran_lock->waiting;
9304 fprintf (log_fp,
"wait:\n");
9307 SET_EMULATE_THREAD_WITH_LOCK_ENTRY (thread_p, entry);
9309 lock_event_log_lock_info (thread_p, log_fp, entry);
9314 fprintf (log_fp,
"\n");
9316 CLEAR_EMULATE_THREAD (thread_p);
9337 SET_EMULATE_THREAD_WITH_LOCK_ENTRY (thread_p, entry);
9339 fprintf (log_fp,
"waiter:\n");
9343 lock_event_log_lock_info (thread_p, log_fp, entry);
9348 CLEAR_EMULATE_THREAD (thread_p);
9350 fprintf (log_fp,
"\n");
9372 res_ptr = wait_entry->res_head;
9375 fprintf (log_fp,
"blocker:\n");
9377 for (entry = res_ptr->
holder; entry != NULL; entry = entry->next)
9379 if (entry == wait_entry)
9384 compat1 =
lock_Comp[entry->granted_mode][wait_entry->blocked_mode];
9385 compat2 =
lock_Comp[entry->blocked_mode][wait_entry->blocked_mode];
9394 SET_EMULATE_THREAD_WITH_LOCK_ENTRY (thread_p, entry);
9396 lock_event_log_lock_info (thread_p, log_fp, entry);
9401 CLEAR_EMULATE_THREAD (thread_p);
9403 fprintf (log_fp,
"\n");
9407 for (entry = res_ptr->
waiter; entry != NULL; entry = entry->next)
9409 if (entry == wait_entry)
9414 compat1 =
lock_Comp[entry->blocked_mode][wait_entry->blocked_mode];
9423 SET_EMULATE_THREAD_WITH_LOCK_ENTRY (thread_p, entry);
9425 lock_event_log_lock_info (thread_p, log_fp, entry);
9430 CLEAR_EMULATE_THREAD (thread_p);
9432 fprintf (log_fp,
"\n");
9455 res_ptr = entry->res_head;
9462 fprintf (log_fp,
", table=db_root");
9467 if (oid_rr != NULL &&
OID_EQ (&res_ptr->
key.
oid, oid_rr))
9470 fprintf (log_fp,
", Generic object for Repeatable Read consistency");
9490 if (classname != NULL)
9492 fprintf (log_fp,
", table=%s", classname);
9517 if (classname != NULL)
9519 fprintf (log_fp,
", table=%s", classname);
9529 fprintf (log_fp,
")\n");
9538 lock_event_set_tran_wait_entry (
int tran_index,
LK_ENTRY * entry)
9540 LK_TRAN_LOCK *tran_lock;
9543 tran_lock = &lk_Gl.tran_lock_table[tran_index];
9546 tran_lock->waiting = entry;
9550 lock_event_set_xasl_id_to_entry (tran_index, entry);
9562 lock_event_set_xasl_id_to_entry (
int tran_index,
LK_ENTRY * entry)
9575 entry->bind_index_in_tran = -1;
9583 entry->bind_index_in_tran = -1;
9599 #if !defined (SERVER_MODE) 9623 if (lock_internal_perform_lock_object (thread_p, tran_index, rep_read_oid, NULL, lock, wait_msecs, &entry_addr,
9633 #if defined (SERVER_MODE) 9638 bool is_safe =
true;
9640 lock_res = entry_ptr->res_head;
9641 if (lock_res != NULL)
9657 #if defined (SERVER_MODE) 9671 LK_TRAN_LOCK *tran_lock = &lk_Gl.tran_lock_table[tran_index];
9675 if (tran_lock->lk_entry_pool)
9677 assert (tran_lock->lk_entry_pool_count > 0);
9678 lock_entry = tran_lock->lk_entry_pool;
9679 tran_lock->lk_entry_pool = tran_lock->lk_entry_pool->next;
9680 tran_lock->lk_entry_pool_count--;
9702 LK_TRAN_LOCK *tran_lock = &lk_Gl.tran_lock_table[tran_index];
9704 assert (tran_lock->lk_entry_pool_count >= 0 && tran_lock->lk_entry_pool_count <= LOCK_TRAN_LOCAL_POOL_MAX_SIZE);
9707 if (tran_lock->lk_entry_pool_count < LOCK_TRAN_LOCAL_POOL_MAX_SIZE)
9709 lock_uninit_entry (lock_entry);
9710 lock_entry->next = tran_lock->lk_entry_pool;
9711 tran_lock->lk_entry_pool = lock_entry;
9712 tran_lock->lk_entry_pool_count++;
9721 #if defined (SERVER_MODE) 9733 const OID * class_oid,
const OID * oid)
9735 assert (class_oid != NULL && oid != NULL);
9752 lock_unlock_shared_inst_lock (thread_p, tran_index, oid);
9771 const OID * class_oid)
9773 assert (class_oid != NULL);
9784 lock_remove_all_inst_locks (thread_p, tran_index, class_oid,
S_LOCK);
9808 if (thread_ref.tran_index != tran_index)
9813 if (thread_ref.lockwait == NULL)
9818 tran_lock_waiters[count++] = &thread_ref;
9833 tran_lock_waiters, count);
bool lock_has_xlock(THREAD_ENTRY *thread_p)
#define MSGCAT_LK_RES_ROOT_CLASS_TYPE
size_t css_get_num_request_workers(void)
#define ER_LK_UNILATERALLY_ABORTED
#define OID_IS_VIRTUAL_CLASS_OF_DIR_OID(oidp)
void xlock_dump(THREAD_ENTRY *thread_p, FILE *outfp)
bool pgbuf_has_perm_pages_fixed(THREAD_ENTRY *thread_p)
LC_LOCKSET_CLASSOF * classes
cubthread::entry * thread_get_thread_entry_info(void)
#define MVCC_IS_HEADER_DELID_VALID(rec_header_p)
#define ER_LK_INVALID_OBJECT_TYPE
#define MSGCAT_LK_RES_NON2PL_RELEASED_HEAD
#define MVCC_GET_INSID(header)
LK_ENTRY * class_lock_ptr
#define LF_EM_NOT_USING_MUTEX
static LK_ENTRY * lock_find_tran_hold_entry(THREAD_ENTRY *thread_p, int tran_index, const OID *oid, bool is_class)
#define BO_IS_SERVER_RESTARTED()
#define MAX_NUM_LOCKS_DUMP_TO_EVENT_LOG
#define ER_LK_ROLLBACK_ON_LOCK_ESCALATION
size_t css_count_transaction_worker_threads(THREAD_ENTRY *thread_p, int tran_index, int client_id)
#define MSGCAT_LK_RES_BLOCKED_WAITER_HEAD
#define MSGCAT_LK_RES_BLOCKED_WAITER_ENTRY
#define pthread_mutex_init(a, b)
SCAN_CODE heap_get_visible_version(THREAD_ENTRY *thread_p, const OID *oid, OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, int ispeeking, int old_chn)
static void lock_detect_local_deadlock(THREAD_ENTRY *thread_p)
#define ER_LK_OBJECT_DL_TIMEOUT_CLASS_MSG
#define ER_LK_LOST_TRANSACTION
#define MSGCAT_LK_DEADLOCK_ABORT
#define MSGCAT_LK_RES_LOCK_COUNT
void event_log_sql_string(THREAD_ENTRY *thread_p, FILE *log_fp, XASL_ID *xasl_id, int indent)
bool mvcc_is_mvcc_disabled_class(const OID *class_oid)
#define ER_LK_OBJECT_TIMEOUT_SIMPLE_MSG
TRAN_ABORT_REASON tran_abort_reason
#define pthread_mutex_unlock(a)
#define MSGCAT_LK_DUMP_TRAN_ISOLATION
int lock_reacquire_crash_locks(THREAD_ENTRY *thread_p, LK_ACQUIRED_LOCKS *acqlocks, int tran_index)
void pgbuf_unfix_all(THREAD_ENTRY *thread_p)
#define LK_SET_STANDALONE_XLOCK(lock)
unsigned int lock_get_number_object_locks(void)
void lock_notify_isolation_incons(THREAD_ENTRY *thread_p, bool(*fun)(const OID *class_oid, const OID *oid, void *args), void *args)
bool logtb_set_tran_index_interrupt(THREAD_ENTRY *thread_p, int tran_index, bool set)
void thread_sleep(double millisec)
#define OR_MVCC_FLAG_VALID_INSID
void get_stats(cubperf::stat_value *stats_out)
#define assert_release(e)
int lock_demote_class_lock(THREAD_ENTRY *thread_p, const OID *oid, LOCK lock, LOCK *ex_lock)
#define ER_LK_MANY_LOCK_WAIT_TRAN
int or_mvcc_get_header(RECDES *record, MVCC_REC_HEADER *mvcc_header)
int lock_object(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int cond_flag)
void lock_abort_composite_lock(LK_COMPOSITE_LOCK *comp_lock)
cubthread::manager * thread_get_manager(void)
#define ER_LK_NOTFOUND_IN_LOCK_HOLDER_LIST
void lock_dump_acquired(FILE *fp, LK_ACQUIRED_LOCKS *acqlocks)
int lock_rep_read_tran(THREAD_ENTRY *thread_p, LOCK lock, int cond_flag)
struct timeval TSCTIMEVAL
#define OID_SET_NULL(oidp)
FILE * event_log_start(THREAD_ENTRY *thread_p, const char *event_name)
int logtb_get_number_assigned_tran_indices(void)
void thread_suspend_wakeup_and_unlock_entry(cubthread::entry *thread_p, thread_resume_suspend_status suspended_reason)
LOG_TDES * LOG_FIND_TDES(int tran_index)
void tsc_elapsed_time_usec(TSCTIMEVAL *tv, TSC_TICKS end_tick, TSC_TICKS start_tick)
int lock_scan(THREAD_ENTRY *thread_p, const OID *class_oid, int cond_flag, LOCK class_lock)
LC_LOCKSET_REQOBJ * objects
void * lf_freelist_claim(LF_TRAN_ENTRY *tran_entry, LF_FREELIST *freelist)
const char * log_state_string(TRAN_STATE state)
void lock_unlock_object_donot_move_to_non2pl(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock)
#define OID_AS_ARGS(oidp)
TRAN_ISOLATION logtb_find_isolation(int tran_index)
#define er_log_debug(...)
int lock_initialize_composite_lock(THREAD_ENTRY *thread_p, LK_COMPOSITE_LOCK *comp_lock)
int logtb_find_log_records_count(int tran_index)
struct lk_acqobj_lock LK_ACQOBJ_LOCK
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
#define MSGCAT_LK_RES_UNKNOWN_TYPE
#define ER_LK_NOTFOUND_IN_TRAN_HOLD_LIST
static int lk_Standalone_has_xlock
#define MSGCAT_LK_MVCC_INFO
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
LOCK lock_get_object_lock(const OID *oid, const OID *class_oid)
int xlogtb_reset_wait_msecs(THREAD_ENTRY *thread_p, int wait_msecs)
void lock_remove_object_lock(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock)
static DB_OBJECT * is_class(OID *obj_oid, OID *class_oid)
#define MSGCAT_LK_RES_INSTANCE_TYPE
static void lock_get_transaction_lock_waiting_threads_mapfunc(THREAD_ENTRY &thread_ref, bool &stop_mapper, int tran_index, tran_lock_waiters_array_type &tran_lock_waiters, size_t &count)
void port_close_memstream(FILE *fp, char **ptr, size_t *sizeloc)
static bool lock_is_class_lock_escalated(LOCK class_lock, LOCK lock_escalation)
manager * get_manager(void)
#define MSGCAT_LK_RES_CLASS_TYPE
#define RECDES_INITIALIZER
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
LF_TRAN_SYSTEM obj_lock_ent_Ts
void lock_unlock_all(THREAD_ENTRY *thread_p)
#define csect_check_own(a, b)
#define MSGCAT_LK_DUMP_TRAN_TIMEOUT_PERIOD
#define ER_LK_ALLOC_RESOURCE
#define XASL_ID_COPY(X1, X2)
int prm_get_integer_value(PARAM_ID prm_id)
#define OID_IS_ROOTOID(oidp)
LOCK_COMPATIBILITY lock_Comp[12][12]
#define MSGCAT_LK_DEADLOCK_ABORT_HDR
#define MSGCAT_LK_SUSPEND_TRAN
#define ER_LK_TOTAL_HOLDERS_MODE
#define ER_OUT_OF_VIRTUAL_MEMORY
#define MSGCAT_LK_RES_BLOCKED_HOLDER_HEAD
lf_tran_entry * thread_get_tran_entry(cubthread::entry *thread_p, int entry_idx)
bool logtb_is_interrupted_tran(THREAD_ENTRY *thread_p, bool clear, bool *continue_checking, int tran_index)
int lf_freelist_retire(LF_TRAN_ENTRY *tran_entry, LF_FREELIST *freelist, void *entry)
bool css_are_all_request_handlers_suspended(void)
static bool lock_is_local_deadlock_detection_interval_up(void)
void lock_unlock_object(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, bool force)
static enum scanner_mode mode
bool logtb_is_current_active(THREAD_ENTRY *thread_p)
int lock_hold_object_instant(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock)
int lock_initialize(void)
void event_log_bind_values(THREAD_ENTRY *thread_p, FILE *log_fp, int tran_index, int bind_index)
#define MSGCAT_LK_DUMP_TRAN_IDENTIFIERS
void lock_force_thread_timeout_lock(THREAD_ENTRY *thrd)
#define OID_EQ(oidp1, oidp2)
#define MSGCAT_LK_DEADLOCK_TIMEOUT
OID * oid_get_rep_read_tran_oid(void)
#define LOCK_TO_LOCKMODE_STRING(lock)
void lock_stop_instant_lock_mode(THREAD_ENTRY *thread_p, int tran_index, bool need_unlock)
void event_log_end(THREAD_ENTRY *thread_p)
#define MSGCAT_LK_DUMP_TRAN_STATE
const size_t DEFAULT_LOCK_WAITING_THREAD_ARRAY_SIZE
#define MSGCAT_LK_RES_RR_TYPE
#define MVCC_IS_FLAG_SET(rec_header_p, flags)
void tsc_getticks(TSC_TICKS *tck)
#define MSGCAT_LK_RES_NON_BLOCKED_HOLDER_ENTRY_WITH_GRANULE
int logtb_get_current_tran_index(void)
STATIC_INLINE bool perfmon_is_perf_tracking_and_active(int activation_flag) __attribute__((ALWAYS_INLINE))
int lock_subclass(THREAD_ENTRY *thread_p, const OID *subclass_oid, const OID *superclass_oid, LOCK lock, int cond_flag)
int lock_add_composite_lock(THREAD_ENTRY *thread_p, LK_COMPOSITE_LOCK *comp_lock, const OID *oid, const OID *class_oid)
#define ER_LK_UNKNOWN_ISOLATION
#define db_private_free_and_init(thrd, ptr)
int lf_freelist_init(LF_FREELIST *freelist, int initial_blocks, int block_size, LF_ENTRY_DESCRIPTOR *edesc, LF_TRAN_SYSTEM *tran_system)
void thread_lock_entry(cubthread::entry *thread_p)
bool logtb_has_deadlock_priority(int tran_index)
#define db_private_alloc(thrd, size)
int css_get_client_id(THREAD_ENTRY *thread_p)
int count(int &result, const cub_regex_object ®, const std::string &src, const int position, const INTL_CODESET codeset)
#define MSGCAT_CATALOG_CUBRID
static void lock_victimize_first_thread_mapfunc(THREAD_ENTRY &thread_ref, bool &stop_mapper)
static void lock_get_transaction_lock_waiting_threads(int tran_index, tran_lock_waiters_array_type &tran_lock_waiters, size_t &count)
#define ER_MNT_WAITING_THREAD
#define LF_FREELIST_INITIALIZER
STATIC_INLINE void perfmon_diff_timeval(struct timeval *elapsed, struct timeval *start, struct timeval *end) __attribute__((ALWAYS_INLINE))
TRANID logtb_find_tranid(int tran_index)
void lock_start_instant_lock_mode(int tran_index)
const char * envvar_get(const char *name)
#define ER_LK_OBJECT_TIMEOUT_CLASS_MSG
void map_entries(Func &&func, Args &&...args)
static void error(const char *msg)
void thread_unlock_entry(cubthread::entry *thread_p)
#define ER_LK_NOTFOUND_IN_TRAN_NON2PL_LIST
STATIC_INLINE void perfmon_inc_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid) __attribute__((ALWAYS_INLINE))
const char * log_isolation_string(TRAN_ISOLATION isolation)
static bool lock_force_timeout_expired_wait_transactions(void *thrd_entry)
LOG_TDES * LOG_FIND_CURRENT_TDES(THREAD_ENTRY *thread_p=NULL)
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
#define MSGCAT_LK_RESUME_TRAN
void lock_unlock_classes_lock_hint(THREAD_ENTRY *thread_p, LC_LOCKHINT *lockhint)
#define MSGCAT_LK_RES_BLOCKED_HOLDER_ENTRY
void destroy_daemon(daemon *&daemon_arg)
void event_log_print_client_info(int tran_index, int indent)
#define ER_LK_NOTENOUGH_ACTIVE_THREADS
float prm_get_float_value(PARAM_ID prm_id)
int lock_get_lock_holder_tran_index(THREAD_ENTRY *thread_p, char **out_buf, int waiter_index, LK_RES *res)
void lock_demote_read_class_lock_for_checksumdb(THREAD_ENTRY *thread_p, int tran_index, const OID *class_oid)
int lock_object_wait_msecs(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int cond_flag, int wait_msecs)
#define free_and_init(ptr)
#define ER_LK_BAD_ARGUMENT
int oid_compare(const void *a, const void *b)
int lock_classes_lock_hint(THREAD_ENTRY *thread_p, LC_LOCKHINT *lockhint)
#define MVCC_GET_DELID(header)
void lf_freelist_destroy(LF_FREELIST *freelist)
bool prm_get_bool_value(PARAM_ID prm_id)
int logtb_find_client_name_host_pid(int tran_index, const char **client_prog_name, const char **client_user_name, const char **client_host_name, int *client_pid)
#define MSGCAT_LK_DUMP_LOCK_TABLE
TRAN_STATE logtb_find_state(int tran_index)
#define IS_WRITE_EXCLUSIVE_LOCK(lock)
#define MSGCAT_LK_NEWLINE
const size_t LOG_USERNAME_MAX
char * msgcat_message(int cat_id, int set_id, int msg_id)
LK_ENTRY * lock_get_class_lock(THREAD_ENTRY *thread_p, const OID *class_oid)
#define XASL_ID_IS_NULL(X)
#define MSGCAT_LK_RES_NON_BLOCKED_HOLDER_HEAD
#define MSGCAT_LK_RES_TOTAL_MODE
#define ER_LK_OBJECT_DL_TIMEOUT_CLASSOF_MSG
LK_LOCKCOMP_CLASS * class_list
int lock_has_lock_on_object(const OID *oid, const OID *class_oid, LOCK lock)
LK_ENTRY * root_class_ptr
#define MSGCAT_LK_RES_BLOCKED_HOLDER_ENTRY_WITH_GRANULE
#define pthread_mutex_lock(a)
std::array< THREAD_ENTRY *, DEFAULT_LOCK_WAITING_THREAD_ARRAY_SIZE > tran_lock_waiters_array_type
#define MSGCAT_LK_RES_OID
#define ER_LK_LOCK_WAITER_ONLY
void thread_wakeup(cubthread::entry *thread_p, thread_resume_suspend_status resume_reason)
int heap_scancache_quick_start(HEAP_SCANCACHE *scan_cache)
bool logtb_is_active(THREAD_ENTRY *thread_p, TRANID trid)
static void lock_unlock_object_lock_internal(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int release_flag, int move_to_non2pl)
int lock_finalize_composite_lock(THREAD_ENTRY *thread_p, LK_COMPOSITE_LOCK *comp_lock)
daemon * create_daemon(const looper &looper_arg, entry_task *exec_p, const char *daemon_name="", entry_manager *context_manager=NULL)
#define CUB_MAXHOSTNAMELEN
void lock_unlock_objects_lock_set(THREAD_ENTRY *thread_p, LC_LOCKSET *lockset)
int num_reqobjs_processed
#define ER_LK_ABORT_TRAN_TWICE
#define MSGCAT_LK_RES_NON_BLOCKED_HOLDER_ENTRY
int heap_get_class_name(THREAD_ENTRY *thread_p, const OID *class_oid, char **class_name)
#define db_private_realloc(thrd, ptr, size)
#define XASL_ID_SET_NULL(X)
#define ER_LK_OBJECT_TIMEOUT_CLASSOF_MSG
#define MONITOR_WAITING_THREAD(elapsed)
callable_task< entry > entry_callable_task
#define MSGCAT_LK_DEADLOCK_TIMEOUT_HDR
#define MSGCAT_LK_RES_NON2PL_RELEASED_ENTRY
bool lock_is_waiting_transaction(int tran_index)
#define LF_EM_USING_MUTEX
int logtb_find_wait_msecs(int tran_index)
bool lock_is_instant_lock_mode(int tran_index)
#define ER_LK_DEADLOCK_CYCLE_DETECTED
enum tran_abort_reason TRAN_ABORT_REASON
#define ER_LK_STRANGE_LOCK_WAIT
LC_LOCKHINT_CLASS * classes
pthread_mutex_t res_mutex
void lock_clear_deadlock_victim(int tran_index)
void lock_unlock_all_shared_get_all_exclusive(THREAD_ENTRY *thread_p, LK_ACQUIRED_LOCKS *acqlocks)
#define ER_LK_OBJECT_DL_TIMEOUT_SIMPLE_MSG
#define ER_LK_DEADLOCK_SPECIFIC_INFO
const char * lock_wait_state_to_string(int state)
#define OID_GET_REAL_CLASS_OF_DIR_OID(virtual_oidp, class_oidp)
#define MAX_NUM_EXEC_QUERY_HISTORY
#define pthread_mutex_destroy(a)
FILE * port_open_memstream(char **ptr, size_t *sizeloc)
LF_TRAN_SYSTEM obj_lock_res_Ts