diff options
Diffstat (limited to 'plugin/semisync')
-rw-r--r-- | plugin/semisync/CMakeLists.txt | 28 | ||||
-rw-r--r-- | plugin/semisync/Makefile.am | 4 | ||||
-rw-r--r-- | plugin/semisync/semisync.h | 4 | ||||
-rw-r--r-- | plugin/semisync/semisync_master.cc | 24 | ||||
-rw-r--r-- | plugin/semisync/semisync_master.h | 15 | ||||
-rw-r--r-- | plugin/semisync/semisync_master_plugin.cc | 37 | ||||
-rw-r--r-- | plugin/semisync/semisync_slave_plugin.cc | 1 |
7 files changed, 76 insertions, 37 deletions
diff --git a/plugin/semisync/CMakeLists.txt b/plugin/semisync/CMakeLists.txt index d42510fab18..2ebd67292f3 100644 --- a/plugin/semisync/CMakeLists.txt +++ b/plugin/semisync/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2006 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 @@ -13,23 +13,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# This is CMakeLists.txt for semi-sync replication plugins -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# Add common include directories -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib - ${CMAKE_SOURCE_DIR}/sql - ${CMAKE_SOURCE_DIR}/regex - ${CMAKE_SOURCE_DIR}/extra/yassl/include) +SET(SEMISYNC_MASTER_SOURCES + semisync.cc semisync_master.cc semisync_master_plugin.cc + semisync.h semisync_master.h) -SET(SEMISYNC_MASTER_SOURCES semisync.cc semisync_master.cc semisync_master_plugin.cc) -SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc semisync_slave_plugin.cc) +MYSQL_ADD_PLUGIN(semisync_master ${SEMISYNC_MASTER_SOURCES} + MODULE_ONLY MODULE_OUTPUT_NAME "semisync_master") + +SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc + semisync_slave_plugin.cc semisync.h semisync_slave.h ) +MYSQL_ADD_PLUGIN(semisync_slave ${SEMISYNC_SLAVE_SOURCES} + MODULE_ONLY MODULE_OUTPUT_NAME "semisync_slave") -ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN) -ADD_LIBRARY(semisync_master SHARED ${SEMISYNC_MASTER_SOURCES}) -TARGET_LINK_LIBRARIES(semisync_master mysqld) -ADD_LIBRARY(semisync_slave SHARED ${SEMISYNC_SLAVE_SOURCES}) -TARGET_LINK_LIBRARIES(semisync_slave mysqld) -MESSAGE("build SEMISYNC as DLL") diff --git a/plugin/semisync/Makefile.am b/plugin/semisync/Makefile.am index 27ff89aae88..0022d600f57 100644 --- a/plugin/semisync/Makefile.am +++ b/plugin/semisync/Makefile.am @@ -25,12 +25,12 @@ noinst_HEADERS = semisync.h semisync_master.h semisync_slave.h pkgplugin_LTLIBRARIES = semisync_master.la semisync_slave.la -semisync_master_la_LDFLAGS = -module +semisync_master_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices semisync_master_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_master_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_master_la_SOURCES = semisync.cc semisync_master.cc semisync_master_plugin.cc -semisync_slave_la_LDFLAGS = -module +semisync_slave_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices semisync_slave_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_slave_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN semisync_slave_la_SOURCES = semisync.cc semisync_slave.cc semisync_slave_plugin.cc diff --git a/plugin/semisync/semisync.h b/plugin/semisync/semisync.h index ced25c40534..57353f3c156 100644 --- a/plugin/semisync/semisync.h +++ b/plugin/semisync/semisync.h @@ -20,11 +20,13 @@ #define MYSQL_SERVER #define HAVE_REPLICATION -#include <mysql_priv.h> +#include <sql_priv.h> +#include "unireg.h" #include <my_global.h> #include <my_pthread.h> #include <mysql/plugin.h> #include <replication.h> +#include "log.h" /* sql_print_information */ typedef struct st_mysql_show_var SHOW_VAR; typedef struct st_mysql_sys_var SYS_VAR; diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index 20d1c6d609c..40a0833b23f 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 @@ -60,7 +60,7 @@ static unsigned long long timespec_to_usec(const struct timespec *ts) * ******************************************************************************/ -ActiveTranx::ActiveTranx(pthread_mutex_t *lock, +ActiveTranx::ActiveTranx(mysql_mutex_t *lock, unsigned long trace_level) : Trace(trace_level), allocator_(max_connections), num_entries_(max_connections << 1), /* Transaction hash table size @@ -358,8 +358,10 @@ int ReplSemiSyncMaster::initObject() setTraceLevel(rpl_semi_sync_master_trace_level); /* 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(); @@ -434,8 +436,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_; @@ -443,17 +445,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) @@ -462,8 +464,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 982a7f77a59..e1ad28cd9f6 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 + struct TranxNode { char log_name_[FN_REFLEN]; my_off_t log_pos_; @@ -280,7 +286,6 @@ private: } }; - /** This class manages memory for active transaction list. @@ -300,7 +305,7 @@ private: TranxNode **trx_htb_; /* A hash table on active 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(); @@ -323,7 +328,7 @@ private: } public: - ActiveTranx(pthread_mutex_t *lock, unsigned long trace_level); + ActiveTranx(mysql_mutex_t *lock, unsigned long trace_level); ~ActiveTranx(); /* Insert an active transaction node with the specified position. @@ -372,14 +377,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..d6cc23a43b7 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 @@ -16,6 +16,7 @@ #include "semisync_master.h" +#include "sql_class.h" // THD ReplSemiSyncMaster repl_semisync; @@ -334,9 +335,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)) diff --git a/plugin/semisync/semisync_slave_plugin.cc b/plugin/semisync/semisync_slave_plugin.cc index 0bd9e1b8b21..66073f8a5e6 100644 --- a/plugin/semisync/semisync_slave_plugin.cc +++ b/plugin/semisync/semisync_slave_plugin.cc @@ -16,6 +16,7 @@ #include "semisync_slave.h" +#include <mysql.h> ReplSemiSyncSlave repl_semisync; |