summaryrefslogtreecommitdiff
path: root/storage/innobase/include/sync0debug.h
blob: 07e985465e098c015fbc12a7389c9506f67a56b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*****************************************************************************

Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, MariaDB Corporation.

Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
briefly in the InnoDB documentation. The contributions by Google are
incorporated with their permission, and subject to the conditions contained in
the file COPYING.Google.

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA

*****************************************************************************/

/**************************************************//**
@file include/sync0debug.h
Debug checks for latches, header file

Created 2012-08-21 Sunny Bains
*******************************************************/

#ifndef sync0debug_h
#define sync0debug_h

#include "univ.i"

/** Initializes the synchronization data structures. */
void
sync_check_init();

/** Free the InnoDB synchronization data structures. */
void
sync_check_close();

#ifdef UNIV_DEBUG
/** Check if it is OK to acquire the latch.
@param[in]	latch	latch type */
void
sync_check_lock_validate(const latch_t* latch);

/** Note that the lock has been granted
@param[in]	latch	latch type */
void
sync_check_lock_granted(const latch_t* latch);

/** Check if it is OK to acquire the latch.
@param[in]	latch	latch type
@param[in]	level	the level of the mutex */
void
sync_check_lock(const latch_t* latch, latch_level_t level);

/**
Check if it is OK to re-acquire the lock. */
void
sync_check_relock(const latch_t* latch);

/** Removes a latch from the thread level array if it is found there.
@param[in]	latch	to unlock */
void
sync_check_unlock(const latch_t* latch);

/** Checks if the level array for the current thread contains a
mutex or rw-latch at the specified level.
@param[in]	level	to find
@return	a matching latch, or NULL if not found */
const latch_t*
sync_check_find(latch_level_t level);

/** Checks that the level array for the current thread is empty.
Terminate iteration if the functor returns true.
@param[in]	 functor	called for each element.
@return true if the functor returns true for any element */
bool
sync_check_iterate(const sync_check_functor_t& functor);

/** Acquires the debug mutex. We cannot use the mutex defined in sync0sync,
because the debug mutex is also acquired in sync0arr while holding the OS
mutex protecting the sync array, and the ordinary mutex_enter might
recursively call routines in sync0arr, leading to a deadlock on the OS
mutex. */
void
rw_lock_debug_mutex_enter();

/** Releases the debug mutex. */
void
rw_lock_debug_mutex_exit();

#endif /* UNIV_DEBUG */

#endif /* !sync0debug_h */