44 #ifndef UNIV_HOTBACKUP
53 #ifndef UNIV_HOTBACKUP
68 #define sync_check_iterate(A) true
71 #define rw_lock_s_lock(L) ((void)0)
72 #define rw_lock_s_unlock(L) ((void)0)
73 #define rw_lock_x_lock(L) ((void)0)
74 #define rw_lock_x_lock_nowait(L) true
75 #define rw_lock_x_unlock(L) ((void)0)
76 #define rw_lock_sx_lock(L) ((void)0)
77 #define rw_lock_sx_unlock(L) ((void)0)
78 #define rw_lock_s_lock_inline(M, P, F, L) ((void)0)
79 #define rw_lock_s_unlock_inline(M, P, F, L) ((void)0)
80 #define rw_lock_x_lock_inline(M, P, F, L) ((void)0)
81 #define rw_lock_x_unlock_inline(M, P, F, L) ((void)0)
82 #define rw_lock_sx_lock_inline(M, P, F, L) ((void)0)
83 #define rw_lock_sx_unlock_inline(M, P, F, L) ((void)0)
84 #define sync_check_lock(A, B) ((void)0)
85 #define rw_lock_s_lock_nowait(M, F, L) true
86 #define rw_lock_own_flagged(A, B) true
106 #define X_LOCK_DECR 0x20000000
107 #define X_LOCK_HALF_DECR 0x10000000
119 #ifndef UNIV_HOTBACKUP
120 #ifndef UNIV_PFS_RWLOCK
128 #define rw_lock_create(K, L, level) \
129 rw_lock_create_func((L), (level), #L, __FILE__, __LINE__)
131 #define rw_lock_create(K, L, level) rw_lock_create_func((L), __FILE__, __LINE__)
137 #define rw_lock_s_lock(M) rw_lock_s_lock_func((M), 0, __FILE__, __LINE__)
139 #define rw_lock_s_lock_inline(M, P, F, L) \
140 rw_lock_s_lock_func((M), (P), (F), (L))
142 #define rw_lock_s_lock_gen(M, P) \
143 rw_lock_s_lock_func((M), (P), __FILE__, __LINE__)
145 #define rw_lock_s_lock_nowait(M, F, L) rw_lock_s_lock_low((M), 0, (F), (L))
148 #define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(P, L)
150 #define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(L)
153 #define rw_lock_sx_lock(L) rw_lock_sx_lock_func((L), 0, __FILE__, __LINE__)
155 #define rw_lock_sx_lock_inline(M, P, F, L) \
156 rw_lock_sx_lock_func((M), (P), (F), (L))
158 #define rw_lock_sx_lock_gen(M, P) \
159 rw_lock_sx_lock_func((M), (P), __FILE__, __LINE__)
161 #define rw_lock_sx_lock_nowait(M, P) \
162 rw_lock_sx_lock_low((M), (P), __FILE__, __LINE__)
165 #define rw_lock_sx_unlock(L) rw_lock_sx_unlock_func(0, L)
166 #define rw_lock_sx_unlock_gen(L, P) rw_lock_sx_unlock_func(P, L)
168 #define rw_lock_sx_unlock(L) rw_lock_sx_unlock_func(L)
169 #define rw_lock_sx_unlock_gen(L, P) rw_lock_sx_unlock_func(L)
172 #define rw_lock_x_lock(M) rw_lock_x_lock_func((M), 0, __FILE__, __LINE__)
174 #define rw_lock_x_lock_inline(M, P, F, L) \
175 rw_lock_x_lock_func((M), (P), (F), (L))
177 #define rw_lock_x_lock_gen(M, P) \
178 rw_lock_x_lock_func((M), (P), __FILE__, __LINE__)
180 #define rw_lock_x_lock_nowait(M) \
181 rw_lock_x_lock_func_nowait((M), __FILE__, __LINE__)
183 #define rw_lock_x_lock_func_nowait_inline(M, F, L) \
184 rw_lock_x_lock_func_nowait((M), (F), (L))
187 #define rw_lock_x_unlock_gen(L, P) rw_lock_x_unlock_func(P, L)
189 #define rw_lock_x_unlock_gen(L, P) rw_lock_x_unlock_func(L)
192 #define rw_lock_free(M) rw_lock_free_func(M)
198 #define rw_lock_create(K, L, level) \
199 pfs_rw_lock_create_func((K), (L), (level), #L, __FILE__, __LINE__)
201 #define rw_lock_create(K, L, level) \
202 pfs_rw_lock_create_func((K), (L), __FILE__, __LINE__)
209 #define rw_lock_s_lock(M) pfs_rw_lock_s_lock_func((M), 0, __FILE__, __LINE__)
211 #define rw_lock_s_lock_inline(M, P, F, L) \
212 pfs_rw_lock_s_lock_func((M), (P), (F), (L))
214 #define rw_lock_s_lock_gen(M, P) \
215 pfs_rw_lock_s_lock_func((M), (P), __FILE__, __LINE__)
217 #define rw_lock_s_lock_nowait(M, F, L) pfs_rw_lock_s_lock_low((M), 0, (F), (L))
220 #define rw_lock_s_unlock_gen(L, P) pfs_rw_lock_s_unlock_func(P, L)
222 #define rw_lock_s_unlock_gen(L, P) pfs_rw_lock_s_unlock_func(L)
225 #define rw_lock_sx_lock(M) pfs_rw_lock_sx_lock_func((M), 0, __FILE__, __LINE__)
227 #define rw_lock_sx_lock_inline(M, P, F, L) \
228 pfs_rw_lock_sx_lock_func((M), (P), (F), (L))
230 #define rw_lock_sx_lock_gen(M, P) \
231 pfs_rw_lock_sx_lock_func((M), (P), __FILE__, __LINE__)
233 #define rw_lock_sx_lock_nowait(M, P) \
234 pfs_rw_lock_sx_lock_low((M), (P), __FILE__, __LINE__)
237 #define rw_lock_sx_unlock(L) pfs_rw_lock_sx_unlock_func(0, L)
238 #define rw_lock_sx_unlock_gen(L, P) pfs_rw_lock_sx_unlock_func(P, L)
240 #define rw_lock_sx_unlock(L) pfs_rw_lock_sx_unlock_func(L)
241 #define rw_lock_sx_unlock_gen(L, P) pfs_rw_lock_sx_unlock_func(L)
244 #define rw_lock_x_lock(M) pfs_rw_lock_x_lock_func((M), 0, __FILE__, __LINE__)
246 #define rw_lock_x_lock_inline(M, P, F, L) \
247 pfs_rw_lock_x_lock_func((M), (P), (F), (L))
249 #define rw_lock_x_lock_gen(M, P) \
250 pfs_rw_lock_x_lock_func((M), (P), __FILE__, __LINE__)
252 #define rw_lock_x_lock_nowait(M) \
253 pfs_rw_lock_x_lock_func_nowait((M), __FILE__, __LINE__)
255 #define rw_lock_x_lock_func_nowait_inline(M, F, L) \
256 pfs_rw_lock_x_lock_func_nowait((M), (F), (L))
259 #define rw_lock_x_unlock_gen(L, P) pfs_rw_lock_x_unlock_func(P, L)
261 #define rw_lock_x_unlock_gen(L, P) pfs_rw_lock_x_unlock_func(L)
264 #define rw_lock_free(M) pfs_rw_lock_free_func(M)
268 #define rw_lock_s_unlock(L) rw_lock_s_unlock_gen(L, 0)
269 #define rw_lock_x_unlock(L) rw_lock_x_unlock_gen(L, 0)
279 const char *cmutex_name,
281 const char *cfile_name,
470 #ifndef UNIV_HOTBACKUP
477 MY_ATTRIBUTE((warn_unused_result));
485 MY_ATTRIBUTE((warn_unused_result));
603 #ifdef UNIV_PFS_RWLOCK
615 virtual std::string
to_string()
const override;
647 #ifndef UNIV_HOTBACKUP
674 #ifdef UNIV_PFS_RWLOCK
693 const char *cfile_name, ulint cline);
795 const char *file_name, ulint line);
830 #include "sync0rw.ic"
static int flags[50]
Definition: hp_test1.cc:39
static uchar key[100]
Definition: mi_test2.cc:58
const std::string FILE("FILE")
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:78
The interface to the operating system condition variables.
Interface for an instrumented rwlock.
Definition: psi_rwlock_bits.h:70
All (ordered) latches, used in debugging, must derive from this class.
Definition: sync0types.h:967
Define for performance schema registration key.
Definition: sync0sync.h:50
InnoDB condition variable.
Definition: os0event.cc:66
The structure for storing debug info of an rw-lock.
Definition: sync0rw.h:632
ulint lock_type
Type of the lock: RW_LOCK_X, RW_LOCK_S, RW_LOCK_X_WAIT.
Definition: sync0rw.h:636
ulint line
Line where the rw-lock was locked.
Definition: sync0rw.h:639
UT_LIST_NODE_T(rw_lock_debug_t) list
Debug structs are linked in a two-way list.
const char * file_name
File name where the lock was obtained.
Definition: sync0rw.h:638
std::thread::id thread_id
The thread id of the thread which locked the rw-lock.
Definition: sync0rw.h:633
ulint pass
Pass value given in the lock operation.
Definition: sync0rw.h:635
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:523
std::atomic< std::thread::id > writer_thread
Thread id of writer thread.
Definition: sync0rw.h:563
uint16_t last_x_line
Line number where last time x-locked.
Definition: sync0rw.h:595
static const uint32_t MAGIC_N
For checking memory corruption.
Definition: sync0rw.h:619
virtual std::string locked_from() const override
Print where it was locked from.
Definition: sync0rw.cc:1058
UT_LIST_BASE_NODE_T(rw_lock_debug_t) debug_list
In the debug version: pointer to the debug info list of the lock.
std::atomic< bool > waiters
1: there are waiters
Definition: sync0rw.h:538
const char * cfile_name
File name where lock created.
Definition: sync0rw.h:577
rw_lock_t & operator=(const rw_lock_t &)=delete
const char * last_s_file_name
last s-lock file/line is not guaranteed to be correct
Definition: sync0rw.h:580
os_event_t wait_ex_event
Event for next-writer to wait on.
Definition: sync0rw.h:574
volatile ulint sx_recursive
number of granted SX locks.
Definition: sync0rw.h:558
bool is_block_lock
If 1 then the rw-lock is a block lock.
Definition: sync0rw.h:589
uint32_t count_os_wait
Count of os_waits.
Definition: sync0rw.h:598
rw_lock_t(const rw_lock_t &)=delete
rw_lock_t is not a copyable object, the reasoning behind this is the same as the reasoning behind why...
uint16_t last_s_line
Line number where last time s-locked.
Definition: sync0rw.h:592
struct PSI_rwlock * pfs_psi
The instrumentation hook.
Definition: sync0rw.h:605
os_event_t event
Used by sync0arr.cc for thread queueing.
Definition: sync0rw.h:570
const char * last_x_file_name
File name where last x-locked.
Definition: sync0rw.h:583
latch_level_t level
Level in the global latching order.
Definition: sync0rw.h:626
Atomic_xor_of_thread_id reader_thread
XOR of reader threads' IDs.
Definition: sync0rw.h:567
virtual std::string to_string() const override
Print the rw-lock information.
Definition: sync0rw.cc:1087
~rw_lock_t() override
Destructor.
Definition: sync0rw.h:610
std::atomic< int32_t > lock_word
Holds the state of the lock.
Definition: sync0rw.h:535
UT_LIST_NODE_T(rw_lock_t) list
All allocated rw locks are put into a list.
bool writer_is_wait_ex
This is TRUE if the writer field is RW_LOCK_X_WAIT; this field is located far from the memory update ...
Definition: sync0rw.h:555
uint32_t magic_n
Definition: sync0rw.h:620
uint16_t cline
Line where created.
Definition: sync0rw.h:586
std::atomic< bool > recursive
Default value FALSE which means the lock is non-recursive.
Definition: sync0rw.h:549
UNIV_INLINE bool pfs_rw_lock_sx_lock_low(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
Performance schema instrumented wrap function for rw_lock_sx_lock_nowait() NOTE! Please use the corre...
bool rw_lock_is_locked(rw_lock_t *lock, ulint lock_type)
Checks if somebody has locked the rw-lock in the specified mode.
Definition: sync0rw.cc:784
void rw_lock_free_func(rw_lock_t *lock)
Calling this function is obligatory only if the memory buffer containing the rw-lock is freed.
Definition: sync0rw.cc:264
UNIV_INLINE bool rw_lock_get_waiters(const rw_lock_t *lock)
Check if there are threads waiting for the rw-lock.
void rw_lock_create_func(rw_lock_t *lock, latch_level_t level, const char *cmutex_name, const char *cfile_name, ulint cline)
Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appro...
Definition: sync0rw.cc:193
void rw_lock_x_lock_func(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for ...
Definition: sync0rw.cc:602
UNIV_INLINE void pfs_rw_lock_sx_lock_func(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
Performance schema instrumented wrap function for rw_lock_sx_lock_func() NOTE! Please use the corresp...
UNIV_INLINE void rw_lock_s_lock_func(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
NOTE! Use the corresponding macro, not directly this function, except if you supply the file name and...
UNIV_INLINE void rw_lock_x_unlock_func(ulint pass, rw_lock_t *lock)
Releases an exclusive mode lock.
UNIV_INLINE void pfs_rw_lock_create_func(mysql_pfs_key_t key, rw_lock_t *lock, latch_level_t level, const char *cmutex_name, const char *cfile_name, ulint cline)
Performance schema instrumented wrap function for rw_lock_create_func() NOTE! Please use the correspo...
UNIV_INLINE bool rw_lock_x_lock_func_nowait(rw_lock_t *lock, const char *file_name, ulint line)
NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for ...
typedef UT_LIST_BASE_NODE_T(rw_lock_t) rw_lock_list_t
UNIV_INLINE void pfs_rw_lock_sx_unlock_func(ulint pass, rw_lock_t *lock)
Performance schema instrumented wrap function for rw_lock_sx_unlock_func() NOTE! Please use the corre...
void rw_lock_debug_print(FILE *f, const rw_lock_debug_t *info)
Prints info of a debug struct.
Definition: sync0rw.cc:1025
UNIV_INLINE bool rw_lock_lock_word_decr(rw_lock_t *lock, ulint amount, lint threshold)
Decrements lock_word the specified amount if it is greater than 0.
ibool rw_lock_own(rw_lock_t *lock, ulint lock_type)
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.
Definition: sync0rw.cc:883
UNIV_INLINE void pfs_rw_lock_free_func(rw_lock_t *lock)
Performance schema instrumented wrap function for rw_lock_free_func() NOTE! Please use the correspond...
UNIV_INLINE void rw_lock_s_unlock_func(ulint pass, rw_lock_t *lock)
Releases a shared mode lock.
rw_lock_list_t rw_lock_list
Definition: sync0rw.cc:170
UNIV_INLINE bool pfs_rw_lock_x_lock_func_nowait(rw_lock_t *lock, const char *file_name, ulint line)
Performance schema instrumented wrap function for rw_lock_x_lock_func_nowait() NOTE!...
bool rw_lock_sx_lock_low(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
Low-level function for acquiring an sx lock.
Definition: sync0rw.cc:526
void rw_lock_sx_lock_func(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in SX mode for the cur...
Definition: sync0rw.cc:687
UNIV_INLINE void pfs_rw_lock_x_unlock_func(ulint pass, rw_lock_t *lock)
Performance schema instrumented wrap function for rw_lock_x_unlock_func() NOTE! Please use the corres...
ib_mutex_t rw_lock_list_mutex
Definition: sync0rw.cc:171
bool rw_lock_validate(const rw_lock_t *lock)
Checks that the rw-lock has been initialized and that there are no simultaneous shared and exclusive ...
Definition: sync0rw.cc:768
void rw_lock_list_print_info(FILE *file)
Prints debug info of currently locked rw-locks.
Definition: sync0rw.cc:980
UNIV_INLINE void rw_lock_set_writer_id_and_recursion_flag(rw_lock_t *lock, bool recursive)
This function sets the lock->writer_thread and lock->recursive fields.
rw_lock_type_t
Definition: sync0rw.h:95
@ RW_SX_LATCH
Definition: sync0rw.h:98
@ RW_NO_LATCH
Definition: sync0rw.h:99
@ RW_X_LATCH
Definition: sync0rw.h:97
@ RW_S_LATCH
Definition: sync0rw.h:96
UNIV_INLINE void rw_lock_sx_unlock_func(ulint pass, rw_lock_t *lock)
Releases an sx mode lock.
UNIV_INLINE ulint rw_lock_get_writer(const rw_lock_t *lock)
Returns the write-status of the lock - this function made more sense with the old rw_lock implementat...
UNIV_INLINE void pfs_rw_lock_s_lock_func(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the correspo...
UNIV_INLINE ibool pfs_rw_lock_s_lock_low(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the correspo...
UNIV_INLINE bool rw_lock_s_lock_low(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
Low-level function which tries to lock an rw-lock in s-mode.
UNIV_INLINE ulint rw_lock_get_x_lock_count(const rw_lock_t *lock)
Returns the value of writer_count for the lock.
bool rw_lock_own_flagged(const rw_lock_t *lock, rw_lock_flags_t flags)
Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0.
Definition: sync0rw.cc:937
UNIV_INLINE lint rw_lock_lock_word_incr(rw_lock_t *lock, ulint amount)
Increments lock_word the specified amount and returns new value.
UNIV_INLINE ulint rw_lock_get_reader_count(const rw_lock_t *lock)
Returns the number of readers (s-locks).
UNIV_INLINE void pfs_rw_lock_s_unlock_func(ulint pass, rw_lock_t *lock)
Performance schema instrumented wrap function for rw_lock_s_unlock_func() NOTE! Please use the corres...
UNIV_INLINE ulint rw_lock_get_sx_lock_count(const rw_lock_t *lock)
Returns the number of sx-lock for the lock.
UNIV_INLINE void pfs_rw_lock_x_lock_func(rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
Performance schema instrumented wrap function for rw_lock_x_lock_func() NOTE! Please use the correspo...
void rw_lock_x_lock_move_ownership(rw_lock_t *lock)
This function is used in the insert buffer to move the ownership of an x-latch on a buffer frame to t...
Definition: sync0rw.cc:376
latch_level_t
Latching order levels.
Definition: sync0types.h:217
ulint rw_lock_flags_t
Definition: sync0types.h:1215
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:66
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:446