From 4d57b851a0335ac098d46dad5b9f698ff2cd3e43 Mon Sep 17 00:00:00 2001 From: Ingo Struewing Date: Tue, 29 Sep 2009 17:38:40 +0200 Subject: WL#4259 - Debug Sync Facility Backport from 6.0 to 5.1. Only those sync points are included, which are used in debug_sync.test. The Debug Sync Facility allows to place synchronization points in the code: open_tables(...) DEBUG_SYNC(thd, "after_open_tables"); lock_tables(...) When activated, a sync point can - Send a signal and/or - Wait for a signal Nomenclature: - signal: A value of a global variable that persists until overwritten by a new signal. The global variable can also be seen as a "signal post" or "flag mast". Then the signal is what is attached to the "signal post" or "flag mast". - send a signal: Assign the value (the signal) to the global variable ("set a flag") and broadcast a global condition to wake those waiting for a signal. - wait for a signal: Loop over waiting for the global condition until the global value matches the wait-for signal. Please find more information in the top comment in debug_sync.cc or in the worklog entry. .bzrignore: WL#4259 - Debug Sync Facility Added the symbolic link libmysqld/debug_sync.cc. CMakeLists.txt: WL#4259 - Debug Sync Facility Added definition for ENABLED_DEBUG_SYNC. configure.in: WL#4259 - Debug Sync Facility Added definition for ENABLED_DEBUG_SYNC. include/my_sys.h: WL#4259 - Debug Sync Facility Added definition for the DEBUG_SYNC_C macro. libmysqld/CMakeLists.txt: WL#4259 - Debug Sync Facility Added sql/debug_sync.cc. libmysqld/Makefile.am: WL#4259 - Debug Sync Facility Added sql/debug_sync.cc. mysql-test/include/have_debug_sync.inc: WL#4259 - Debug Sync Facility New include file. mysql-test/mysql-test-run.pl: WL#4259 - Debug Sync Facility Added option --debug_sync_timeout. mysql-test/r/debug_sync.result: WL#4259 - Debug Sync Facility New test result. mysql-test/r/have_debug_sync.require: WL#4259 - Debug Sync Facility New require file. mysql-test/t/debug_sync.test: WL#4259 - Debug Sync Facility New test file. mysys/my_static.c: WL#4259 - Debug Sync Facility Added definition for debug_sync_C_callback_ptr. mysys/thr_lock.c: WL#4259 - Debug Sync Facility Added sync point "wait_for_lock". sql/CMakeLists.txt: WL#4259 - Debug Sync Facility Added debug_sync.cc and debug_sync.h. sql/Makefile.am: WL#4259 - Debug Sync Facility Added debug_sync.cc and debug_sync.h. sql/debug_sync.cc: WL#4259 - Debug Sync Facility New source file. sql/debug_sync.h: WL#4259 - Debug Sync Facility New header file. sql/mysqld.cc: WL#4259 - Debug Sync Facility Added opt_debug_sync_timeout. Added calls to debug_sync_init() and debug_sync_end(). Fixed a purecov comment (unrelated). sql/set_var.cc: WL#4259 - Debug Sync Facility Added server variable "debug_sync". sql/set_var.h: WL#4259 - Debug Sync Facility Added declaration for server variable "debug_sync". sql/share/errmsg.txt: WL#4259 - Debug Sync Facility Added error messages ER_DEBUG_SYNC_TIMEOUT and ER_DEBUG_SYNC_HIT_LIMIT. sql/sql_base.cc: WL#4259 - Debug Sync Facility Added sync points "after_flush_unlock" and "before_lock_tables_takes_lock". sql/sql_class.cc: WL#4259 - Debug Sync Facility Added initialization for debug_sync_control to THD::THD. Added calls to debug_sync_init_thread() and debug_sync_end_thread(). sql/sql_class.h: WL#4259 - Debug Sync Facility Added element debug_sync_control to THD. storage/myisam/myisamchk.c: Fixed a typo in an error message string (unrelated). --- sql/debug_sync.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sql/debug_sync.h (limited to 'sql/debug_sync.h') diff --git a/sql/debug_sync.h b/sql/debug_sync.h new file mode 100644 index 00000000000..f4cd0b364cf --- /dev/null +++ b/sql/debug_sync.h @@ -0,0 +1,60 @@ +#ifndef DEBUG_SYNC_INCLUDED +#define DEBUG_SYNC_INCLUDED + +/* Copyright (C) 2008 Sun Microsystems, Inc. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/** + @file + + Declarations for the Debug Sync Facility. See debug_sync.cc for details. +*/ + +#ifdef USE_PRAGMA_INTERFACE +#pragma interface /* gcc class implementation */ +#endif + +#include + +class THD; + +#if defined(ENABLED_DEBUG_SYNC) + +/* Macro to be put in the code at synchronization points. */ +#define DEBUG_SYNC(_thd_, _sync_point_name_) \ + do { if (unlikely(opt_debug_sync_timeout)) \ + debug_sync(_thd_, STRING_WITH_LEN(_sync_point_name_)); \ + } while (0) + +/* Command line option --debug-sync-timeout. See mysqld.cc. */ +extern uint opt_debug_sync_timeout; + +/* Default WAIT_FOR timeout if command line option is given without argument. */ +#define DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT 300 + +/* Debug Sync prototypes. See debug_sync.cc. */ +extern int debug_sync_init(void); +extern void debug_sync_end(void); +extern void debug_sync_init_thread(THD *thd); +extern void debug_sync_end_thread(THD *thd); +extern void debug_sync(THD *thd, const char *sync_point_name, size_t name_len); + +#else /* defined(ENABLED_DEBUG_SYNC) */ + +#define DEBUG_SYNC(_thd_, _sync_point_name_) /* disabled DEBUG_SYNC */ + +#endif /* defined(ENABLED_DEBUG_SYNC) */ + +#endif /* DEBUG_SYNC_INCLUDED */ -- cgit v1.2.1