MySQL  8.0.20
Source Code Documentation
sync0rw.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2020, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2008, Google Inc.
5 
6 Portions of this file contain modifications contributed and copyrighted by
7 Google, Inc. Those modifications are gratefully acknowledged and are described
8 briefly in the InnoDB documentation. The contributions by Google are
9 incorporated with their permission, and subject to the conditions contained in
10 the file COPYING.Google.
11 
12 This program is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License, version 2.0, as published by the
14 Free Software Foundation.
15 
16 This program is also distributed with certain software (including but not
17 limited to OpenSSL) that is licensed under separate terms, as designated in a
18 particular file or component or in included license documentation. The authors
19 of MySQL hereby grant you an additional permission to link the program and
20 your derivative works with the separately licensed software that they have
21 included with MySQL.
22 
23 This program is distributed in the hope that it will be useful, but WITHOUT
24 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
25 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
26 for more details.
27 
28 You should have received a copy of the GNU General Public License along with
29 this program; if not, write to the Free Software Foundation, Inc.,
30 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 
32 *****************************************************************************/
33 
34 /** @file include/sync0rw.h
35  The read-write lock (for threads, not for database transactions)
36 
37  Created 9/11/1995 Heikki Tuuri
38  *******************************************************/
39 
40 #ifndef sync0rw_h
41 #define sync0rw_h
42 
43 #include "univ.i"
44 #ifndef UNIV_HOTBACKUP
45 #include "os0event.h"
46 #include "ut0counter.h"
47 #endif /* !UNIV_HOTBACKUP */
48 #include <atomic>
49 #include "ut0mutex.h"
50 
51 struct rw_lock_t;
52 
53 #ifndef UNIV_HOTBACKUP
54 
55 #ifdef UNIV_LIBRARY
56 
57 #ifdef UNIV_DEBUG
58 
59 /**
60 Pass-through version of rw_lock_own(), which normally checks that the
61 thread has locked the rw-lock in the specified mode.
62 @param[in] rw-lock pointer to rw-lock
63 @param[in] lock type lock type: RW_LOCK_S, RW_LOCK_X
64 @return true if success */
65 UNIV_INLINE
66 bool rw_lock_own(rw_lock_t *lock, ulint lock_type) { return (lock != nullptr); }
67 
68 #define sync_check_iterate(A) true
69 #endif /* UNIV_DEBUG */
70 
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
87 #endif /* UNIV_LIBRARY */
88 
89 /** Counters for RW locks. */
92 
93  /** number of spin waits on rw-latches,
94  resulted during shared (read) locks */
95  uint64_counter_t rw_s_spin_wait_count;
96 
97  /** number of spin loop rounds on rw-latches,
98  resulted during shared (read) locks */
99  uint64_counter_t rw_s_spin_round_count;
100 
101  /** number of OS waits on rw-latches,
102  resulted during shared (read) locks */
103  uint64_counter_t rw_s_os_wait_count;
104 
105  /** number of spin waits on rw-latches,
106  resulted during exclusive (write) locks */
107  uint64_counter_t rw_x_spin_wait_count;
108 
109  /** number of spin loop rounds on rw-latches,
110  resulted during exclusive (write) locks */
111  uint64_counter_t rw_x_spin_round_count;
112 
113  /** number of OS waits on rw-latches,
114  resulted during exclusive (write) locks */
115  uint64_counter_t rw_x_os_wait_count;
116 
117  /** number of spin waits on rw-latches,
118  resulted during sx locks */
119  uint64_counter_t rw_sx_spin_wait_count;
120 
121  /** number of spin loop rounds on rw-latches,
122  resulted during sx locks */
123  uint64_counter_t rw_sx_spin_round_count;
124 
125  /** number of OS waits on rw-latches,
126  resulted during sx locks */
127  uint64_counter_t rw_sx_os_wait_count;
128 };
129 #endif /* !UNIV_HOTBACKUP */
130 
131 /* Latch types; these are used also in btr0btr.h and mtr0mtr.h: keep the
132 numerical values smaller than 30 (smaller than BTR_MODIFY_TREE and
133 MTR_MEMO_MODIFY) and the order of the numerical values like below! and they
134 should be 2pow value to be used also as ORed combination of flag. */
140 };
141 
142 /* We decrement lock_word by X_LOCK_DECR for each x_lock. It is also the
143 start value for the lock_word, meaning that it limits the maximum number
144 of concurrent read locks before the rw_lock breaks. */
145 /* We decrement lock_word by X_LOCK_HALF_DECR for sx_lock. */
146 #define X_LOCK_DECR 0x20000000
147 #define X_LOCK_HALF_DECR 0x10000000
148 
149 #ifdef UNIV_DEBUG
150 struct rw_lock_debug_t;
151 #endif /* UNIV_DEBUG */
152 
153 typedef UT_LIST_BASE_NODE_T(rw_lock_t) rw_lock_list_t;
154 
155 extern rw_lock_list_t rw_lock_list;
156 extern ib_mutex_t rw_lock_list_mutex;
157 
158 #ifndef UNIV_HOTBACKUP
159 /** Counters for RW locks. */
161 #endif /* !UNIV_HOTBACKUP */
162 
163 #ifndef UNIV_LIBRARY
164 #ifndef UNIV_HOTBACKUP
165 #ifndef UNIV_PFS_RWLOCK
166 /** Creates, or rather, initializes an rw-lock object in a specified memory
167  location (which must be appropriately aligned). The rw-lock is initialized
168  to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free
169  is necessary only if the memory block containing it is freed.
170  if MySQL performance schema is enabled and "UNIV_PFS_RWLOCK" is
171  defined, the rwlock are instrumented with performance schema probes. */
172 #ifdef UNIV_DEBUG
173 #define rw_lock_create(K, L, level) \
174  rw_lock_create_func((L), (level), #L, __FILE__, __LINE__)
175 #else /* UNIV_DEBUG */
176 #define rw_lock_create(K, L, level) rw_lock_create_func((L), __FILE__, __LINE__)
177 #endif /* UNIV_DEBUG */
178 
179 /** NOTE! The following macros should be used in rw locking and
180  unlocking, not the corresponding function. */
181 
182 #define rw_lock_s_lock(M) rw_lock_s_lock_func((M), 0, __FILE__, __LINE__)
183 
184 #define rw_lock_s_lock_inline(M, P, F, L) \
185  rw_lock_s_lock_func((M), (P), (F), (L))
186 
187 #define rw_lock_s_lock_gen(M, P) \
188  rw_lock_s_lock_func((M), (P), __FILE__, __LINE__)
189 
190 #define rw_lock_s_lock_nowait(M, F, L) rw_lock_s_lock_low((M), 0, (F), (L))
191 
192 #ifdef UNIV_DEBUG
193 #define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(P, L)
194 #else
195 #define rw_lock_s_unlock_gen(L, P) rw_lock_s_unlock_func(L)
196 #endif /* UNIV_DEBUG */
197 
198 #define rw_lock_sx_lock(L) rw_lock_sx_lock_func((L), 0, __FILE__, __LINE__)
199 
200 #define rw_lock_sx_lock_inline(M, P, F, L) \
201  rw_lock_sx_lock_func((M), (P), (F), (L))
202 
203 #define rw_lock_sx_lock_gen(M, P) \
204  rw_lock_sx_lock_func((M), (P), __FILE__, __LINE__)
205 
206 #define rw_lock_sx_lock_nowait(M, P) \
207  rw_lock_sx_lock_low((M), (P), __FILE__, __LINE__)
208 
209 #ifdef UNIV_DEBUG
210 #define rw_lock_sx_unlock(L) rw_lock_sx_unlock_func(0, L)
211 #define rw_lock_sx_unlock_gen(L, P) rw_lock_sx_unlock_func(P, L)
212 #else /* UNIV_DEBUG */
213 #define rw_lock_sx_unlock(L) rw_lock_sx_unlock_func(L)
214 #define rw_lock_sx_unlock_gen(L, P) rw_lock_sx_unlock_func(L)
215 #endif /* UNIV_DEBUG */
216 
217 #define rw_lock_x_lock(M) rw_lock_x_lock_func((M), 0, __FILE__, __LINE__)
218 
219 #define rw_lock_x_lock_inline(M, P, F, L) \
220  rw_lock_x_lock_func((M), (P), (F), (L))
221 
222 #define rw_lock_x_lock_gen(M, P) \
223  rw_lock_x_lock_func((M), (P), __FILE__, __LINE__)
224 
225 #define rw_lock_x_lock_nowait(M) \
226  rw_lock_x_lock_func_nowait((M), __FILE__, __LINE__)
227 
228 #define rw_lock_x_lock_func_nowait_inline(M, F, L) \
229  rw_lock_x_lock_func_nowait((M), (F), (L))
230 
231 #ifdef UNIV_DEBUG
232 #define rw_lock_x_unlock_gen(L, P) rw_lock_x_unlock_func(P, L)
233 #else
234 #define rw_lock_x_unlock_gen(L, P) rw_lock_x_unlock_func(L)
235 #endif
236 
237 #define rw_lock_free(M) rw_lock_free_func(M)
238 
239 #else /* !UNIV_PFS_RWLOCK */
240 
241 /* Following macros point to Performance Schema instrumented functions. */
242 #ifdef UNIV_DEBUG
243 #define rw_lock_create(K, L, level) \
244  pfs_rw_lock_create_func((K), (L), (level), #L, __FILE__, __LINE__)
245 #else /* UNIV_DEBUG */
246 #define rw_lock_create(K, L, level) \
247  pfs_rw_lock_create_func((K), (L), __FILE__, __LINE__)
248 #endif /* UNIV_DEBUG */
249 
250 /******************************************************************
251 NOTE! The following macros should be used in rw locking and
252 unlocking, not the corresponding function. */
253 
254 #define rw_lock_s_lock(M) pfs_rw_lock_s_lock_func((M), 0, __FILE__, __LINE__)
255 
256 #define rw_lock_s_lock_inline(M, P, F, L) \
257  pfs_rw_lock_s_lock_func((M), (P), (F), (L))
258 
259 #define rw_lock_s_lock_gen(M, P) \
260  pfs_rw_lock_s_lock_func((M), (P), __FILE__, __LINE__)
261 
262 #define rw_lock_s_lock_nowait(M, F, L) pfs_rw_lock_s_lock_low((M), 0, (F), (L))
263 
264 #ifdef UNIV_DEBUG
265 #define rw_lock_s_unlock_gen(L, P) pfs_rw_lock_s_unlock_func(P, L)
266 #else
267 #define rw_lock_s_unlock_gen(L, P) pfs_rw_lock_s_unlock_func(L)
268 #endif
269 
270 #define rw_lock_sx_lock(M) pfs_rw_lock_sx_lock_func((M), 0, __FILE__, __LINE__)
271 
272 #define rw_lock_sx_lock_inline(M, P, F, L) \
273  pfs_rw_lock_sx_lock_func((M), (P), (F), (L))
274 
275 #define rw_lock_sx_lock_gen(M, P) \
276  pfs_rw_lock_sx_lock_func((M), (P), __FILE__, __LINE__)
277 
278 #define rw_lock_sx_lock_nowait(M, P) \
279  pfs_rw_lock_sx_lock_low((M), (P), __FILE__, __LINE__)
280 
281 #ifdef UNIV_DEBUG
282 #define rw_lock_sx_unlock(L) pfs_rw_lock_sx_unlock_func(0, L)
283 #define rw_lock_sx_unlock_gen(L, P) pfs_rw_lock_sx_unlock_func(P, L)
284 #else
285 #define rw_lock_sx_unlock(L) pfs_rw_lock_sx_unlock_func(L)
286 #define rw_lock_sx_unlock_gen(L, P) pfs_rw_lock_sx_unlock_func(L)
287 #endif
288 
289 #define rw_lock_x_lock(M) pfs_rw_lock_x_lock_func((M), 0, __FILE__, __LINE__)
290 
291 #define rw_lock_x_lock_inline(M, P, F, L) \
292  pfs_rw_lock_x_lock_func((M), (P), (F), (L))
293 
294 #define rw_lock_x_lock_gen(M, P) \
295  pfs_rw_lock_x_lock_func((M), (P), __FILE__, __LINE__)
296 
297 #define rw_lock_x_lock_nowait(M) \
298  pfs_rw_lock_x_lock_func_nowait((M), __FILE__, __LINE__)
299 
300 #define rw_lock_x_lock_func_nowait_inline(M, F, L) \
301  pfs_rw_lock_x_lock_func_nowait((M), (F), (L))
302 
303 #ifdef UNIV_DEBUG
304 #define rw_lock_x_unlock_gen(L, P) pfs_rw_lock_x_unlock_func(P, L)
305 #else
306 #define rw_lock_x_unlock_gen(L, P) pfs_rw_lock_x_unlock_func(L)
307 #endif
308 
309 #define rw_lock_free(M) pfs_rw_lock_free_func(M)
310 
311 #endif /* !UNIV_PFS_RWLOCK */
312 
313 #define rw_lock_s_unlock(L) rw_lock_s_unlock_gen(L, 0)
314 #define rw_lock_x_unlock(L) rw_lock_x_unlock_gen(L, 0)
315 
316 /** Creates, or rather, initializes an rw-lock object in a specified memory
317  location (which must be appropriately aligned). The rw-lock is initialized
318  to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free
319  is necessary only if the memory block containing it is freed. */
321  rw_lock_t *lock, /*!< in: pointer to memory */
322 #ifdef UNIV_DEBUG
323  latch_level_t level, /*!< in: level */
324  const char *cmutex_name, /*!< in: mutex name */
325 #endif /* UNIV_DEBUG */
326  const char *cfile_name, /*!< in: file name where created */
327  ulint cline); /*!< in: file line where created */
328 /** Calling this function is obligatory only if the memory buffer containing
329  the rw-lock is freed. Removes an rw-lock object from the global list. The
330  rw-lock is checked to be in the non-locked state. */
331 void rw_lock_free_func(rw_lock_t *lock); /*!< in/out: rw-lock */
332 #ifdef UNIV_DEBUG
333 /** Checks that the rw-lock has been initialized and that there are no
334  simultaneous shared and exclusive locks.
335  @return true */
336 bool rw_lock_validate(const rw_lock_t *lock); /*!< in: rw-lock */
337 #endif /* UNIV_DEBUG */
338 
339 /** Low-level function which tries to lock an rw-lock in s-mode. Performs no
340 spinning.
341 @param[in] lock pointer to rw-lock
342 @param[in] pass pass value; != 0, if the lock will be passed
343  to another thread to unlock
344 @param[in] file_name file name where lock requested
345 @param[in] line line where requested
346 @return true if success */
347 UNIV_INLINE
348 ibool rw_lock_s_lock_low(rw_lock_t *lock, ulint pass MY_ATTRIBUTE((unused)),
349  const char *file_name, ulint line);
350 
351 /** NOTE! Use the corresponding macro, not directly this function, except if
352 you supply the file name and line number. Lock an rw-lock in shared mode for
353 the current thread. If the rw-lock is locked in exclusive mode, or there is an
354 exclusive lock request waiting, the function spins a preset time (controlled
355 by srv_n_spin_wait_rounds), waiting for the lock, before suspending the thread.
356 @param[in] lock pointer to rw-lock
357 @param[in] pass pass value; != 0, if the lock will be passed
358  to another thread to unlock
359 @param[in] file_name file name where lock requested
360 @param[in] line line where requested */
361 UNIV_INLINE
362 void rw_lock_s_lock_func(rw_lock_t *lock, ulint pass, const char *file_name,
363  ulint line);
364 
365 /** NOTE! Use the corresponding macro, not directly this function! Lock an
366 rw-lock in exclusive mode for the current thread if the lock can be obtained
367 immediately.
368 @param[in] lock pointer to rw-lock
369 @param[in] file_name file name where lock requested
370 @param[in] line line where requested
371 @return true if success */
372 UNIV_INLINE
373 ibool rw_lock_x_lock_func_nowait(rw_lock_t *lock, const char *file_name,
374  ulint line);
375 
376 /** Releases a shared mode lock.
377 @param[in] pass pass value; != 0, if the lock will be passed
378  to another thread to unlock
379 @param[in,out] lock rw-lock */
380 UNIV_INLINE
382 #ifdef UNIV_DEBUG
383  ulint pass,
384 #endif /* UNIV_DEBUG */
385  rw_lock_t *lock);
386 
387 /** NOTE! Use the corresponding macro, not directly this function! Lock an
388  rw-lock in exclusive mode for the current thread. If the rw-lock is locked
389  in shared or exclusive mode, or there is an exclusive lock request waiting,
390  the function spins a preset time (controlled by srv_n_spin_wait_rounds),
391  waiting for the lock, before suspending the thread. If the same thread has an
392  x-lock on the rw-lock, locking succeed, with the following exception: if pass
393  != 0, only a single x-lock may be taken on the lock. NOTE: If the same thread
394  has an s-lock, locking does not succeed! */
396  rw_lock_t *lock, /*!< in: pointer to rw-lock */
397  ulint pass, /*!< in: pass value; != 0, if the lock will
398  be passed to another thread to unlock */
399  const char *file_name, /*!< in: file name where lock requested */
400  ulint line); /*!< in: line where requested */
401 /** Low-level function for acquiring an sx lock.
402  @return false if did not succeed, true if success. */
403 ibool rw_lock_sx_lock_low(
404  rw_lock_t *lock, /*!< in: pointer to rw-lock */
405  ulint pass, /*!< in: pass value; != 0, if the lock will
406  be passed to another thread to unlock */
407  const char *file_name, /*!< in: file name where lock requested */
408  ulint line); /*!< in: line where requested */
409 /** NOTE! Use the corresponding macro, not directly this function! Lock an
410  rw-lock in SX mode for the current thread. If the rw-lock is locked
411  in exclusive mode, or there is an exclusive lock request waiting,
412  the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting
413  for the lock, before suspending the thread. If the same thread has an x-lock
414  on the rw-lock, locking succeed, with the following exception: if pass != 0,
415  only a single sx-lock may be taken on the lock. NOTE: If the same thread has
416  an s-lock, locking does not succeed! */
418  rw_lock_t *lock, /*!< in: pointer to rw-lock */
419  ulint pass, /*!< in: pass value; != 0, if the lock will
420  be passed to another thread to unlock */
421  const char *file_name, /*!< in: file name where lock requested */
422  ulint line); /*!< in: line where requested */
423 
424 /** Releases an exclusive mode lock.
425 @param[in] pass pass value; != 0, if the lock will be passed
426  to another thread to unlock
427 @param[in,out] lock rw-lock */
428 UNIV_INLINE
430 #ifdef UNIV_DEBUG
431  ulint pass,
432 #endif /* UNIV_DEBUG */
433  rw_lock_t *lock);
434 
435 /** Releases an sx mode lock.
436 @param[in] pass pass value; != 0, if the lock will be passed
437  to another thread to unlock
438 @param[in,out] lock rw-lock */
439 UNIV_INLINE
441 #ifdef UNIV_DEBUG
442  ulint pass,
443 #endif /* UNIV_DEBUG */
444  rw_lock_t *lock);
445 
446 /** This function is used in the insert buffer to move the ownership of an
447  x-latch on a buffer frame to the current thread. The x-latch was set by
448  the buffer read operation and it protected the buffer frame while the
449  read was done. The ownership is moved because we want that the current
450  thread is able to acquire a second x-latch which is stored in an mtr.
451  This, in turn, is needed to pass the debug checks of index page
452  operations. */
454  rw_lock_t *lock); /*!< in: lock which was x-locked in the
455  buffer read */
456 #endif /* !UNIV_HOTBACKUP */
457 /** Returns the value of writer_count for the lock. Does not reserve the lock
458  mutex, so the caller must be sure it is not changed during the call.
459  @return value of writer_count */
460 UNIV_INLINE
461 ulint rw_lock_get_x_lock_count(const rw_lock_t *lock); /*!< in: rw-lock */
462 /** Returns the number of sx-lock for the lock. Does not reserve the lock
463  mutex, so the caller must be sure it is not changed during the call.
464  @return value of writer_count */
465 UNIV_INLINE
466 ulint rw_lock_get_sx_lock_count(const rw_lock_t *lock); /*!< in: rw-lock */
467 /** Check if there are threads waiting for the rw-lock.
468  @return 1 if waiters, 0 otherwise */
469 UNIV_INLINE
470 ulint rw_lock_get_waiters(const rw_lock_t *lock); /*!< in: rw-lock */
471 /** Returns the write-status of the lock - this function made more sense
472  with the old rw_lock implementation.
473  @return RW_LOCK_NOT_LOCKED, RW_LOCK_X, RW_LOCK_X_WAIT, RW_LOCK_SX */
474 UNIV_INLINE
475 ulint rw_lock_get_writer(const rw_lock_t *lock); /*!< in: rw-lock */
476 /** Returns the number of readers (s-locks).
477  @return number of readers */
478 UNIV_INLINE
479 ulint rw_lock_get_reader_count(const rw_lock_t *lock); /*!< in: rw-lock */
480 
481 /** Decrements lock_word the specified amount if it is greater than 0.
482 This is used by both s_lock and x_lock operations.
483 @param[in,out] lock rw-lock
484 @param[in] amount amount to decrement
485 @param[in] threshold threshold of judgement
486 @return true if decr occurs */
487 UNIV_INLINE
488 bool rw_lock_lock_word_decr(rw_lock_t *lock, ulint amount, lint threshold);
489 
490 /** Increments lock_word the specified amount and returns new value.
491 @param[in,out] lock rw-lock
492 @param[in] amount amount to decrement
493 @return lock->lock_word after increment */
494 UNIV_INLINE
495 lint rw_lock_lock_word_incr(rw_lock_t *lock, ulint amount);
496 
497 /** This function sets the lock->writer_thread and lock->recursive fields. Sets
498 lock->recursive field using atomic release after setting lock->writer thread to
499 ensure proper memory ordering of the two.
500 Note that it is assumed that the caller of this function effectively owns
501 the lock i.e.: nobody else is allowed to modify lock->writer_thread at this
502 point in time. The protocol is that lock->writer_thread MUST be updated BEFORE
503 the lock->recursive flag is set.
504 @param[in,out] lock lock to work on
505 @param[in] recursive true if recursion allowed */
506 UNIV_INLINE
507 void rw_lock_set_writer_id_and_recursion_flag(rw_lock_t *lock, bool recursive);
508 
509 #ifndef UNIV_HOTBACKUP
510 #ifdef UNIV_DEBUG
511 /** Checks if the thread has locked the rw-lock in the specified mode, with
512  the pass value == 0. */
513 ibool rw_lock_own(rw_lock_t *lock, /*!< in: rw-lock */
514  ulint lock_type) /*!< in: lock type: RW_LOCK_S,
515  RW_LOCK_X */
516  MY_ATTRIBUTE((warn_unused_result));
517 
518 /** Checks if the thread has locked the rw-lock in the specified mode, with
519  the pass value == 0. */
521  const rw_lock_t *lock, /*!< in: rw-lock */
522  rw_lock_flags_t flags) /*!< in: specify lock types with
523  OR of the rw_lock_flag_t values */
524  MY_ATTRIBUTE((warn_unused_result));
525 #endif /* UNIV_DEBUG */
526 #endif /* !UNIV_HOTBACKUP */
527 /** Checks if somebody has locked the rw-lock in the specified mode.
528  @return true if locked */
529 bool rw_lock_is_locked(rw_lock_t *lock, /*!< in: rw-lock */
530  ulint lock_type); /*!< in: lock type: RW_LOCK_S,
531  RW_LOCK_X or RW_LOCK_SX */
532 #ifdef UNIV_DEBUG
533 /** Prints debug info of currently locked rw-locks. */
534 void rw_lock_list_print_info(FILE *file); /*!< in: file where to print */
535 
536 /*#####################################################################*/
537 
538 /** Prints info of a debug struct. */
539 void rw_lock_debug_print(FILE *f, /*!< in: output stream */
540  const rw_lock_debug_t *info); /*!< in: debug struct */
541 #endif /* UNIV_DEBUG */
542 
543 #endif /* !UNIV_LIBRARY */
544 
545 /* NOTE! The structure appears here only for the compiler to know its size.
546 Do not use its fields directly! */
547 
548 /** The structure used in the spin lock implementation of a read-write
549 lock. Several threads may have a shared lock simultaneously in this
550 lock, but only one writer may have an exclusive lock, in which case no
551 shared locks are allowed. To prevent starving of a writer blocked by
552 readers, a writer may queue for x-lock by decrementing lock_word: no
553 new readers will be let in while the thread waits for readers to
554 exit. */
555 
556 struct rw_lock_t
557 #ifdef UNIV_DEBUG
558  : public latch_t
559 #endif /* UNIV_DEBUG */
560 {
561  rw_lock_t() = default;
562 
563  /** rw_lock_t is not a copyable object, the reasoning
564  behind this is the same as the reasoning behind why
565  std::mutex is not copyable. It is supposed to represent
566  a synchronization primitive for which copying semantics
567  do not make sense. */
568  rw_lock_t(const rw_lock_t &) = delete;
569  rw_lock_t &operator=(const rw_lock_t &) = delete;
570 
571  /** Holds the state of the lock. */
572  volatile lint lock_word;
573 
574  /** 1: there are waiters */
575  volatile ulint waiters;
576 
577  /** Default value FALSE which means the lock is non-recursive.
578  The value is typically set to TRUE making normal rw_locks recursive.
579  In case of asynchronous IO, when a non-zero value of 'pass' is
580  passed then we keep the lock non-recursive.
581 
582  This flag also tells us about the state of writer_thread field.
583  If this flag is set then writer_thread MUST contain the thread
584  id of the current x-holder or wait-x thread. This flag must be
585  reset in x_unlock functions before incrementing the lock_word */
586  std::atomic<bool> recursive;
587 
588  /** number of granted SX locks. */
589  volatile ulint sx_recursive;
590 
591  /** This is TRUE if the writer field is RW_LOCK_X_WAIT; this field
592  is located far from the memory update hotspot fields which are at
593  the start of this struct, thus we can peek this field without
594  causing much memory bus traffic */
596 
597  /** Thread id of writer thread. Is only guaranteed to have non-stale value if
598  recursive flag is set, otherwise it may contain native thread handle of a
599  thread which already released or passed the lock. */
600  std::atomic<os_thread_id_t> writer_thread;
601 
602  /** Used by sync0arr.cc for thread queueing */
604 
605  /** Event for next-writer to wait on. A thread must decrement
606  lock_word before waiting. */
608 
609  /** File name where lock created */
610  const char *cfile_name;
611 
612  /** last s-lock file/line is not guaranteed to be correct */
613  const char *last_s_file_name;
614 
615  /** File name where last x-locked */
616  const char *last_x_file_name;
617 
618  /** Line where created */
619  unsigned cline : 13;
620 
621  /** If 1 then the rw-lock is a block lock */
622  unsigned is_block_lock : 1;
623 
624  /** Line number where last time s-locked */
625  unsigned last_s_line : 14;
626 
627  /** Line number where last time x-locked */
628  unsigned last_x_line : 14;
629 
630  /** Count of os_waits. May not be accurate */
631  uint32_t count_os_wait;
632 
633  /** All allocated rw locks are put into a list */
635 
636 #ifdef UNIV_PFS_RWLOCK
637  /** The instrumentation hook */
639 #endif /* UNIV_PFS_RWLOCK */
640 
641 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
642  /** The mutex protecting rw_lock_t */
643  mutable ib_mutex_t mutex;
644 #endif /* INNODB_RW_LOCKS_USE_ATOMICS */
645 
646 #ifdef UNIV_DEBUG
647  /** Destructor */
648  virtual ~rw_lock_t() {
649  ut_ad(magic_n == MAGIC_N);
650  magic_n = 0;
651  }
652 
653  virtual std::string to_string() const;
654  virtual std::string locked_from() const;
655 
656  /** For checking memory corruption. */
657  static const uint32_t MAGIC_N = 22643;
658  uint32_t magic_n = {MAGIC_N};
659 
660  /** In the debug version: pointer to the debug info list of the lock */
662 
663  /** Level in the global latching order. */
665 #endif /* UNIV_DEBUG */
666 };
667 #ifdef UNIV_DEBUG
668 /** The structure for storing debug info of an rw-lock. All access to this
669 structure must be protected by rw_lock_debug_mutex_enter(). */
671  os_thread_id_t thread_id; /*!< The thread id of the thread which
672  locked the rw-lock */
673  ulint pass; /*!< Pass value given in the lock operation */
674  ulint lock_type; /*!< Type of the lock: RW_LOCK_X,
675  RW_LOCK_S, RW_LOCK_X_WAIT */
676  const char *file_name; /*!< File name where the lock was obtained */
677  ulint line; /*!< Line where the rw-lock was locked */
679  /*!< Debug structs are linked in a two-way
680  list */
681 };
682 #endif /* UNIV_DEBUG */
683 
684 #ifndef UNIV_LIBRARY
685 #ifndef UNIV_HOTBACKUP
686 /* For performance schema instrumentation, a new set of rwlock
687 wrap functions are created if "UNIV_PFS_RWLOCK" is defined.
688 The instrumentations are not planted directly into original
689 functions, so that we keep the underlying function as they
690 are. And in case, user wants to "take out" some rwlock from
691 instrumentation even if performance schema (UNIV_PFS_RWLOCK)
692 is defined, they can do so by reinstating APIs directly link to
693 original underlying functions.
694 The instrumented function names have prefix of "pfs_rw_lock_" vs.
695 original name prefix of "rw_lock_". Following are list of functions
696 that have been instrumented:
697 
698 rw_lock_create()
699 rw_lock_x_lock()
700 rw_lock_x_lock_gen()
701 rw_lock_x_lock_nowait()
702 rw_lock_x_unlock_gen()
703 rw_lock_s_lock()
704 rw_lock_s_lock_gen()
705 rw_lock_s_lock_nowait()
706 rw_lock_s_unlock_gen()
707 rw_lock_sx_lock()
708 rw_lock_sx_unlock_gen()
709 rw_lock_free()
710 */
711 
712 #ifdef UNIV_PFS_RWLOCK
713 /** Performance schema instrumented wrap function for rw_lock_create_func()
714 NOTE! Please use the corresponding macro rw_lock_create(), not directly this
715 function!
716 @param[in] key key registered with performance schema
717 @param[in] lock rw lock
718 @param[in] level level
719 @param[in] cmutex_name mutex name
720 @param[in] cline file line where created
721 @param[in] cfile_name file name where created */
722 UNIV_INLINE
724 #ifdef UNIV_DEBUG
725  latch_level_t level, const char *cmutex_name,
726 #endif /* UNIV_DEBUG */
727  const char *cfile_name, ulint cline);
728 
729 /** Performance schema instrumented wrap function for rw_lock_x_lock_func()
730 NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly this
731 function!
732 @param[in] lock pointer to rw-lock
733 @param[in] pass pass value; != 0, if the lock will be passed
734  to another thread to unlock
735 @param[in] file_name file name where lock requested
736 @param[in] line line where requested */
737 UNIV_INLINE
738 void pfs_rw_lock_x_lock_func(rw_lock_t *lock, ulint pass, const char *file_name,
739  ulint line);
740 
741 /** Performance schema instrumented wrap function for
742 rw_lock_x_lock_func_nowait()
743 NOTE! Please use the corresponding macro, not directly this function!
744 @param[in] lock pointer to rw-lock
745 @param[in] file_name file name where lock requested
746 @param[in] line line where requested
747 @return true if success */
748 UNIV_INLINE
749 ibool pfs_rw_lock_x_lock_func_nowait(rw_lock_t *lock, const char *file_name,
750  ulint line);
751 
752 /** Performance schema instrumented wrap function for rw_lock_s_lock_func()
753 NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this
754 function!
755 @param[in] lock pointer to rw-lock
756 @param[in] pass pass value; != 0, if the lock will be passed
757  to another thread to unlock
758 @param[in] file_name file name where lock requested
759 @param[in] line line where requested */
760 UNIV_INLINE
761 void pfs_rw_lock_s_lock_func(rw_lock_t *lock, ulint pass, const char *file_name,
762  ulint line);
763 
764 /** Performance schema instrumented wrap function for rw_lock_s_lock_func()
765 NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this
766 function!
767 @param[in] lock pointer to rw-lock
768 @param[in] pass pass value; != 0, if the lock will be passed
769  to another thread to unlock
770 @param[in] file_name file name where lock requested
771 @param[in] line line where requested
772 @return true if success */
773 UNIV_INLINE
774 ibool pfs_rw_lock_s_lock_low(rw_lock_t *lock, ulint pass, const char *file_name,
775  ulint line);
776 
777 /** Performance schema instrumented wrap function for rw_lock_x_lock_func()
778 NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly this
779 function!
780 @param[in] lock pointer to rw-lock
781 @param[in] pass pass value; != 0, if the lock will be passed
782  to another thread to unlock
783 @param[in] file_name file name where lock requested
784 @param[in] line line where requested */
785 UNIV_INLINE
786 void pfs_rw_lock_x_lock_func(rw_lock_t *lock, ulint pass, const char *file_name,
787  ulint line);
788 
789 /** Performance schema instrumented wrap function for rw_lock_s_unlock_func()
790 NOTE! Please use the corresponding macro rw_lock_s_unlock(), not directly this
791 function!
792 @param[in] pass pass value; != 0, if the lock may have been passed to
793  another thread to unlock
794 @param[in,out] lock rw-lock */
795 UNIV_INLINE
797 #ifdef UNIV_DEBUG
798  ulint pass,
799 #endif /* UNIV_DEBUG */
800  rw_lock_t *lock);
801 
802 /** Performance schema instrumented wrap function for rw_lock_x_unlock_func()
803 NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly this
804 function!
805 @param[in] pass pass value; != 0, if the lock may have been passed to
806  another thread to unlock
807 @param[in,out] lock rw-lock */
808 UNIV_INLINE
810 #ifdef UNIV_DEBUG
811  ulint pass,
812 #endif /* UNIV_DEBUG */
813  rw_lock_t *lock);
814 
815 /** Performance schema instrumented wrap function for rw_lock_sx_lock_func()
816 NOTE! Please use the corresponding macro rw_lock_sx_lock(), not directly this
817 function!
818 @param[in] lock pointer to rw-lock
819 @param[in] pass pass value; != 0, if the lock will be passed
820  to another thread to unlock
821 @param[in] file_name file name where lock requested
822 @param[in] line line where requested */
823 UNIV_INLINE
824 void pfs_rw_lock_sx_lock_func(rw_lock_t *lock, ulint pass,
825  const char *file_name, ulint line);
826 
827 /** Performance schema instrumented wrap function for rw_lock_sx_lock_nowait()
828 NOTE! Please use the corresponding macro, not directly this function!
829 @param[in] lock pointer to rw-lock
830 @param[in] pass pass value; != 0, if the lock will be passed
831  to another thread to unlock
832 @param[in] file_name file name where lock requested
833 @param[in] line line where requested */
834 UNIV_INLINE
835 ibool pfs_rw_lock_sx_lock_low(rw_lock_t *lock, ulint pass,
836  const char *file_name, ulint line);
837 
838 /** Performance schema instrumented wrap function for rw_lock_sx_unlock_func()
839 NOTE! Please use the corresponding macro rw_lock_sx_unlock(), not directly this
840 function!
841 @param[in,out] lock pointer to rw-lock
842 @param[in] pass pass value; != 0, if the lock will be passed
843  to another thread to unlock */
844 UNIV_INLINE
846 #ifdef UNIV_DEBUG
847  ulint pass,
848 #endif /* UNIV_DEBUG */
849  rw_lock_t *lock);
850 
851 /** Performance schema instrumented wrap function for rw_lock_free_func()
852  NOTE! Please use the corresponding macro rw_lock_free(), not directly
853  this function! */
854 UNIV_INLINE
855 void pfs_rw_lock_free_func(rw_lock_t *lock); /*!< in: rw-lock */
856 #endif /* UNIV_PFS_RWLOCK */
857 
858 #include "sync0rw.ic"
859 
860 #endif /* !UNIV_HOTBACKUP */
861 
862 #endif /* !UNIV_LIBRARY */
863 #endif /* sync0rw.h */
All (ordered) latches, used in debugging, must derive from this class.
Definition: sync0types.h:960
latch_level_t
Latching order levels.
Definition: sync0types.h:209
std::atomic< os_thread_id_t > writer_thread
Thread id of writer thread.
Definition: sync0rw.h:600
ib_mutex_t mutex
The mutex protecting rw_lock_t.
Definition: sync0rw.h:643
UNIV_INLINE ulint rw_lock_get_x_lock_count(const rw_lock_t *lock)
Returns the value of writer_count for the lock.
volatile ulint sx_recursive
number of granted SX locks.
Definition: sync0rw.h:589
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:556
Definition: sync0rw.h:137
ulint pass
Pass value given in the lock operation.
Definition: sync0rw.h:673
uint64_counter_t rw_s_spin_wait_count
number of spin waits on rw-latches, resulted during shared (read) locks
Definition: sync0rw.h:95
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:595
Counter utility class.
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:933
ulint rw_lock_flags_t
Definition: sync0types.h:1194
unsigned cline
Line where created.
Definition: sync0rw.h:619
uint64_counter_t rw_x_spin_round_count
number of spin loop rounds on rw-latches, resulted during exclusive (write) locks ...
Definition: sync0rw.h:111
UNIV_INLINE ulint rw_lock_get_sx_lock_count(const rw_lock_t *lock)
Returns the number of sx-lock for the lock.
uint64_counter_t rw_sx_os_wait_count
number of OS waits on rw-latches, resulted during sx locks
Definition: sync0rw.h:127
UNIV_INLINE ibool 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! Please use the c...
volatile ulint waiters
1: there are waiters
Definition: sync0rw.h:575
class udf_list * list
typedef UT_LIST_BASE_NODE_T(rw_lock_t) rw_lock_list_t
uint64_counter_t rw_sx_spin_round_count
number of spin loop rounds on rw-latches, resulted during sx locks
Definition: sync0rw.h:123
ib_mutex_t rw_lock_list_mutex
Definition: sync0rw.cc:174
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...
const std::string FILE("FILE")
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.
virtual ~rw_lock_t()
Destructor.
Definition: sync0rw.h:648
const char * file_name
File name where the lock was obtained.
Definition: sync0rw.h:676
latch_level_t level
Level in the global latching order.
Definition: sync0rw.h:664
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.
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...
uint64_counter_t rw_s_spin_round_count
number of spin loop rounds on rw-latches, resulted during shared (read) locks
Definition: sync0rw.h:99
ibool 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:553
Definition: sync0rw.h:139
UNIV_INLINE ibool 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 ...
Counters for RW locks.
Definition: sync0rw.h:90
os_event_t wait_ex_event
Event for next-writer to wait on.
Definition: sync0rw.h:607
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...
The structure for storing debug info of an rw-lock.
Definition: sync0rw.h:670
UNIV_INLINE ibool 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...
void rw_lock_debug_print(FILE *f, const rw_lock_debug_t *info)
Prints info of a debug struct.
Definition: sync0rw.cc:1081
const char * last_x_file_name
File name where last x-locked.
Definition: sync0rw.h:616
os_event_t event
Used by sync0arr.cc for thread queueing.
Definition: sync0rw.h:603
static std::mutex lock
Definition: net_ns.cc:55
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:271
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 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...
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:722
UNIV_INLINE void rw_lock_x_unlock_func(ulint pass, rw_lock_t *lock)
Releases an exclusive mode lock.
UNIV_INLINE ibool 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.
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:987
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...
Definition: sync0rw.h:136
UNIV_INLINE lint rw_lock_lock_word_incr(rw_lock_t *lock, ulint amount)
Increments lock_word the specified amount and returns new value.
uint64_counter_t rw_sx_spin_wait_count
number of spin waits on rw-latches, resulted during sx locks
Definition: sync0rw.h:119
rw_lock_type_t
Definition: sync0rw.h:135
Policy based mutexes.
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...
unsigned is_block_lock
If 1 then the rw-lock is a block lock.
Definition: sync0rw.h:622
static const char * key
Definition: suite_stubs.c:14
UNIV_INLINE ulint rw_lock_get_reader_count(const rw_lock_t *lock)
Returns the number of readers (s-locks).
struct PSI_rwlock * pfs_psi
The instrumentation hook.
Definition: sync0rw.h:638
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
const char * last_s_file_name
last s-lock file/line is not guaranteed to be correct
Definition: sync0rw.h:613
uint64_counter_t rw_s_os_wait_count
number of OS waits on rw-latches, resulted during shared (read) locks
Definition: sync0rw.h:103
std::atomic< bool > recursive
Default value FALSE which means the lock is non-recursive.
Definition: sync0rw.h:586
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...
rw_lock_stats_t rw_lock_stats
Counters for RW locks.
Definition: sync0rw.cc:170
uint32_t count_os_wait
Count of os_waits.
Definition: sync0rw.h:631
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:398
InnoDB condition variable.
Definition: os0event.cc:66
os_thread_id_t thread_id
The thread id of the thread which locked the rw-lock.
Definition: sync0rw.h:671
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...
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:814
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:196
std::thread::native_handle_type os_thread_id_t
Operating system thread native handle.
Definition: os0thread.h:64
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...
Definition: os0file.h:85
Definition: sync0rw.h:138
struct PSI_rwlock PSI_rwlock
Definition: psi_rwlock_bits.h:69
The interface to the operating system condition variables.
Log info(cout, "NOTE")
UNIV_INLINE ulint rw_lock_get_waiters(const rw_lock_t *lock)
Check if there are threads waiting for the rw-lock.
UNIV_INLINE void rw_lock_s_unlock_func(ulint pass, rw_lock_t *lock)
Releases a shared mode lock.
unsigned last_s_line
Line number where last time s-locked.
Definition: sync0rw.h:625
void rw_lock_list_print_info(FILE *file)
Prints debug info of currently locked rw-locks.
Definition: sync0rw.cc:1030
Define for performance schema registration key.
Definition: sync0sync.h:50
uint64_counter_t rw_x_spin_wait_count
number of spin waits on rw-latches, resulted during exclusive (write) locks
Definition: sync0rw.h:107
static int flags[50]
Definition: hp_test1.cc:39
uint64_counter_t rw_x_os_wait_count
number of OS waits on rw-latches, resulted during exclusive (write) locks
Definition: sync0rw.h:115
static std::string to_string(const LEX_STRING &str)
Definition: lex_string.h:44
const char * cfile_name
File name where lock created.
Definition: sync0rw.h:610
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...
ulint line
Line where the rw-lock was locked.
Definition: sync0rw.h:677
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:834
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:627
ulint lock_type
Type of the lock: RW_LOCK_X, RW_LOCK_S, RW_LOCK_X_WAIT.
Definition: sync0rw.h:674
rw_lock_list_t rw_lock_list
Definition: sync0rw.cc:173
#define UT_LIST_NODE_T(TYPE)
Definition: innodb_utility.h:40
unsigned last_x_line
Line number where last time x-locked.
Definition: sync0rw.h:628
UNIV_INLINE void rw_lock_sx_unlock_func(ulint pass, rw_lock_t *lock)
Releases an sx mode lock.
volatile lint lock_word
Holds the state of the lock.
Definition: sync0rw.h:572
ib_counter_t< uint64_t, IB_N_SLOTS > uint64_counter_t
Definition: sync0rw.h:91