diff options
author | Marc Alff <marc.alff@sun.com> | 2009-12-09 20:19:51 -0700 |
---|---|---|
committer | Marc Alff <marc.alff@sun.com> | 2009-12-09 20:19:51 -0700 |
commit | c082955f0676efe069f30384102ba7807b49dee6 (patch) | |
tree | cc0a038191d1969182d5dd108c891ee10a436cc0 /plugin/semisync | |
parent | 6fd3866c6c104f8bc991d71583e627ae6fabe0ab (diff) | |
download | mariadb-git-c082955f0676efe069f30384102ba7807b49dee6.tar.gz |
WL#2360 Performance schema
Part III: mysys instrumentation
Diffstat (limited to 'plugin/semisync')
-rw-r--r-- | plugin/semisync/semisync_master.cc | 24 | ||||
-rw-r--r-- | plugin/semisync/semisync_master.h | 14 | ||||
-rw-r--r-- | plugin/semisync/semisync_master_plugin.cc | 36 |
3 files changed, 58 insertions, 16 deletions
diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index cc83978ad4e..23c78eca587 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2007 Google Inc. - Copyright (C) 2008 MySQL AB + Copyright (C) 2008 MySQL AB, 2008-2009 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 @@ -64,7 +64,7 @@ static int gettimeofday(struct timeval *tv, void *tz) ******************************************************************************/ ActiveTranx::ActiveTranx(int max_connections, - pthread_mutex_t *lock, + mysql_mutex_t *lock, unsigned long trace_level) : Trace(trace_level), num_transactions_(max_connections), num_entries_(max_connections << 1), @@ -416,8 +416,10 @@ int ReplSemiSyncMaster::initObject() max_transactions_ = (int)max_connections; /* Mutex initialization can only be done after MY_INIT(). */ - pthread_mutex_init(&LOCK_binlog_, MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND_binlog_send_, NULL); + mysql_mutex_init(key_ss_mutex_LOCK_binlog_, + &LOCK_binlog_, MY_MUTEX_INIT_FAST); + mysql_cond_init(key_ss_cond_COND_binlog_send_, + &COND_binlog_send_, NULL); if (rpl_semi_sync_master_enabled) result = enableMaster(); @@ -494,8 +496,8 @@ ReplSemiSyncMaster::~ReplSemiSyncMaster() { if (init_done_) { - pthread_mutex_destroy(&LOCK_binlog_); - pthread_cond_destroy(&COND_binlog_send_); + mysql_mutex_destroy(&LOCK_binlog_); + mysql_cond_destroy(&COND_binlog_send_); } delete active_tranxs_; @@ -503,17 +505,17 @@ ReplSemiSyncMaster::~ReplSemiSyncMaster() void ReplSemiSyncMaster::lock() { - pthread_mutex_lock(&LOCK_binlog_); + mysql_mutex_lock(&LOCK_binlog_); } void ReplSemiSyncMaster::unlock() { - pthread_mutex_unlock(&LOCK_binlog_); + mysql_mutex_unlock(&LOCK_binlog_); } void ReplSemiSyncMaster::cond_broadcast() { - pthread_cond_broadcast(&COND_binlog_send_); + mysql_cond_broadcast(&COND_binlog_send_); } int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time) @@ -522,8 +524,8 @@ int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time) int wait_res; function_enter(kWho); - wait_res = pthread_cond_timedwait(&COND_binlog_send_, - &LOCK_binlog_, wait_time); + wait_res= mysql_cond_timedwait(&COND_binlog_send_, + &LOCK_binlog_, wait_time); return function_exit(kWho, wait_res); } diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h index d2b87745600..dbe8bb9d5e2 100644 --- a/plugin/semisync/semisync_master.h +++ b/plugin/semisync/semisync_master.h @@ -1,5 +1,6 @@ /* Copyright (C) 2007 Google Inc. Copyright (C) 2008 MySQL AB + Copyright (C) 2009 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 @@ -20,6 +21,11 @@ #include "semisync.h" +#ifdef HAVE_PSI_INTERFACE +extern PSI_mutex_key key_ss_mutex_LOCK_binlog_; +extern PSI_cond_key key_ss_cond_COND_binlog_send_; +#endif + /** This class manages memory for active transaction list. @@ -49,7 +55,7 @@ private: int num_transactions_; /* maximum transactions */ int num_entries_; /* maximum hash table entries */ - pthread_mutex_t *lock_; /* mutex lock */ + mysql_mutex_t *lock_; /* mutex lock */ inline void assert_lock_owner(); @@ -74,7 +80,7 @@ private: } public: - ActiveTranx(int max_connections, pthread_mutex_t *lock, + ActiveTranx(int max_connections, mysql_mutex_t *lock, unsigned long trace_level); ~ActiveTranx(); @@ -124,14 +130,14 @@ class ReplSemiSyncMaster /* This cond variable is signaled when enough binlog has been sent to slave, * so that a waiting trx can return the 'ok' to the client for a commit. */ - pthread_cond_t COND_binlog_send_; + mysql_cond_t COND_binlog_send_; /* Mutex that protects the following state variables and the active * transaction list. * Under no cirumstances we can acquire mysql_bin_log.LOCK_log if we are * already holding LOCK_binlog_ because it can cause deadlocks. */ - pthread_mutex_t LOCK_binlog_; + mysql_mutex_t LOCK_binlog_; /* This is set to true when reply_file_name_ contains meaningful data. */ bool reply_file_name_inited_; diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc index efcb7172b28..e371df3edc3 100644 --- a/plugin/semisync/semisync_master_plugin.cc +++ b/plugin/semisync/semisync_master_plugin.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2007 Google Inc. - Copyright (C) 2008 MySQL AB + Copyright (C) 2008 MySQL AB, 2008-2009 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 @@ -334,9 +334,43 @@ static SHOW_VAR semi_sync_master_status_vars[]= { {NULL, NULL, SHOW_LONG}, }; +#ifdef HAVE_PSI_INTERFACE +PSI_mutex_key key_ss_mutex_LOCK_binlog_; + +static PSI_mutex_info all_semisync_mutexes[]= +{ + { &key_ss_mutex_LOCK_binlog_, "LOCK_binlog_", 0} +}; + +PSI_cond_key key_ss_cond_COND_binlog_send_; + +static PSI_cond_info all_semisync_conds[]= +{ + { &key_ss_cond_COND_binlog_send_, "COND_binlog_send_", 0} +}; + +static void init_semisync_psi_keys(void) +{ + const char* category= "semisync"; + int count; + + if (PSI_server == NULL) + return; + + count= array_elements(all_semisync_mutexes); + PSI_server->register_mutex(category, all_semisync_mutexes, count); + + count= array_elements(all_semisync_conds); + PSI_server->register_cond(category, all_semisync_conds, count); +} +#endif /* HAVE_PSI_INTERFACE */ static int semi_sync_master_plugin_init(void *p) { +#ifdef HAVE_PSI_INTERFACE + init_semisync_psi_keys(); +#endif + if (repl_semisync.initObject()) return 1; if (register_trans_observer(&trans_observer, p)) |