MySQL  8.0.18
Source Code Documentation
debug_sync.h
Go to the documentation of this file.
1 #ifndef DEBUG_SYNC_INCLUDED
2 #define DEBUG_SYNC_INCLUDED
3 
4 /* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License, version 2.0,
8  as published by the Free Software Foundation.
9 
10  This program is also distributed with certain software (including
11  but not limited to OpenSSL) that is licensed under separate terms,
12  as designated in a particular file or component or in included license
13  documentation. The authors of MySQL hereby grant you an additional
14  permission to link the program and your derivative works with the
15  separately licensed software that they have included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 /**
27  @file
28 
29  Declarations for the Debug Sync Facility. See debug_sync.cc for details.
30 */
31 
32 #include <stddef.h>
33 #include <sys/types.h>
34 
35 #include "m_string.h"
36 #include "my_compiler.h"
37 #include "my_inttypes.h"
38 #include "my_sharedlib.h"
39 
40 class THD;
41 
42 #if defined(ENABLED_DEBUG_SYNC)
43 
44 /* Macro to be put in the code at synchronization points. */
45 #define DEBUG_SYNC(_thd_, _sync_point_name_) \
46  do { \
47  if (unlikely(opt_debug_sync_timeout)) \
48  debug_sync(_thd_, STRING_WITH_LEN(_sync_point_name_)); \
49  } while (0)
50 
51 /* Command line option --debug-sync-timeout. See mysqld.cc. */
52 extern MYSQL_PLUGIN_IMPORT uint opt_debug_sync_timeout;
53 
54 /* Default WAIT_FOR timeout if command line option is given without argument. */
55 #define DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT 300
56 
57 /* Debug Sync prototypes. See debug_sync.cc. */
58 extern int debug_sync_init(void);
59 extern void debug_sync_end(void);
60 extern void debug_sync_init_thread(THD *thd);
61 extern void debug_sync_claim_memory_ownership(THD *thd);
62 extern void debug_sync_end_thread(THD *thd);
63 extern void debug_sync(THD *thd, const char *sync_point_name, size_t name_len);
64 extern bool debug_sync_set_action(THD *thd, const char *action_str, size_t len);
65 extern bool debug_sync_update(THD *thd, char *val_str);
66 extern uchar *debug_sync_value_ptr(THD *thd);
67 
68 /**
69  This macro simplifies when a DBUG_EXECUTE_IF will generate a given
70  signal and then will wait for another signal to continue.
71 */
72 #define DBUG_SIGNAL_WAIT_FOR(T, A, B, C) \
73  DBUG_EXECUTE_IF(A, { \
74  const char act[] = "now SIGNAL " B " WAIT_FOR " C; \
75  DBUG_ASSERT(!debug_sync_set_action(T, STRING_WITH_LEN(act))); \
76  };)
77 
78 #else /* defined(ENABLED_DEBUG_SYNC) */
79 
80 #define DEBUG_SYNC(_thd_, _sync_point_name_) /* disabled DEBUG_SYNC */
81 #define DBUG_SIGNAL_WAIT_FOR(T, A, B, C) \
82  do { \
83  } while (0)
84 
85 #endif /* defined(ENABLED_DEBUG_SYNC) */
86 
87 #endif /* DEBUG_SYNC_INCLUDED */
unsigned char uchar
Definition: my_inttypes.h:51
Some integer typedefs for easier portability.
#define MYSQL_PLUGIN_IMPORT
Definition: my_sharedlib.h:70
Functions related to handling of plugins and other dynamically loaded libraries.
Header for compiler-dependent features.
unsigned int uint
Definition: uca-dump.cc:29
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:778