summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@skysql.com>2015-02-21 11:46:22 +0200
committerJan Lindström <jan.lindstrom@skysql.com>2015-02-21 11:46:22 +0200
commit4bad32add7e33e069720f9eab1665f13376e222a (patch)
treee4003cd7e1484cd088e463666f0b00a5f4e9db52
parent6a5b07023dba5972bd50373928cd62fa97a48996 (diff)
downloadmariadb-git-bb-10.1-sema.tar.gz
Add a method to disable semaphore instrumentation.bb-10.1-sema
-rw-r--r--mysql-test/suite/innodb/t/innodb_sys_semaphore_waits-master.opt4
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_instrument_semaphores.test42
-rw-r--r--storage/innobase/handler/ha_innodb.cc7
-rw-r--r--storage/innobase/include/srv0srv.h3
-rw-r--r--storage/innobase/include/sync0rw.h3
-rw-r--r--storage/innobase/include/sync0rw.ic18
-rw-r--r--storage/innobase/include/sync0sync.h3
-rw-r--r--storage/innobase/include/sync0sync.ic8
-rw-r--r--storage/innobase/srv/srv0srv.cc6
-rw-r--r--storage/innobase/sync/sync0rw.cc17
-rw-r--r--storage/innobase/sync/sync0sync.cc22
-rw-r--r--storage/xtradb/handler/ha_innodb.cc8
-rw-r--r--storage/xtradb/include/srv0srv.h3
-rw-r--r--storage/xtradb/include/sync0rw.h3
-rw-r--r--storage/xtradb/include/sync0rw.ic18
-rw-r--r--storage/xtradb/include/sync0sync.h3
-rw-r--r--storage/xtradb/include/sync0sync.ic12
-rw-r--r--storage/xtradb/srv/srv0srv.cc6
-rw-r--r--storage/xtradb/sync/sync0rw.cc17
-rw-r--r--storage/xtradb/sync/sync0sync.cc22
20 files changed, 171 insertions, 54 deletions
diff --git a/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits-master.opt b/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits-master.opt
index 6bf084db9a8..22272485540 100644
--- a/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits-master.opt
+++ b/mysql-test/suite/innodb/t/innodb_sys_semaphore_waits-master.opt
@@ -1 +1,3 @@
---innodb-fatal-semaphore-wait-threshold=1 --innodb-sys-semaphore-waits
+--innodb-fatal-semaphore-wait-threshold=1
+--innodb-sys-semaphore-waits=1
+--innodb-instrument-semaphores=1
diff --git a/mysql-test/suite/sys_vars/t/innodb_instrument_semaphores.test b/mysql-test/suite/sys_vars/t/innodb_instrument_semaphores.test
new file mode 100644
index 00000000000..9b302be79b5
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/innodb_instrument_semaphores.test
@@ -0,0 +1,42 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # innodb_instrument_semaphores
+--echo #
+
+--echo # save the initial value
+SET @innodb_instrument_semaphores_global_saved = @@global.innodb_instrument_semaphores;
+
+--echo # default
+SELECT @@global.innodb_instrument_semaphores;
+
+--echo
+--echo # scope
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.innodb_instrument_semaphores;
+SET @@global.innodb_instrument_semaphores=OFF;
+SELECT @@global.innodb_instrument_semaphores;
+SET @@global.innodb_instrument_semaphores=ON;
+SELECT @@global.innodb_instrument_semaphores;
+
+--echo
+--echo # valid values
+SET @@global.innodb_instrument_semaphores='OFF';
+SELECT @@global.innodb_instrument_semaphores;
+SET @@global.innodb_instrument_semaphores=ON;
+SELECT @@global.innodb_instrument_semaphores;
+SET @@global.innodb_instrument_semaphores=default;
+SELECT @@global.innodb_instrument_semaphores;
+
+--echo
+--echo # invalid values
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_instrument_semaphores=NULL;
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@global.innodb_instrument_semaphores='junk';
+
+--echo
+--echo # restore the initial value
+SET @@global.innodb_instrument_semaphores = @innodb_instrument_semaphores_global_saved;
+
+--echo # End of test
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 82b8ac5a70d..f3a5afdad34 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -19221,6 +19221,12 @@ static MYSQL_SYSVAR_BOOL(scrub_force_testing,
NULL, NULL, FALSE);
#endif /* UNIV_DEBUG */
+static MYSQL_SYSVAR_BOOL(instrument_semaphores, srv_instrument_semaphores,
+ PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
+ "Enable semaphore request instrumentation. This could have some effect on performance but allows better"
+ " information on long semaphore wait problems. (Default: not enabled)",
+ 0, 0, FALSE);
+
static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(additional_mem_pool_size),
MYSQL_SYSVAR(api_trx_level),
@@ -19418,6 +19424,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
#ifdef UNIV_DEBUG
MYSQL_SYSVAR(scrub_force_testing),
#endif
+ MYSQL_SYSVAR(instrument_semaphores),
NULL
};
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index a23e9306716..31db78ae5ee 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -565,6 +565,9 @@ extern ulong srv_fatal_semaphore_wait_threshold;
/** Default encryption key used for page encryption */
extern uint srv_default_page_encryption_key;
+/** Enable semaphore request instrumentation */
+extern my_bool srv_instrument_semaphores;
+
# ifdef UNIV_PFS_THREAD
/* Keys to register InnoDB threads with performance schema */
extern mysql_pfs_key_t buf_page_cleaner_thread_key;
diff --git a/storage/innobase/include/sync0rw.h b/storage/innobase/include/sync0rw.h
index e7ec45c7a3b..cfd9776959f 100644
--- a/storage/innobase/include/sync0rw.h
+++ b/storage/innobase/include/sync0rw.h
@@ -40,6 +40,9 @@ Created 9/11/1995 Heikki Tuuri
#include "sync0sync.h"
#include "os0sync.h"
+/** Enable semaphore request instrumentation */
+extern my_bool srv_instrument_semaphores;
+
/* The following undef is to prevent a name conflict with a macro
in MySQL: */
#undef rw_lock_t
diff --git a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic
index 6c107ee6476..afd25f3a071 100644
--- a/storage/innobase/include/sync0rw.ic
+++ b/storage/innobase/include/sync0rw.ic
@@ -324,9 +324,12 @@ rw_lock_s_lock_low(
or even refer to a line that is invalid for the file name. */
lock->last_s_file_name = file_name;
lock->last_s_line = line;
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
return(TRUE); /* locking succeeded */
}
@@ -429,9 +432,12 @@ rw_lock_x_lock_func_nowait(
rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
#endif
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
+
lock->last_x_file_name = file_name;
lock->last_x_line = line;
diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h
index e02e36868e1..2ffa14fd7fb 100644
--- a/storage/innobase/include/sync0sync.h
+++ b/storage/innobase/include/sync0sync.h
@@ -42,6 +42,9 @@ Created 9/5/1995 Heikki Tuuri
#include "os0sync.h"
#include "sync0arr.h"
+/** Enable semaphore request instrumentation */
+extern my_bool srv_instrument_semaphores;
+
#if defined(UNIV_DEBUG) && !defined(UNIV_HOTBACKUP)
extern "C" my_bool timed_mutexes;
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic
index 1e305e45952..d29932b39a6 100644
--- a/storage/innobase/include/sync0sync.ic
+++ b/storage/innobase/include/sync0sync.ic
@@ -216,10 +216,12 @@ mutex_enter_func(
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
+
return; /* Succeeded! */
}
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index 07d8539836a..77b5e218723 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -76,6 +76,7 @@ Created 10/8/1995 Heikki Tuuri
#include "fil0fil.h"
#include "fil0pagecompress.h"
#include "btr0scrub.h"
+#include "fil0pageencryption.h"
#ifdef WITH_WSREP
extern int wsrep_debug;
@@ -523,7 +524,10 @@ second. */
static time_t srv_last_log_flush_time;
/** Default encryption key used for page encryption */
-UNIV_INTERN uint srv_default_page_encryption_key;
+UNIV_INTERN uint srv_default_page_encryption_key = DEFAULT_ENCRYPTION_KEY;
+
+/** Enable semaphore request instrumentation */
+UNIV_INTERN my_bool srv_instrument_semaphores = FALSE;
/* Interval in seconds at which various tasks are performed by the
master thread when server is active. In order to balance the workload,
diff --git a/storage/innobase/sync/sync0rw.cc b/storage/innobase/sync/sync0rw.cc
index 82c4914c2b3..8e5faed08dd 100644
--- a/storage/innobase/sync/sync0rw.cc
+++ b/storage/innobase/sync/sync0rw.cc
@@ -517,9 +517,11 @@ rw_lock_x_lock_wait(
file_name, line);
#endif
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
sync_array_wait_event(sync_arr, index);
#ifdef UNIV_SYNC_DEBUG
@@ -594,9 +596,12 @@ rw_lock_x_lock_low(
rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name, line);
#endif
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
+
lock->last_x_file_name = file_name;
lock->last_x_line = (unsigned int) line;
diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc
index 22769a5e9d3..78210b18c0e 100644
--- a/storage/innobase/sync/sync0sync.cc
+++ b/storage/innobase/sync/sync0sync.cc
@@ -402,10 +402,11 @@ mutex_enter_nowait_func(
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
return(0); /* Succeeded! */
}
@@ -527,10 +528,12 @@ spin_loop:
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
+
return;
}
@@ -573,10 +576,11 @@ spin_loop:
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
return;
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index b64f7701cf5..58b88c3f6c3 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -20412,6 +20412,12 @@ static MYSQL_SYSVAR_BOOL(scrub_force_testing,
NULL, NULL, FALSE);
#endif /* UNIV_DEBUG */
+static MYSQL_SYSVAR_BOOL(instrument_semaphores, srv_instrument_semaphores,
+ PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
+ "Enable semaphore request instrumentation. This could have some effect on performance but allows better"
+ " information on long semaphore wait problems. (Default: not enabled)",
+ 0, 0, FALSE);
+
static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(log_block_size),
MYSQL_SYSVAR(additional_mem_pool_size),
@@ -20646,7 +20652,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
#ifdef UNIV_DEBUG
MYSQL_SYSVAR(scrub_force_testing),
#endif
-
+ MYSQL_SYSVAR(instrument_semaphores),
NULL
};
diff --git a/storage/xtradb/include/srv0srv.h b/storage/xtradb/include/srv0srv.h
index de994e79b30..de33f767021 100644
--- a/storage/xtradb/include/srv0srv.h
+++ b/storage/xtradb/include/srv0srv.h
@@ -708,6 +708,9 @@ extern ulong srv_fatal_semaphore_wait_threshold;
/** Default encryption key used for page encryption */
extern uint srv_default_page_encryption_key;
+/** Enable semaphore request instrumentation */
+extern my_bool srv_instrument_semaphores;
+
# ifdef UNIV_PFS_THREAD
/* Keys to register InnoDB threads with performance schema */
extern mysql_pfs_key_t buf_page_cleaner_thread_key;
diff --git a/storage/xtradb/include/sync0rw.h b/storage/xtradb/include/sync0rw.h
index b02193add91..1df6a793637 100644
--- a/storage/xtradb/include/sync0rw.h
+++ b/storage/xtradb/include/sync0rw.h
@@ -40,6 +40,9 @@ Created 9/11/1995 Heikki Tuuri
#include "sync0sync.h"
#include "os0sync.h"
+/** Enable semaphore request instrumentation */
+extern my_bool srv_instrument_semaphores;
+
/* The following undef is to prevent a name conflict with a macro
in MySQL: */
#undef rw_lock_t
diff --git a/storage/xtradb/include/sync0rw.ic b/storage/xtradb/include/sync0rw.ic
index e16228f7110..72bce228170 100644
--- a/storage/xtradb/include/sync0rw.ic
+++ b/storage/xtradb/include/sync0rw.ic
@@ -381,9 +381,12 @@ rw_lock_s_lock_low(
or even refer to a line that is invalid for the file name. */
lock->last_s_file_name = file_name;
lock->last_s_line = line;
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
return(TRUE); /* locking succeeded */
}
@@ -554,9 +557,12 @@ rw_lock_x_lock_func_nowait(
rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
#endif
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
+
lock->last_x_file_name = file_name;
lock->last_x_line = line;
diff --git a/storage/xtradb/include/sync0sync.h b/storage/xtradb/include/sync0sync.h
index 2d414d31a0f..8112fff8a30 100644
--- a/storage/xtradb/include/sync0sync.h
+++ b/storage/xtradb/include/sync0sync.h
@@ -43,6 +43,9 @@ Created 9/5/1995 Heikki Tuuri
#include "sync0arr.h"
#include "ut0counter.h"
+/** Enable semaphore request instrumentation */
+extern my_bool srv_instrument_semaphores;
+
#if defined(UNIV_DEBUG) && !defined(UNIV_HOTBACKUP)
extern "C" my_bool timed_mutexes;
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
diff --git a/storage/xtradb/include/sync0sync.ic b/storage/xtradb/include/sync0sync.ic
index ed4e9e78d0c..56d9dd3063b 100644
--- a/storage/xtradb/include/sync0sync.ic
+++ b/storage/xtradb/include/sync0sync.ic
@@ -267,10 +267,12 @@ mutex_enter_func(
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
+
return; /* Succeeded! */
}
@@ -310,10 +312,10 @@ mutex_enter_func(
mutex->base_mutex.thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(&mutex->base_mutex, file_name, line);
-#else
+#endif
mutex->base_mutex.file_name = file_name;
mutex->base_mutex.line = line;
-#endif
+
return; /* Succeeded! */
}
diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc
index f3d71fac155..37adca6975b 100644
--- a/storage/xtradb/srv/srv0srv.cc
+++ b/storage/xtradb/srv/srv0srv.cc
@@ -78,6 +78,7 @@ Created 10/8/1995 Heikki Tuuri
#include "fil0pagecompress.h"
#include <my_rdtsc.h>
#include "btr0scrub.h"
+#include "fil0pageencryption.h"
/* prototypes of new functions added to ha_innodb.cc for kill_idle_transaction */
ibool innobase_thd_is_idle(const void* thd);
@@ -670,7 +671,10 @@ second. */
static time_t srv_last_log_flush_time;
/** Default encryption key used for page encryption */
-UNIV_INTERN uint srv_default_page_encryption_key;
+UNIV_INTERN uint srv_default_page_encryption_key = DEFAULT_ENCRYPTION_KEY;
+
+/** Enable semaphore request instrumentation */
+UNIV_INTERN my_bool srv_instrument_semaphores = FALSE;
/* Interval in seconds at which various tasks are performed by the
master thread when server is active. In order to balance the workload,
diff --git a/storage/xtradb/sync/sync0rw.cc b/storage/xtradb/sync/sync0rw.cc
index 89deacc8cb4..eac085513dc 100644
--- a/storage/xtradb/sync/sync0rw.cc
+++ b/storage/xtradb/sync/sync0rw.cc
@@ -658,9 +658,11 @@ rw_lock_x_lock_wait(
file_name, line);
#endif
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
sync_array_wait_event(sync_arr, index);
#ifdef UNIV_SYNC_DEBUG
@@ -746,9 +748,12 @@ rw_lock_x_lock_low(
#endif
lock->last_x_file_name = file_name;
lock->last_x_line = (unsigned int) line;
- lock->thread_id = os_thread_get_curr_id();
- lock->file_name = file_name;
- lock->line = line;
+
+ if (srv_instrument_semaphores) {
+ lock->thread_id = os_thread_get_curr_id();
+ lock->file_name = file_name;
+ lock->line = line;
+ }
return(TRUE);
}
diff --git a/storage/xtradb/sync/sync0sync.cc b/storage/xtradb/sync/sync0sync.cc
index 53ab0b51bfc..2bdaaa35a0e 100644
--- a/storage/xtradb/sync/sync0sync.cc
+++ b/storage/xtradb/sync/sync0sync.cc
@@ -463,10 +463,11 @@ mutex_enter_nowait_func(
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
return(0); /* Succeeded! */
}
@@ -610,10 +611,12 @@ spin_loop:
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
+
return;
}
@@ -667,10 +670,11 @@ spin_loop:
mutex->thread_id = os_thread_get_curr_id();
#ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line);
-#else
- mutex->file_name = file_name;
- mutex->line = line;
#endif
+ if (srv_instrument_semaphores) {
+ mutex->file_name = file_name;
+ mutex->line = line;
+ }
if (prio_mutex) {
os_atomic_decrement_ulint(