MySQL  8.0.22
Source Code Documentation
sync0rw.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2020, Oracle and/or its affiliates.
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] 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 #ifdef UNIV_DEBUG
378 /** @param[in] pass pass value; != 0, if the lock will be passed
379  to another thread to unlock */
380 #endif
381 /** @param[in,out] lock rw-lock */
382 UNIV_INLINE
384 #ifdef UNIV_DEBUG
385  ulint pass,
386 #endif /* UNIV_DEBUG */
387  rw_lock_t *lock);
388 
389 /** NOTE! Use the corresponding macro, not directly this function! Lock an
390  rw-lock in exclusive mode for the current thread. If the rw-lock is locked
391  in shared or exclusive mode, or there is an exclusive lock request waiting,
392  the function spins a preset time (controlled by srv_n_spin_wait_rounds),
393  waiting for the lock, before suspending the thread. If the same thread has an
394  x-lock on the rw-lock, locking succeed, with the following exception: if pass
395  != 0, only a single x-lock may be taken on the lock. NOTE: If the same thread
396  has an s-lock, locking does not succeed! */
398  rw_lock_t *lock, /*!< in: pointer to rw-lock */
399  ulint pass, /*!< in: pass value; != 0, if the lock will
400  be passed to another thread to unlock */
401  const char *file_name, /*!< in: file name where lock requested */
402  ulint line); /*!< in: line where requested */
403 /** Low-level function for acquiring an sx lock.
404  @return false if did not succeed, true if success. */
405 ibool rw_lock_sx_lock_low(
406  rw_lock_t *lock, /*!< in: pointer to rw-lock */
407  ulint pass, /*!< in: pass value; != 0, if the lock will
408  be passed to another thread to unlock */
409  const char *file_name, /*!< in: file name where lock requested */
410  ulint line); /*!< in: line where requested */
411 /** NOTE! Use the corresponding macro, not directly this function! Lock an
412  rw-lock in SX mode for the current thread. If the rw-lock is locked
413  in exclusive mode, or there is an exclusive lock request waiting,
414  the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting
415  for the lock, before suspending the thread. If the same thread has an x-lock
416  on the rw-lock, locking succeed, with the following exception: if pass != 0,
417  only a single sx-lock may be taken on the lock. NOTE: If the same thread has
418  an s-lock, locking does not succeed! */
420  rw_lock_t *lock, /*!< in: pointer to rw-lock */
421  ulint pass, /*!< in: pass value; != 0, if the lock will
422  be passed to another thread to unlock */
423  const char *file_name, /*!< in: file name where lock requested */
424  ulint line); /*!< in: line where requested */
425 
426 /** Releases an exclusive mode lock. */
427 #ifdef UNIV_DEBUG
428 /** @param[in] pass pass value; != 0, if the lock will be passed
429  to another thread to unlock */
430 #endif /* UNIV_DEBUG */
431 /** @param[in,out] lock rw-lock */
432 UNIV_INLINE
434 #ifdef UNIV_DEBUG
435  ulint pass,
436 #endif /* UNIV_DEBUG */
437  rw_lock_t *lock);
438 
439 /** Releases an sx mode lock. */
440 #ifdef UNIV_DEBUG
441 /** @param[in] pass pass value; != 0, if the lock will be passed
442  to another thread to unlock */
443 #endif /* UNIV_DEBUG */
444 /** @param[in,out] lock rw-lock */
445 UNIV_INLINE
447 #ifdef UNIV_DEBUG
448  ulint pass,
449 #endif /* UNIV_DEBUG */
450  rw_lock_t *lock);
451 
452 /** This function is used in the insert buffer to move the ownership of an
453  x-latch on a buffer frame to the current thread. The x-latch was set by
454  the buffer read operation and it protected the buffer frame while the
455  read was done. The ownership is moved because we want that the current
456  thread is able to acquire a second x-latch which is stored in an mtr.
457  This, in turn, is needed to pass the debug checks of index page
458  operations. */
460  rw_lock_t *lock); /*!< in: lock which was x-locked in the
461  buffer read */
462 #endif /* !UNIV_HOTBACKUP */
463 /** Returns the value of writer_count for the lock. Does not reserve the lock
464  mutex, so the caller must be sure it is not changed during the call.
465  @return value of writer_count */
466 UNIV_INLINE
467 ulint rw_lock_get_x_lock_count(const rw_lock_t *lock); /*!< in: rw-lock */
468 /** Returns the number of sx-lock for the lock. Does not reserve the lock
469  mutex, so the caller must be sure it is not changed during the call.
470  @return value of writer_count */
471 UNIV_INLINE
472 ulint rw_lock_get_sx_lock_count(const rw_lock_t *lock); /*!< in: rw-lock */
473 /** Check if there are threads waiting for the rw-lock.
474  @return 1 if waiters, 0 otherwise */
475 UNIV_INLINE
476 ulint rw_lock_get_waiters(const rw_lock_t *lock); /*!< in: rw-lock */
477 /** Returns the write-status of the lock - this function made more sense
478  with the old rw_lock implementation.
479  @return RW_LOCK_NOT_LOCKED, RW_LOCK_X, RW_LOCK_X_WAIT, RW_LOCK_SX */
480 UNIV_INLINE
481 ulint rw_lock_get_writer(const rw_lock_t *lock); /*!< in: rw-lock */
482 /** Returns the number of readers (s-locks).
483  @return number of readers */
484 UNIV_INLINE
485 ulint rw_lock_get_reader_count(const rw_lock_t *lock); /*!< in: rw-lock */
486 
487 /** Decrements lock_word the specified amount if it is greater than 0.
488 This is used by both s_lock and x_lock operations.
489 @param[in,out] lock rw-lock
490 @param[in] amount amount to decrement
491 @param[in] threshold threshold of judgement
492 @return true if decr occurs */
493 UNIV_INLINE
494 bool rw_lock_lock_word_decr(rw_lock_t *lock, ulint amount, lint threshold);
495 
496 /** Increments lock_word the specified amount and returns new value.
497 @param[in,out] lock rw-lock
498 @param[in] amount amount to decrement
499 @return lock->lock_word after increment */
500 UNIV_INLINE
501 lint rw_lock_lock_word_incr(rw_lock_t *lock, ulint amount);
502 
503 /** This function sets the lock->writer_thread and lock->recursive fields. Sets
504 lock->recursive field using atomic release after setting lock->writer thread to
505 ensure proper memory ordering of the two.
506 Note that it is assumed that the caller of this function effectively owns
507 the lock i.e.: nobody else is allowed to modify lock->writer_thread at this
508 point in time. The protocol is that lock->writer_thread MUST be updated BEFORE
509 the lock->recursive flag is set.
510 @param[in,out] lock lock to work on
511 @param[in] recursive true if recursion allowed */
512 UNIV_INLINE
513 void rw_lock_set_writer_id_and_recursion_flag(rw_lock_t *lock, bool recursive);
514 
515 #ifndef UNIV_HOTBACKUP
516 #ifdef UNIV_DEBUG
517 /** Checks if the thread has locked the rw-lock in the specified mode, with
518  the pass value == 0. */
519 ibool rw_lock_own(rw_lock_t *lock, /*!< in: rw-lock */
520  ulint lock_type) /*!< in: lock type: RW_LOCK_S,
521  RW_LOCK_X */
522  MY_ATTRIBUTE((warn_unused_result));
523 
524 /** Checks if the thread has locked the rw-lock in the specified mode, with
525  the pass value == 0. */
527  const rw_lock_t *lock, /*!< in: rw-lock */
528  rw_lock_flags_t flags) /*!< in: specify lock types with
529  OR of the rw_lock_flag_t values */
530  MY_ATTRIBUTE((warn_unused_result));
531 #endif /* UNIV_DEBUG */
532 #endif /* !UNIV_HOTBACKUP */
533 /** Checks if somebody has locked the rw-lock in the specified mode.
534  @return true if locked */
535 bool rw_lock_is_locked(rw_lock_t *lock, /*!< in: rw-lock */
536  ulint lock_type); /*!< in: lock type: RW_LOCK_S,
537  RW_LOCK_X or RW_LOCK_SX */
538 #ifdef UNIV_DEBUG
539 /** Prints debug info of currently locked rw-locks. */
540 void rw_lock_list_print_info(FILE *file); /*!< in: file where to print */
541 
542 /*#####################################################################*/
543 
544 /** Prints info of a debug struct.
545 @param[in] f Output stream
546 @param[in] info Debug struct */
548 
549 #endif /* UNIV_DEBUG */
550 
551 #endif /* !UNIV_LIBRARY */
552 
553 /* NOTE! The structure appears here only for the compiler to know its size.
554 Do not use its fields directly! */
555 
556 /** The structure used in the spin lock implementation of a read-write
557 lock. Several threads may have a shared lock simultaneously in this
558 lock, but only one writer may have an exclusive lock, in which case no
559 shared locks are allowed. To prevent starving of a writer blocked by
560 readers, a writer may queue for x-lock by decrementing lock_word: no
561 new readers will be let in while the thread waits for readers to
562 exit. */
563 
564 struct rw_lock_t
565 #ifdef UNIV_DEBUG
566  : public latch_t
567 #endif /* UNIV_DEBUG */
568 {
569  rw_lock_t() = default;
570 
571  /** rw_lock_t is not a copyable object, the reasoning
572  behind this is the same as the reasoning behind why
573  std::mutex is not copyable. It is supposed to represent
574  a synchronization primitive for which copying semantics
575  do not make sense. */
576  rw_lock_t(const rw_lock_t &) = delete;
577  rw_lock_t &operator=(const rw_lock_t &) = delete;
578 
579  /** Holds the state of the lock. */
580  volatile lint lock_word;
581 
582  /** 1: there are waiters */
583  volatile ulint waiters;
584 
585  /** Default value FALSE which means the lock is non-recursive.
586  The value is typically set to TRUE making normal rw_locks recursive.
587  In case of asynchronous IO, when a non-zero value of 'pass' is
588  passed then we keep the lock non-recursive.
589 
590  This flag also tells us about the state of writer_thread field.
591  If this flag is set then writer_thread MUST contain the thread
592  id of the current x-holder or wait-x thread. This flag must be
593  reset in x_unlock functions before incrementing the lock_word */
594  std::atomic<bool> recursive;
595 
596  /** number of granted SX locks. */
597  volatile ulint sx_recursive;
598 
599  /** This is TRUE if the writer field is RW_LOCK_X_WAIT; this field
600  is located far from the memory update hotspot fields which are at
601  the start of this struct, thus we can peek this field without
602  causing much memory bus traffic */
604 
605  /** Thread id of writer thread. Is only guaranteed to have non-stale value if
606  recursive flag is set, otherwise it may contain native thread handle of a
607  thread which already released or passed the lock. */
608  std::atomic<os_thread_id_t> writer_thread;
609 
610  /** Used by sync0arr.cc for thread queueing */
612 
613  /** Event for next-writer to wait on. A thread must decrement
614  lock_word before waiting. */
616 
617  /** File name where lock created */
618  const char *cfile_name;
619 
620  /** last s-lock file/line is not guaranteed to be correct */
621  const char *last_s_file_name;
622 
623  /** File name where last x-locked */
624  const char *last_x_file_name;
625 
626  /** Line where created */
627  unsigned cline : 13;
628 
629  /** If 1 then the rw-lock is a block lock */
630  unsigned is_block_lock : 1;
631 
632  /** Line number where last time s-locked */
633  unsigned last_s_line : 14;
634 
635  /** Line number where last time x-locked */
636  unsigned last_x_line : 14;
637 
638  /** Count of os_waits. May not be accurate */
639  uint32_t count_os_wait;
640 
641  /** All allocated rw locks are put into a list */
643 
644 #ifdef UNIV_PFS_RWLOCK
645  /** The instrumentation hook */
647 #endif /* UNIV_PFS_RWLOCK */
648 
649 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
650  /** The mutex protecting rw_lock_t */
651  mutable ib_mutex_t mutex;
652 #endif /* INNODB_RW_LOCKS_USE_ATOMICS */
653 
654 #ifdef UNIV_DEBUG
655  /** Destructor */
656  ~rw_lock_t() override {
657  ut_ad(magic_n == MAGIC_N);
658  magic_n = 0;
659  }
660 
661  virtual std::string to_string() const override;
662  virtual std::string locked_from() const override;
663 
664  /** For checking memory corruption. */
665  static const uint32_t MAGIC_N = 22643;
666  uint32_t magic_n = {MAGIC_N};
667 
668  /** In the debug version: pointer to the debug info list of the lock */
670 
671  /** Level in the global latching order. */
673 #endif /* UNIV_DEBUG */
674 };
675 #ifdef UNIV_DEBUG
676 /** The structure for storing debug info of an rw-lock. All access to this
677 structure must be protected by rw_lock_debug_mutex_enter(). */
679  os_thread_id_t thread_id; /*!< The thread id of the thread which
680  locked the rw-lock */
681  ulint pass; /*!< Pass value given in the lock operation */
682  ulint lock_type; /*!< Type of the lock: RW_LOCK_X,
683  RW_LOCK_S, RW_LOCK_X_WAIT */
684  const char *file_name; /*!< File name where the lock was obtained */
685  ulint line; /*!< Line where the rw-lock was locked */
687  /*!< Debug structs are linked in a two-way
688  list */
689 };
690 #endif /* UNIV_DEBUG */
691 
692 #ifndef UNIV_LIBRARY
693 #ifndef UNIV_HOTBACKUP
694 /* For performance schema instrumentation, a new set of rwlock
695 wrap functions are created if "UNIV_PFS_RWLOCK" is defined.
696 The instrumentations are not planted directly into original
697 functions, so that we keep the underlying function as they
698 are. And in case, user wants to "take out" some rwlock from
699 instrumentation even if performance schema (UNIV_PFS_RWLOCK)
700 is defined, they can do so by reinstating APIs directly link to
701 original underlying functions.
702 The instrumented function names have prefix of "pfs_rw_lock_" vs.
703 original name prefix of "rw_lock_". Following are list of functions
704 that have been instrumented:
705 
706 rw_lock_create()
707 rw_lock_x_lock()
708 rw_lock_x_lock_gen()
709 rw_lock_x_lock_nowait()
710 rw_lock_x_unlock_gen()
711 rw_lock_s_lock()
712 rw_lock_s_lock_gen()
713 rw_lock_s_lock_nowait()
714 rw_lock_s_unlock_gen()
715 rw_lock_sx_lock()
716 rw_lock_sx_unlock_gen()
717 rw_lock_free()
718 */
719 
720 #ifdef UNIV_PFS_RWLOCK
721 /** Performance schema instrumented wrap function for rw_lock_create_func()
722 NOTE! Please use the corresponding macro rw_lock_create(), not directly this
723 function!
724 @param[in] key key registered with performance schema
725 @param[in] lock rw lock */
726 #ifdef UNIV_DEBUG
727 /**
728 @param[in] level level
729 @param[in] cmutex_name mutex name */
730 #endif /* UNIV_DEBUG */
731 /**
732 @param[in] cline file line where created
733 @param[in] cfile_name file name where created */
734 UNIV_INLINE
736 #ifdef UNIV_DEBUG
737  latch_level_t level, const char *cmutex_name,
738 #endif /* UNIV_DEBUG */
739  const char *cfile_name, ulint cline);
740 
741 /** Performance schema instrumented wrap function for rw_lock_x_lock_func()
742 NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly this
743 function!
744 @param[in] lock pointer to rw-lock
745 @param[in] pass pass value; != 0, if the lock will be passed
746  to another thread to unlock
747 @param[in] file_name file name where lock requested
748 @param[in] line line where requested */
749 UNIV_INLINE
750 void pfs_rw_lock_x_lock_func(rw_lock_t *lock, ulint pass, const char *file_name,
751  ulint line);
752 
753 /** Performance schema instrumented wrap function for
754 rw_lock_x_lock_func_nowait()
755 NOTE! Please use the corresponding macro, not directly this function!
756 @param[in] lock pointer to rw-lock
757 @param[in] file_name file name where lock requested
758 @param[in] line line where requested
759 @return true if success */
760 UNIV_INLINE
761 ibool pfs_rw_lock_x_lock_func_nowait(rw_lock_t *lock, 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 UNIV_INLINE
773 void pfs_rw_lock_s_lock_func(rw_lock_t *lock, ulint pass, const char *file_name,
774  ulint line);
775 
776 /** Performance schema instrumented wrap function for rw_lock_s_lock_func()
777 NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this
778 function!
779 @param[in] lock pointer to rw-lock
780 @param[in] pass pass value; != 0, if the lock will be passed
781  to another thread to unlock
782 @param[in] file_name file name where lock requested
783 @param[in] line line where requested
784 @return true if success */
785 UNIV_INLINE
786 ibool pfs_rw_lock_s_lock_low(rw_lock_t *lock, ulint pass, const char *file_name,
787  ulint line);
788 
789 /** Performance schema instrumented wrap function for rw_lock_x_lock_func()
790 NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly this
791 function!
792 @param[in] lock pointer to rw-lock
793 @param[in] pass pass value; != 0, if the lock will be passed
794  to another thread to unlock
795 @param[in] file_name file name where lock requested
796 @param[in] line line where requested */
797 UNIV_INLINE
798 void pfs_rw_lock_x_lock_func(rw_lock_t *lock, ulint pass, const char *file_name,
799  ulint line);
800 
801 /** Performance schema instrumented wrap function for rw_lock_s_unlock_func()
802 NOTE! Please use the corresponding macro rw_lock_s_unlock(), not directly this
803 function! */
804 #ifdef UNIV_DEBUG
805 /** @param[in] pass pass value; != 0, if the lock may have been passed to
806  another thread to unlock */
807 #endif /* UNIV_DEBUG */
808 /** @param[in,out] lock rw-lock */
809 UNIV_INLINE
811 #ifdef UNIV_DEBUG
812  ulint pass,
813 #endif /* UNIV_DEBUG */
814  rw_lock_t *lock);
815 
816 /** Performance schema instrumented wrap function for rw_lock_x_unlock_func()
817 NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly this
818 function! */
819 #ifdef UNIV_DEBUG
820 /** @param[in] pass pass value; != 0, if the lock may have been passed to
821  another thread to unlock */
822 #endif /* UNIV_DEBUG */
823 /** @param[in,out] lock rw-lock */
824 UNIV_INLINE
826 #ifdef UNIV_DEBUG
827  ulint pass,
828 #endif /* UNIV_DEBUG */
829  rw_lock_t *lock);
830 
831 /** Performance schema instrumented wrap function for rw_lock_sx_lock_func()
832 NOTE! Please use the corresponding macro rw_lock_sx_lock(), not directly this
833 function!
834 @param[in] lock pointer to rw-lock
835 @param[in] pass pass value; != 0, if the lock will be passed
836  to another thread to unlock
837 @param[in] file_name file name where lock requested
838 @param[in] line line where requested */
839 UNIV_INLINE
840 void pfs_rw_lock_sx_lock_func(rw_lock_t *lock, ulint pass,
841  const char *file_name, ulint line);
842 
843 /** Performance schema instrumented wrap function for rw_lock_sx_lock_nowait()
844 NOTE! Please use the corresponding macro, not directly this function!
845 @param[in] lock pointer to rw-lock
846 @param[in] pass pass value; != 0, if the lock will be passed
847  to another thread to unlock
848 @param[in] file_name file name where lock requested
849 @param[in] line line where requested */
850 UNIV_INLINE
851 ibool pfs_rw_lock_sx_lock_low(rw_lock_t *lock, ulint pass,
852  const char *file_name, ulint line);
853 
854 /** Performance schema instrumented wrap function for rw_lock_sx_unlock_func()
855 NOTE! Please use the corresponding macro rw_lock_sx_unlock(), not directly this
856 function!
857 @param[in,out] lock pointer to rw-lock */
858 #ifdef UNIV_DEBUG
859 /** @param[in] pass pass value; != 0, if the lock will be passed
860  to another thread to unlock */
861 #endif /* UNIV_DEBUG */
862 UNIV_INLINE
864 #ifdef UNIV_DEBUG
865  ulint pass,
866 #endif /* UNIV_DEBUG */
867  rw_lock_t *lock);
868 
869 /** Performance schema instrumented wrap function for rw_lock_free_func()
870  NOTE! Please use the corresponding macro rw_lock_free(), not directly
871  this function! */
872 UNIV_INLINE
873 void pfs_rw_lock_free_func(rw_lock_t *lock); /*!< in: rw-lock */
874 #endif /* UNIV_PFS_RWLOCK */
875 
876 #include "sync0rw.ic"
877 
878 #endif /* !UNIV_HOTBACKUP */
879 
880 #endif /* !UNIV_LIBRARY */
881 #endif /* sync0rw.h */
All (ordered) latches, used in debugging, must derive from this class.
Definition: sync0types.h:967
latch_level_t
Latching order levels.
Definition: sync0types.h:217
std::atomic< os_thread_id_t > writer_thread
Thread id of writer thread.
Definition: sync0rw.h:608
ib_mutex_t mutex
The mutex protecting rw_lock_t.
Definition: sync0rw.h:651
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:597
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:564
Definition: sync0rw.h:137
ulint pass
Pass value given in the lock operation.
Definition: sync0rw.h:681
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:603
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:1215
unsigned cline
Line where created.
Definition: sync0rw.h:627
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:583
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.
const char * file_name
File name where the lock was obtained.
Definition: sync0rw.h:684
latch_level_t level
Level in the global latching order.
Definition: sync0rw.h:672
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:615
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:678
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:1083
const char * last_x_file_name
File name where last x-locked.
Definition: sync0rw.h:624
os_event_t event
Used by sync0arr.cc for thread queueing.
Definition: sync0rw.h:611
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
~rw_lock_t() override
Destructor.
Definition: sync0rw.h:656
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:630
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:646
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:66
const char * last_s_file_name
last s-lock file/line is not guaranteed to be correct
Definition: sync0rw.h:621
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:594
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:639
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:679
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:633
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:48
const char * cfile_name
File name where lock created.
Definition: sync0rw.h:618
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:685
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:682
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:636
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:580
ib_counter_t< uint64_t, IB_N_SLOTS > uint64_counter_t
Definition: sync0rw.h:91