📄 sync0sync.h
字号:
Synchronization object Notes---------------------- ----- Dictionary mutex If we have a pointer to a dictionary| object, e.g., a table, it can be| accessed without reserving the| dictionary mutex. We must have a| reservation, a memoryfix, to the| appropriate table object in this case,| and the table must be explicitly| released later.VDictionary header|V Secondary index tree latch The tree latch protects also all| the B-tree non-leaf pages. TheseV can be read with the page onlySecondary index non-leaf bufferfixed to save CPU time,| no s-latch is needed on the page.| Modification of a page requires an| x-latch on the page, however. If a| thread owns an x-latch to the tree,| it is allowed to latch non-leaf pages| even after it has acquired the fsp| latch.V Secondary index leaf The latch on the secondary index leaf| can be kept while accessing the| clustered index, to save CPU time.VClustered index tree latch To increase concurrency, the tree| latch is usually released when the| leaf page latch has been acquired.V Clustered index non-leaf|VClustered index leaf|VTransaction system header|VTransaction undo mutex The undo log entry must be written| before any index page is modified.| Transaction undo mutex is for the undo| logs the analogue of the tree latch| for a B-tree. If a thread has the| trx undo mutex reserved, it is allowed| to latch the undo log pages in any| order, and also after it has acquired| the fsp latch. VRollback segment mutex The rollback segment mutex must be| reserved, if, e.g., a new page must| be added to an undo log. The rollback| segment and the undo logs in its| history list can be seen as an| analogue of a B-tree, and the latches| reserved similarly, using a version of| lock-coupling. If an undo log must be| extended by a page when inserting an| undo log record, this corresponds to| a pessimistic insert in a B-tree.VRollback segment header|VPurge system latch|VUndo log pages If a thread owns the trx undo mutex,| or for a log in the history list, the| rseg mutex, it is allowed to latch| undo log pages in any order, and even| after it has acquired the fsp latch.| If a thread does not have the| appropriate mutex, it is allowed to| latch only a single undo log page in| a mini-transaction.VFile space management latch If a mini-transaction must allocate| several file pages, it can do that,| because it keeps the x-latch to the| file space management in its memo.VFile system pages|VKernel mutex If a kernel operation needs a file| page allocation, it must reserve the| fsp x-latch before acquiring the kernel| mutex.VSearch system mutex|VBuffer pool mutex|VLog mutex|Any other latch|VMemory pool mutex *//* Latching order levels *//* User transaction locks are higher than any of the latch levels below:no latches are allowed when a thread goes to wait for a normal tableor row lock! */#define SYNC_USER_TRX_LOCK 9999#define SYNC_NO_ORDER_CHECK 3000 /* this can be used to suppress latching order checking */#define SYNC_LEVEL_NONE 2000 /* default: level not defined */#define SYNC_DICT_OPERATION 1001 /* table create, drop, etc. reserve this in X-mode, implicit or backround operations purge, rollback, foreign key checks reserve this in S-mode */#define SYNC_DICT 1000#define SYNC_DICT_AUTOINC_MUTEX 999#define SYNC_DICT_HEADER 995#define SYNC_IBUF_HEADER 914#define SYNC_IBUF_PESS_INSERT_MUTEX 912#define SYNC_IBUF_MUTEX 910 /* ibuf mutex is really below SYNC_FSP_PAGE: we assign a value this high only to make the program to pass the debug checks *//*-------------------------------*/#define SYNC_INDEX_TREE 900#define SYNC_TREE_NODE_NEW 892#define SYNC_TREE_NODE_FROM_HASH 891#define SYNC_TREE_NODE 890#define SYNC_PURGE_SYS 810#define SYNC_PURGE_LATCH 800#define SYNC_TRX_UNDO 700#define SYNC_RSEG 600#define SYNC_RSEG_HEADER_NEW 591#define SYNC_RSEG_HEADER 590#define SYNC_TRX_UNDO_PAGE 570#define SYNC_EXTERN_STORAGE 500#define SYNC_FSP 400#define SYNC_FSP_PAGE 395/*------------------------------------- Insert buffer headers */ /*------------------------------------- ibuf_mutex *//*------------------------------------- Insert buffer tree */#define SYNC_IBUF_BITMAP_MUTEX 351#define SYNC_IBUF_BITMAP 350/*------------------------------------- MySQL query cache mutex *//*------------------------------------- MySQL binlog mutex *//*-------------------------------*/#define SYNC_KERNEL 300#define SYNC_REC_LOCK 299#define SYNC_TRX_LOCK_HEAP 298#define SYNC_TRX_SYS_HEADER 290#define SYNC_LOG 170#define SYNC_RECV 168#define SYNC_SEARCH_SYS 160 /* NOTE that if we have a memory heap that can be extended to the buffer pool, its logical level is SYNC_SEARCH_SYS, as memory allocation can call routines there! Otherwise the level is SYNC_MEM_HASH. */#define SYNC_BUF_POOL 150#define SYNC_BUF_BLOCK 149#define SYNC_DOUBLEWRITE 140#define SYNC_ANY_LATCH 135#define SYNC_THR_LOCAL 133#define SYNC_MEM_HASH 131#define SYNC_MEM_POOL 130/* Codes used to designate lock operations */#define RW_LOCK_NOT_LOCKED 350#define RW_LOCK_EX 351#define RW_LOCK_EXCLUSIVE 351#define RW_LOCK_SHARED 352#define RW_LOCK_WAIT_EX 353#define SYNC_MUTEX 354/* NOTE! The structure appears here only for the compiler to know its size.Do not use its fields directly! The structure used in the spin lockimplementation of a mutual exclusion semaphore. */struct mutex_struct { ulint lock_word; /* This ulint is the target of the atomic test-and-set instruction in Win32 */#if !defined(_WIN32) || !defined(UNIV_CAN_USE_X86_ASSEMBLER) os_fast_mutex_t os_fast_mutex; /* In other systems we use this OS mutex in place of lock_word */#endif ulint waiters; /* This ulint is set to 1 if there are (or may be) threads waiting in the global wait array for this mutex to be released. Otherwise, this is 0. */ UT_LIST_NODE_T(mutex_t) list; /* All allocated mutexes are put into a list. Pointers to the next and prev. */#ifdef UNIV_SYNC_DEBUG const char* file_name; /* File where the mutex was locked */ ulint line; /* Line where the mutex was locked */ os_thread_id_t thread_id; /* Debug version: The thread id of the thread which locked the mutex. */#endif /* UNIV_SYNC_DEBUG */ ulint level; /* Level in the global latching order; default SYNC_LEVEL_NONE */ const char* cfile_name;/* File name where mutex created */ ulint cline; /* Line where created */ ulint magic_n;#ifndef UNIV_HOTBACKUP ulong count_using; /* count of times mutex used */ ulong count_spin_loop; /* count of spin loops */ ulong count_spin_rounds; /* count of spin rounds */ ulong count_os_wait; /* count of os_wait */ ulong count_os_yield; /* count of os_wait */ ulonglong lspent_time; /* mutex os_wait timer msec */ ulonglong lmax_spent_time; /* mutex os_wait timer msec */ const char* cmutex_name;/* mutex name */ ulint mutex_type;/* 0 - usual mutex 1 - rw_lock mutex */#endif /* !UNIV_HOTBACKUP */};#define MUTEX_MAGIC_N (ulint)979585/* The global array of wait cells for implementation of the databases ownmutexes and read-write locks. Appears here for debugging purposes only! */extern sync_array_t* sync_primary_wait_array;/* Constant determining how long spin wait is continued before suspendingthe thread. A value 600 rounds on a 1995 100 MHz Pentium seems to correspondto 20 microseconds. */#define SYNC_SPIN_ROUNDS srv_n_spin_wait_rounds#define SYNC_INFINITE_TIME ((ulint)(-1))/* Means that a timeout elapsed when waiting */#define SYNC_TIME_EXCEEDED (ulint)1/* The number of system calls made in this module. Intended for performancemonitoring. */extern ulint mutex_system_call_count;extern ulint mutex_exit_count;/* Latching order checks start when this is set TRUE */extern ibool sync_order_checks_on;/* This variable is set to TRUE when sync_init is called */extern ibool sync_initialized;/* Global list of database mutexes (not OS mutexes) created. */typedef UT_LIST_BASE_NODE_T(mutex_t) ut_list_base_node_t;extern ut_list_base_node_t mutex_list;/* Mutex protecting the mutex_list variable */extern mutex_t mutex_list_mutex;#ifndef UNIV_NONINL#include "sync0sync.ic"#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -