45 #if defined(UNIV_DEBUG) && !defined(UNIV_HOTBACKUP)
46 extern "C" my_bool timed_mutexes;
49 #ifdef HAVE_WINDOWS_ATOMICS
50 typedef LONG lock_word_t;
53 typedef byte lock_word_t;
56 #if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
60 # define PFS_SKIP_BUFFER_MUTEX_RWLOCK
63 # define PFS_SKIP_EVENT_MUTEX
69 extern mysql_pfs_key_t autoinc_mutex_key;
70 extern mysql_pfs_key_t buffer_block_mutex_key;
71 extern mysql_pfs_key_t buf_pool_mutex_key;
72 extern mysql_pfs_key_t buf_pool_zip_mutex_key;
73 extern mysql_pfs_key_t cache_last_read_mutex_key;
74 extern mysql_pfs_key_t dict_foreign_err_mutex_key;
75 extern mysql_pfs_key_t dict_sys_mutex_key;
76 extern mysql_pfs_key_t file_format_max_mutex_key;
77 extern mysql_pfs_key_t fil_system_mutex_key;
78 extern mysql_pfs_key_t flush_list_mutex_key;
79 extern mysql_pfs_key_t fts_bg_threads_mutex_key;
80 extern mysql_pfs_key_t fts_delete_mutex_key;
81 extern mysql_pfs_key_t fts_optimize_mutex_key;
82 extern mysql_pfs_key_t fts_doc_id_mutex_key;
83 extern mysql_pfs_key_t hash_table_mutex_key;
84 extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
85 extern mysql_pfs_key_t ibuf_mutex_key;
86 extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
87 extern mysql_pfs_key_t log_sys_mutex_key;
88 extern mysql_pfs_key_t log_flush_order_mutex_key;
89 # ifndef HAVE_ATOMIC_BUILTINS
90 extern mysql_pfs_key_t server_mutex_key;
92 # ifdef UNIV_MEM_DEBUG
93 extern mysql_pfs_key_t mem_hash_mutex_key;
95 extern mysql_pfs_key_t mem_pool_mutex_key;
96 extern mysql_pfs_key_t mutex_list_mutex_key;
97 extern mysql_pfs_key_t purge_sys_bh_mutex_key;
98 extern mysql_pfs_key_t recv_sys_mutex_key;
99 extern mysql_pfs_key_t recv_writer_mutex_key;
100 extern mysql_pfs_key_t rseg_mutex_key;
101 # ifdef UNIV_SYNC_DEBUG
102 extern mysql_pfs_key_t rw_lock_debug_mutex_key;
104 extern mysql_pfs_key_t rw_lock_list_mutex_key;
105 extern mysql_pfs_key_t rw_lock_mutex_key;
106 extern mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
107 extern mysql_pfs_key_t srv_innodb_monitor_mutex_key;
108 extern mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
109 extern mysql_pfs_key_t srv_threads_mutex_key;
110 extern mysql_pfs_key_t srv_monitor_file_mutex_key;
111 # ifdef UNIV_SYNC_DEBUG
112 extern mysql_pfs_key_t sync_thread_mutex_key;
114 extern mysql_pfs_key_t buf_dblwr_mutex_key;
115 extern mysql_pfs_key_t trx_undo_mutex_key;
116 extern mysql_pfs_key_t trx_mutex_key;
117 extern mysql_pfs_key_t lock_sys_mutex_key;
118 extern mysql_pfs_key_t lock_sys_wait_mutex_key;
119 extern mysql_pfs_key_t trx_sys_mutex_key;
120 extern mysql_pfs_key_t srv_sys_mutex_key;
121 extern mysql_pfs_key_t srv_sys_tasks_mutex_key;
122 #ifndef HAVE_ATOMIC_BUILTINS
123 extern mysql_pfs_key_t srv_conc_mutex_key;
125 #ifndef HAVE_ATOMIC_BUILTINS_64
128 extern mysql_pfs_key_t event_os_mutex_key;
129 extern mysql_pfs_key_t ut_list_mutex_key;
130 extern mysql_pfs_key_t os_mutex_key;
131 extern mysql_pfs_key_t zip_pad_mutex_key;
149 #ifdef UNIV_PFS_MUTEX
173 # ifdef UNIV_SYNC_DEBUG
174 # define mutex_create(K, M, level) \
175 pfs_mutex_create_func((K), (M), #M, (level), __FILE__, __LINE__)
177 # define mutex_create(K, M, level) \
178 pfs_mutex_create_func((K), (M), #M, __FILE__, __LINE__)
181 # define mutex_create(K, M, level) \
182 pfs_mutex_create_func((K), (M), __FILE__, __LINE__)
185 # define mutex_enter(M) \
186 pfs_mutex_enter_func((M), __FILE__, __LINE__)
188 # define mutex_enter_nowait(M) \
189 pfs_mutex_enter_nowait_func((M), __FILE__, __LINE__)
191 # define mutex_exit(M) pfs_mutex_exit_func(M)
193 # define mutex_free(M) pfs_mutex_free_func(M)
200 # ifdef UNIV_SYNC_DEBUG
201 # define mutex_create(K, M, level) \
202 mutex_create_func((M), #M, (level), __FILE__, __LINE__)
204 # define mutex_create(K, M, level) \
205 mutex_create_func((M), #M, __FILE__, __LINE__)
208 # define mutex_create(K, M, level) \
209 mutex_create_func((M), __FILE__, __LINE__)
212 # define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__)
214 # define mutex_enter_nowait(M) \
215 mutex_enter_nowait_func((M), __FILE__, __LINE__)
217 # define mutex_exit(M) mutex_exit_func(M)
219 # define mutex_free(M) mutex_free_func(M)
234 const char* cmutex_name,
235 # ifdef UNIV_SYNC_DEBUG
239 const char* cfile_name,
258 #define mutex_enter_fast(M) mutex_enter_func((M), __FILE__, __LINE__)
269 const char* file_name,
281 const char* file_name,
294 #ifdef UNIV_PFS_MUTEX
303 pfs_mutex_create_func(
308 const char* cmutex_name,
309 # ifdef UNIV_SYNC_DEBUG
313 const char* cfile_name,
322 pfs_mutex_enter_func(
325 const char* file_name,
335 pfs_mutex_enter_nowait_func(
338 const char* file_name,
365 #ifdef UNIV_SYNC_DEBUG
372 sync_all_freed(
void);
409 __attribute__((warn_unused_result));
411 #ifdef UNIV_SYNC_DEBUG
418 sync_thread_add_level(
424 __attribute__((nonnull));
432 sync_thread_reset_level(
441 sync_thread_levels_contains(
450 sync_thread_levels_nonempty_gen(
452 ibool dict_mutex_allowed)
454 __attribute__((warn_unused_result));
458 #define sync_thread_levels_empty_except_dict() \
459 (!sync_thread_levels_nonempty_gen(TRUE))
466 sync_thread_levels_nonempty_trx(
468 ibool has_search_latch)
471 __attribute__((warn_unused_result));
477 mutex_get_debug_info(
480 const char** file_name,
489 mutex_n_reserved(
void);
500 #ifdef UNIV_SYNC_DEBUG
649 #define SYNC_USER_TRX_LOCK 9999
650 #define SYNC_NO_ORDER_CHECK 3000
652 #define SYNC_LEVEL_VARYING 2000
658 #define SYNC_TRX_I_S_RWLOCK 1910
660 #define SYNC_TRX_I_S_LAST_READ 1900
662 #define SYNC_FILE_FORMAT_TAG 1200
664 #define SYNC_DICT_OPERATION 1010
668 #define SYNC_FTS_CACHE 1005
669 #define SYNC_DICT 1000
670 #define SYNC_DICT_AUTOINC_MUTEX 999
671 #define SYNC_STATS_AUTO_RECALC 997
672 #define SYNC_DICT_HEADER 995
673 #define SYNC_IBUF_HEADER 914
674 #define SYNC_IBUF_PESS_INSERT_MUTEX 912
676 #define SYNC_INDEX_TREE 900
677 #define SYNC_TREE_NODE_NEW 892
678 #define SYNC_TREE_NODE_FROM_HASH 891
679 #define SYNC_TREE_NODE 890
680 #define SYNC_PURGE_LATCH 800
681 #define SYNC_TRX_UNDO 700
682 #define SYNC_RSEG 600
683 #define SYNC_RSEG_HEADER_NEW 591
684 #define SYNC_RSEG_HEADER 590
685 #define SYNC_TRX_UNDO_PAGE 570
686 #define SYNC_EXTERN_STORAGE 500
688 #define SYNC_FSP_PAGE 395
690 #define SYNC_IBUF_MUTEX 370
692 #define SYNC_IBUF_INDEX_TREE 360
693 #define SYNC_IBUF_TREE_NODE_NEW 359
694 #define SYNC_IBUF_TREE_NODE 358
695 #define SYNC_IBUF_BITMAP_MUTEX 351
696 #define SYNC_IBUF_BITMAP 350
698 #define SYNC_INDEX_ONLINE_LOG 340
702 #define SYNC_LOCK_WAIT_SYS 300
703 #define SYNC_LOCK_SYS 299
704 #define SYNC_TRX_SYS 298
706 #define SYNC_THREADS 295
707 #define SYNC_REC_LOCK 294
708 #define SYNC_TRX_SYS_HEADER 290
709 #define SYNC_PURGE_QUEUE 200
711 #define SYNC_LOG_FLUSH_ORDER 147
712 #define SYNC_RECV 168
713 #define SYNC_FTS_CACHE_INIT 166
714 #define SYNC_FTS_BG_THREADS 165
715 #define SYNC_FTS_OPTIMIZE 164 // FIXME: is this correct number, test
716 #define SYNC_WORK_QUEUE 162
717 #define SYNC_SEARCH_SYS 160
723 #define SYNC_BUF_POOL 150
724 #define SYNC_BUF_PAGE_HASH 149
725 #define SYNC_BUF_BLOCK 146
726 #define SYNC_BUF_FLUSH_LIST 145
727 #define SYNC_DOUBLEWRITE 140
728 #define SYNC_ANY_LATCH 135
729 #define SYNC_MEM_HASH 131
730 #define SYNC_MEM_POOL 130
733 #define RW_LOCK_NOT_LOCKED 350
734 #define RW_LOCK_EX 351
735 #define RW_LOCK_EXCLUSIVE 351
736 #define RW_LOCK_SHARED 352
737 #define RW_LOCK_WAIT_EX 353
738 #define SYNC_MUTEX 354
751 #if !defined(HAVE_ATOMIC_BUILTINS)
762 #ifdef UNIV_SYNC_DEBUG
763 const char* file_name;
773 # define MUTEX_MAGIC_N 979585UL
778 const char* cmutex_name;
781 #ifdef UNIV_PFS_MUTEX
782 struct PSI_mutex* pfs_psi;
791 #define SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds
796 #ifdef UNIV_SYNC_DEBUG
798 extern ibool sync_order_checks_on;
805 typedef UT_LIST_BASE_NODE_T(
ib_mutex_t) ut_list_base_node_t;
812 #ifndef HAVE_ATOMIC_BUILTINS
838 #include "sync0sync.ic"