summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysql/service_wsrep.h205
-rw-r--r--include/mysql/services.h1
-rw-r--r--include/service_versions.h1
-rw-r--r--libmysqld/CMakeLists.txt1
-rw-r--r--libservices/CMakeLists.txt1
-rw-r--r--libservices/wsrep_service.c20
-rw-r--r--mysql-test/r/handlersocket.result2
-rw-r--r--mysql-test/r/plugin.result6
-rw-r--r--mysql-test/suite/plugins/r/show_all_plugins.result4
-rw-r--r--sql/CMakeLists.txt2
-rw-r--r--sql/mdl.cc16
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_plugin_services.h41
-rw-r--r--sql/wsrep_dummy.cc126
-rw-r--r--sql/wsrep_mysqld.cc144
-rw-r--r--sql/wsrep_mysqld.h71
-rw-r--r--sql/wsrep_thd.cc20
-rw-r--r--sql/wsrep_thd.h5
-rw-r--r--sql/wsrep_utils.cc3
-rw-r--r--storage/innobase/handler/ha_innodb.cc91
-rw-r--r--storage/innobase/handler/ha_innodb.h33
-rw-r--r--storage/innobase/handler/handler0alter.cc4
-rw-r--r--storage/innobase/include/ha_prototypes.h13
-rw-r--r--storage/innobase/lock/lock0lock.cc7
-rw-r--r--storage/innobase/row/row0upd.cc5
-rw-r--r--storage/innobase/srv/srv0conc.cc7
-rw-r--r--storage/innobase/trx/trx0sys.cc4
-rw-r--r--storage/innobase/trx/trx0trx.cc4
-rw-r--r--storage/xtradb/handler/ha_innodb.cc50
-rw-r--r--storage/xtradb/handler/ha_innodb.h15
-rw-r--r--storage/xtradb/include/ha_prototypes.h8
-rw-r--r--storage/xtradb/lock/lock0lock.cc7
-rw-r--r--storage/xtradb/lock/lock0wait.cc2
-rw-r--r--storage/xtradb/row/row0upd.cc5
-rw-r--r--storage/xtradb/srv/srv0conc.cc7
-rw-r--r--storage/xtradb/trx/trx0roll.cc2
-rw-r--r--storage/xtradb/trx/trx0sys.cc4
-rw-r--r--storage/xtradb/trx/trx0trx.cc4
39 files changed, 617 insertions, 328 deletions
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h
new file mode 100644
index 00000000000..11872469cc7
--- /dev/null
+++ b/include/mysql/service_wsrep.h
@@ -0,0 +1,205 @@
+#ifndef MYSQL_SERVICE_WSREP_INCLUDED
+/* Copyright (c) 2013, Monty Program Ab
+
+ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+/**
+ @file
+ wsrep service
+
+ Interface to WSREP functionality in the server.
+ For engines that want to support galera.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum wsrep_conflict_state {
+ NO_CONFLICT,
+ MUST_ABORT,
+ ABORTING,
+ ABORTED,
+ MUST_REPLAY,
+ REPLAYING,
+ RETRY_AUTOCOMMIT,
+ CERT_FAILURE,
+};
+
+enum wsrep_exec_mode {
+ LOCAL_STATE,
+ REPL_RECV,
+ TOTAL_ORDER,
+ LOCAL_COMMIT
+};
+
+enum wsrep_query_state {
+ QUERY_IDLE,
+ QUERY_EXEC,
+ QUERY_COMMITTING,
+ QUERY_EXITING,
+ QUERY_ROLLINGBACK,
+};
+
+enum wsrep_trx_status {
+ WSREP_TRX_OK,
+ WSREP_TRX_CERT_FAIL, /* certification failure, must abort */
+ WSREP_TRX_SIZE_EXCEEDED, /* trx size exceeded */
+ WSREP_TRX_ERROR, /* native mysql error */
+};
+
+struct xid_t;
+struct wsrep;
+struct wsrep_ws_handle;
+struct wsrep_buf;
+
+extern struct wsrep_service_st {
+ struct wsrep * (*get_wsrep_func)();
+ my_bool (*get_wsrep_certify_nonPK_func)();
+ my_bool (*get_wsrep_debug_func)();
+ my_bool (*get_wsrep_drupal_282555_workaround_func)();
+ my_bool (*get_wsrep_load_data_splitting_func)();
+ my_bool (*get_wsrep_log_conflicts_func)();
+ long (*get_wsrep_protocol_version_func)();
+ my_bool (*wsrep_aborting_thd_contains_func)(THD *thd);
+ void (*wsrep_aborting_thd_enqueue_func)(THD *thd);
+ bool (*wsrep_consistency_check_func)(THD *thd);
+ int (*wsrep_is_wsrep_xid_func)(const struct xid_t *xid);
+ void (*wsrep_lock_rollback_func)();
+ int (*wsrep_on_func)(MYSQL_THD);
+ void (*wsrep_post_commit_func)(THD* thd, bool all);
+ bool (*wsrep_prepare_key_func)(const unsigned char*, size_t, const unsigned char*, size_t, struct wsrep_buf*, size_t*);
+ enum wsrep_trx_status (*wsrep_run_wsrep_commit_func)(THD *thd, handlerton *hton, bool all);
+ void (*wsrep_thd_LOCK_func)(THD *thd);
+ void (*wsrep_thd_UNLOCK_func)(THD *thd);
+ void (*wsrep_thd_awake_func)(THD *thd, my_bool signal);
+ enum wsrep_conflict_state (*wsrep_thd_conflict_state_func)(MYSQL_THD, my_bool);
+ const char * (*wsrep_thd_conflict_state_str_func)(THD *thd);
+ enum wsrep_exec_mode (*wsrep_thd_exec_mode_func)(THD *thd);
+ const char * (*wsrep_thd_exec_mode_str_func)(THD *thd);
+ enum wsrep_conflict_state (*wsrep_thd_get_conflict_state_func)(MYSQL_THD);
+ my_bool (*wsrep_thd_is_BF_func)(MYSQL_THD , my_bool);
+ my_bool (*wsrep_thd_is_wsrep_func)(MYSQL_THD thd);
+ char * (*wsrep_thd_query_func)(THD *thd);
+ enum wsrep_query_state (*wsrep_thd_query_state_func)(THD *thd);
+ const char * (*wsrep_thd_query_state_str_func)(THD *thd);
+ int (*wsrep_thd_retry_counter_func)(THD *thd);
+ void (*wsrep_thd_set_conflict_state_func)(THD *thd, enum wsrep_conflict_state state);
+ long long (*wsrep_thd_trx_seqno_func)(THD *thd);
+ struct wsrep_ws_handle * (*wsrep_thd_ws_handle_func)(THD *thd);
+ int (*wsrep_trx_is_aborting_func)(MYSQL_THD thd);
+ int (*wsrep_trx_order_before_func)(MYSQL_THD, MYSQL_THD);
+ void (*wsrep_unlock_rollback_func)();
+} *wsrep_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+#define get_wsrep() wsrep_service->get_wsrep_func()
+#define get_wsrep_certify_nonPK() wsrep_service->get_wsrep_certify_nonPK_func()
+#define get_wsrep_debug() wsrep_service->get_wsrep_debug_func()
+#define get_wsrep_drupal_282555_workaround() wsrep_service->get_wsrep_drupal_282555_workaround_func()
+#define get_wsrep_load_data_splitting() wsrep_service->get_wsrep_load_data_splitting_func()
+#define get_wsrep_log_conflicts() wsrep_service->get_wsrep_log_conflicts_func()
+#define get_wsrep_protocol_version() wsrep_service->get_wsrep_protocol_version_func()
+#define wsrep_aborting_thd_contains(T) wsrep_service->wsrep_aborting_thd_contains_func(T)
+#define wsrep_aborting_thd_enqueue(T) wsrep_service->wsrep_aborting_thd_enqueue_func(T)
+#define wsrep_consistency_check(T) wsrep_service->wsrep_consistency_check_func(T)
+#define wsrep_is_wsrep_xid(X) wsrep_service->wsrep_is_wsrep_xid_func(X)
+#define wsrep_lock_rollback() wsrep_service->wsrep_lock_rollback_func()
+#define wsrep_on(X) wsrep_service->wsrep_on_func(X)
+#define wsrep_post_commit(T,A) wsrep_service->wsrep_post_commit_func(T,A)
+#define wsrep_prepare_key(A,B,C,D,E,F) wsrep_service->wsrep_prepare_key_func(A,B,C,D,E,F)
+#define wsrep_run_wsrep_commit(T,H,A) wsrep_service->wsrep_run_wsrep_commit_func(T,H,A)
+#define wsrep_thd_LOCK(T) wsrep_service->wsrep_thd_LOCK_func(T)
+#define wsrep_thd_UNLOCK(T) wsrep_service->wsrep_thd_UNLOCK_func(T)
+#define wsrep_thd_awake(T,S) wsrep_service->wsrep_thd_awake_func(T,S)
+#define wsrep_thd_conflict_state(T,S) wsrep_service->wsrep_thd_conflict_state_func(T,S)
+#define wsrep_thd_conflict_state_str(T) wsrep_service->wsrep_thd_conflict_state_str_func(T)
+#define wsrep_thd_exec_mode(T) wsrep_service->wsrep_thd_exec_mode_func(T)
+#define wsrep_thd_exec_mode_str(T) wsrep_service->wsrep_thd_exec_mode_str_func(T)
+#define wsrep_thd_get_conflict_state(T) wsrep_service->wsrep_thd_get_conflict_state_func(T)
+#define wsrep_thd_is_BF(T,S) wsrep_service->wsrep_thd_is_BF_func(T,S)
+#define wsrep_thd_is_wsrep(T) wsrep_service->wsrep_thd_is_wsrep_func(T)
+#define wsrep_thd_query(T) wsrep_service->wsrep_thd_query_func(T)
+#define wsrep_thd_query_state(T) wsrep_service->wsrep_thd_query_state_func(T)
+#define wsrep_thd_query_state_str(T) wsrep_service->wsrep_thd_query_state_str_func(T)
+#define wsrep_thd_retry_counter(T) wsrep_service->wsrep_thd_retry_counter_func(T)
+#define wsrep_thd_set_conflict_state(T,S) wsrep_service->wsrep_thd_set_conflict_state_func(T,S)
+#define wsrep_thd_trx_seqno(T) wsrep_service->wsrep_thd_trx_seqno_func(T)
+#define wsrep_thd_ws_handle(T) wsrep_service->wsrep_thd_ws_handle_func(T)
+#define wsrep_trx_is_aborting(T) wsrep_service->wsrep_trx_is_aborting_func(T)
+#define wsrep_trx_order_before(T1,T2) wsrep_service->wsrep_trx_order_before_func(T1,T2)
+#define wsrep_unlock_rollback() wsrep_service->wsrep_unlock_rollback_func()
+
+#define wsrep_debug get_wsrep_debug()
+#define wsrep_log_conflicts get_wsrep_log_conflicts()
+#define wsrep_certify_nonPK get_wsrep_certify_nonPK()
+#define wsrep_load_data_splitting get_wsrep_load_data_splitting()
+#define wsrep_drupal_282555_workaround get_wsrep_drupal_282555_workaround()
+#define wsrep_protocol_version get_wsrep_protocol_version()
+
+#else
+
+extern my_bool wsrep_debug;
+extern my_bool wsrep_log_conflicts;
+extern my_bool wsrep_certify_nonPK;
+extern my_bool wsrep_load_data_splitting;
+extern my_bool wsrep_drupal_282555_workaround;
+extern long wsrep_protocol_version;
+
+bool wsrep_consistency_check(THD *thd);
+bool wsrep_prepare_key(const unsigned char* cache_key, size_t cache_key_len, const unsigned char* row_id, size_t row_id_len, struct wsrep_buf* key, size_t* key_len);
+char *wsrep_thd_query(THD *thd);
+const char *wsrep_thd_conflict_state_str(THD *thd);
+const char *wsrep_thd_exec_mode_str(THD *thd);
+const char *wsrep_thd_query_state_str(THD *thd);
+enum wsrep_conflict_state wsrep_thd_conflict_state(MYSQL_THD thd, my_bool sync);
+enum wsrep_conflict_state wsrep_thd_get_conflict_state(MYSQL_THD thd);
+enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
+enum wsrep_query_state wsrep_thd_query_state(THD *thd);
+enum wsrep_trx_status wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all);
+int wsrep_is_wsrep_xid(const struct xid_t* xid);
+int wsrep_on(MYSQL_THD thd);
+int wsrep_thd_retry_counter(THD *thd);
+int wsrep_trx_is_aborting(MYSQL_THD thd);
+int wsrep_trx_order_before(MYSQL_THD thd1, MYSQL_THD thd2);
+long get_wsrep_protocol_version();
+long long wsrep_thd_trx_seqno(THD *thd);
+my_bool get_wsrep_certify_nonPK();
+my_bool get_wsrep_debug();
+my_bool get_wsrep_drupal_282555_workaround();
+my_bool get_wsrep_load_data_splitting();
+my_bool get_wsrep_log_conflicts();
+my_bool wsrep_aborting_thd_contains(THD *thd);
+my_bool wsrep_thd_is_BF(MYSQL_THD thd, my_bool sync);
+my_bool wsrep_thd_is_wsrep(MYSQL_THD thd);
+struct wsrep *get_wsrep();
+struct wsrep_ws_handle *wsrep_thd_ws_handle(THD *thd);
+void wsrep_aborting_thd_enqueue(THD *thd);
+void wsrep_lock_rollback();
+void wsrep_post_commit(THD* thd, bool all);
+void wsrep_thd_LOCK(THD *thd);
+void wsrep_thd_UNLOCK(THD *thd);
+void wsrep_thd_awake(THD *thd, my_bool signal);
+void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state);
+void wsrep_unlock_rollback();
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_WSREP_INCLUDED
+#endif
+
diff --git a/include/mysql/services.h b/include/mysql/services.h
index a969cfb388e..4ff30fdd1bb 100644
--- a/include/mysql/services.h
+++ b/include/mysql/services.h
@@ -31,6 +31,7 @@ extern "C" {
#include <mysql/service_logger.h>
#include <mysql/service_thd_autoinc.h>
#include <mysql/service_thd_error_context.h>
+/*#include <mysql/service_wsrep.h>*/
#ifdef __cplusplus
}
diff --git a/include/service_versions.h b/include/service_versions.h
index c9d7571fa10..da3a7edc012 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -30,6 +30,7 @@
#define VERSION_thd_timezone 0x0100
#define VERSION_my_sha1 0x0101
#define VERSION_my_md5 0x0100
+#define VERSION_wsrep 0x0100
#define VERSION_logger 0x0100
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 0920be53baf..f44c5daa17c 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -105,6 +105,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/compat56.cc
../sql/table_cache.cc
../sql/item_inetfunc.cc
+ ../sql/wsrep_dummy.cc
${GEN_SOURCES}
${MYSYS_LIBWRAP_SOURCE}
)
diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt
index 12f7d6cc1a8..46be68a5b7f 100644
--- a/libservices/CMakeLists.txt
+++ b/libservices/CMakeLists.txt
@@ -26,6 +26,7 @@ SET(MYSQLSERVICES_SOURCES
debug_sync_service.c
my_sha1_service.c
my_md5_service.c
+ wsrep_service.c
kill_statement_service.c
logger_service.c)
diff --git a/libservices/wsrep_service.c b/libservices/wsrep_service.c
new file mode 100644
index 00000000000..5faf1a12d05
--- /dev/null
+++ b/libservices/wsrep_service.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2014 SkySQL Ab.
+
+ 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 */
+
+#include <service_versions.h>
+
+/* file reserved for the future use */
+SERVICE_VERSION wsrep_service= (void *) VERSION_wsrep;
+
diff --git a/mysql-test/r/handlersocket.result b/mysql-test/r/handlersocket.result
index b519e2e7c93..453a32cedc4 100644
--- a/mysql-test/r/handlersocket.result
+++ b/mysql-test/r/handlersocket.result
@@ -5,7 +5,7 @@ plugin_version 1.0
plugin_status ACTIVE
plugin_type DAEMON
plugin_library handlersocket.so
-plugin_library_version 1.8
+plugin_library_version 1.9
plugin_author higuchi dot akira at dena dot jp
plugin_description Direct access into InnoDB
plugin_license BSD
diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result
index 630f0141d18..0bd1e1e6dcd 100644
--- a/mysql-test/r/plugin.result
+++ b/mysql-test/r/plugin.result
@@ -15,7 +15,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE STORAGE ENGINE
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
-PLUGIN_LIBRARY_VERSION 1.8
+PLUGIN_LIBRARY_VERSION 1.9
PLUGIN_AUTHOR Brian Aker, MySQL AB
PLUGIN_DESCRIPTION Example storage engine
PLUGIN_LICENSE GPL
@@ -28,7 +28,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE DAEMON
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
-PLUGIN_LIBRARY_VERSION 1.8
+PLUGIN_LIBRARY_VERSION 1.9
PLUGIN_AUTHOR Sergei Golubchik
PLUGIN_DESCRIPTION Unusable Daemon
PLUGIN_LICENSE GPL
@@ -67,7 +67,7 @@ PLUGIN_STATUS DELETED
PLUGIN_TYPE STORAGE ENGINE
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
-PLUGIN_LIBRARY_VERSION 1.8
+PLUGIN_LIBRARY_VERSION 1.9
PLUGIN_AUTHOR Brian Aker, MySQL AB
PLUGIN_DESCRIPTION Example storage engine
PLUGIN_LICENSE GPL
diff --git a/mysql-test/suite/plugins/r/show_all_plugins.result b/mysql-test/suite/plugins/r/show_all_plugins.result
index 854eb339ce0..55aa43a646d 100644
--- a/mysql-test/suite/plugins/r/show_all_plugins.result
+++ b/mysql-test/suite/plugins/r/show_all_plugins.result
@@ -4,8 +4,8 @@ Variable_name Value
Opened_plugin_libraries 0
select * from information_schema.all_plugins where plugin_library='ha_example.so';
PLUGIN_NAME PLUGIN_VERSION PLUGIN_STATUS PLUGIN_TYPE PLUGIN_TYPE_VERSION PLUGIN_LIBRARY PLUGIN_LIBRARY_VERSION PLUGIN_AUTHOR PLUGIN_DESCRIPTION PLUGIN_LICENSE LOAD_OPTION PLUGIN_MATURITY PLUGIN_AUTH_VERSION
-EXAMPLE 0.1 NOT INSTALLED STORAGE ENGINE MYSQL_VERSION_ID ha_example.so 1.8 Brian Aker, MySQL AB Example storage engine GPL OFF Experimental 0.1
-UNUSABLE 3.14 NOT INSTALLED DAEMON MYSQL_VERSION_ID ha_example.so 1.8 Sergei Golubchik Unusable Daemon GPL OFF Experimental 3.14.15.926
+EXAMPLE 0.1 NOT INSTALLED STORAGE ENGINE MYSQL_VERSION_ID ha_example.so 1.9 Brian Aker, MySQL AB Example storage engine GPL OFF Experimental 0.1
+UNUSABLE 3.14 NOT INSTALLED DAEMON MYSQL_VERSION_ID ha_example.so 1.9 Sergei Golubchik Unusable Daemon GPL OFF Experimental 3.14.15.926
show status like '%libraries%';
Variable_name Value
Opened_plugin_libraries 1
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index b02389ccc17..32499662a7c 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -29,6 +29,8 @@ IF(WITH_WSREP AND NOT EMBEDDED_LIBRARY)
wsrep_thd.cc
)
SET(WSREP_LIB wsrep)
+ELSE()
+ SET(WSREP_SOURCES wsrep_dummy.cc)
ENDIF()
INCLUDE_DIRECTORIES(
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 15428c96d73..42f12a47afd 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -1501,7 +1501,7 @@ void MDL_lock::Ticket_list::add_ticket(MDL_ticket *ticket)
DBUG_ASSERT(ticket->get_lock());
#ifdef WITH_WSREP
if ((this == &(ticket->get_lock()->m_waiting)) &&
- wsrep_thd_is_BF((void *)(ticket->get_ctx()->get_thd()), false))
+ wsrep_thd_is_BF(ticket->get_ctx()->get_thd(), false))
{
Ticket_iterator itw(ticket->get_lock()->m_waiting);
Ticket_iterator itg(ticket->get_lock()->m_granted);
@@ -1513,10 +1513,10 @@ void MDL_lock::Ticket_list::add_ticket(MDL_ticket *ticket)
while ((waiting= itw++) && !added)
{
- if (!wsrep_thd_is_BF((void *)(waiting->get_ctx()->get_thd()), true))
+ if (!wsrep_thd_is_BF(waiting->get_ctx()->get_thd(), true))
{
WSREP_DEBUG("MDL add_ticket inserted before: %lu %s",
- wsrep_thd_thread_id(waiting->get_ctx()->get_thd()),
+ thd_get_thread_id(waiting->get_ctx()->get_thd()),
wsrep_thd_query(waiting->get_ctx()->get_thd()));
m_list.insert_after(prev, ticket);
added= true;
@@ -1911,11 +1911,11 @@ MDL_lock::can_grant_lock(enum_mdl_type type_arg,
ticket->is_incompatible_when_granted(type_arg))
{
#ifdef WITH_WSREP
- if (wsrep_thd_is_BF((void *)(requestor_ctx->get_thd()),false) &&
+ if (wsrep_thd_is_BF(requestor_ctx->get_thd(),false) &&
key.mdl_namespace() == MDL_key::GLOBAL)
{
WSREP_DEBUG("global lock granted for BF: %lu %s",
- wsrep_thd_thread_id(requestor_ctx->get_thd()),
+ thd_get_thread_id(requestor_ctx->get_thd()),
wsrep_thd_query(requestor_ctx->get_thd()));
can_grant = true;
}
@@ -1945,12 +1945,12 @@ MDL_lock::can_grant_lock(enum_mdl_type type_arg,
}
else
{
- if (wsrep_thd_is_BF((void *)(requestor_ctx->get_thd()), false) &&
+ if (wsrep_thd_is_BF(requestor_ctx->get_thd(), false) &&
key.mdl_namespace() == MDL_key::GLOBAL)
{
WSREP_DEBUG("global lock granted for BF (waiting queue): %lu %s",
- wsrep_thd_thread_id(requestor_ctx->get_thd()),
- wsrep_thd_query(requestor_ctx->get_thd()));
+ thd_get_thread_id(requestor_ctx->get_thd()),
+ wsrep_thd_query(requestor_ctx->get_thd()));
can_grant = true;
}
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 00689aad1f3..356f672657e 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -9019,7 +9019,7 @@ bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use,
if (!thd_table->needs_reopen())
{
signalled|= mysql_lock_abort_for_thread(thd, thd_table);
- if (thd && WSREP(thd) && wsrep_thd_is_BF((void *)thd, true))
+ if (thd && WSREP(thd) && wsrep_thd_is_BF(thd, true))
{
WSREP_DEBUG("remove_table_from_cache: %llu",
(unsigned long long) thd->real_id);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 56c14613829..782e4a27317 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1949,7 +1949,7 @@ bool THD::notify_shared_lock(MDL_context_owner *ctx_in_use,
if (!thd_table->needs_reopen())
{
signalled|= mysql_lock_abort_for_thread(this, thd_table);
- if (this && WSREP(this) && wsrep_thd_is_BF((void *)this, FALSE))
+ if (this && WSREP(this) && wsrep_thd_is_BF(this, FALSE))
{
WSREP_DEBUG("remove_table_from_cache: %llu",
(unsigned long long) this->real_id);
diff --git a/sql/sql_plugin_services.h b/sql/sql_plugin_services.h
index 417c16c1112..399de854218 100644
--- a/sql/sql_plugin_services.h
+++ b/sql/sql_plugin_services.h
@@ -16,6 +16,7 @@
/* support for Services */
#include <service_versions.h>
+#include <mysql/service_wsrep.h>
struct st_service_ref {
const char *name;
@@ -99,6 +100,45 @@ static struct thd_error_context_service_st thd_error_conext_handler= {
thd_get_error_context_description
};
+static struct wsrep_service_st wsrep_handler = {
+ get_wsrep,
+ get_wsrep_certify_nonPK,
+ get_wsrep_debug,
+ get_wsrep_drupal_282555_workaround,
+ get_wsrep_load_data_splitting,
+ get_wsrep_log_conflicts,
+ get_wsrep_protocol_version,
+ wsrep_aborting_thd_contains,
+ wsrep_aborting_thd_enqueue,
+ wsrep_consistency_check,
+ wsrep_is_wsrep_xid,
+ wsrep_lock_rollback,
+ wsrep_on,
+ wsrep_post_commit,
+ wsrep_prepare_key,
+ wsrep_run_wsrep_commit,
+ wsrep_thd_LOCK,
+ wsrep_thd_UNLOCK,
+ wsrep_thd_awake,
+ wsrep_thd_conflict_state,
+ wsrep_thd_conflict_state_str,
+ wsrep_thd_exec_mode,
+ wsrep_thd_exec_mode_str,
+ wsrep_thd_get_conflict_state,
+ wsrep_thd_is_BF,
+ wsrep_thd_is_wsrep,
+ wsrep_thd_query,
+ wsrep_thd_query_state,
+ wsrep_thd_query_state_str,
+ wsrep_thd_retry_counter,
+ wsrep_thd_set_conflict_state,
+ wsrep_thd_trx_seqno,
+ wsrep_thd_ws_handle,
+ wsrep_trx_is_aborting,
+ wsrep_trx_order_before,
+ wsrep_unlock_rollback
+};
+
static struct st_service_ref list_of_services[]=
{
{ "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
@@ -112,6 +152,7 @@ static struct st_service_ref list_of_services[]=
{ "my_md5_service", VERSION_my_md5, &my_md5_handler},
{ "logger_service", VERSION_logger, &logger_service_handler },
{ "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
+ { "wsrep_service", VERSION_wsrep, &wsrep_handler },
{ "thd_error_context_service", VERSION_thd_error_context, &thd_error_conext_handler },
};
diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc
new file mode 100644
index 00000000000..e937ef9be5c
--- /dev/null
+++ b/sql/wsrep_dummy.cc
@@ -0,0 +1,126 @@
+/* Copyright (C) 2014 SkySQL Ab.
+
+ 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.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
+
+#include <my_global.h>
+#include <sql_class.h>
+#include <mysql/service_wsrep.h>
+
+my_bool wsrep_thd_is_BF(THD *, my_bool)
+{ return 0; }
+
+int wsrep_trx_order_before(THD *, THD *)
+{ return 0; }
+
+enum wsrep_conflict_state wsrep_thd_conflict_state(THD *, my_bool)
+{ return NO_CONFLICT; }
+
+int wsrep_is_wsrep_xid(const XID*)
+{ return 0; }
+
+bool wsrep_prepare_key(const uchar*, size_t, const uchar*, size_t, struct wsrep_buf*, size_t*)
+{ return 0; }
+
+struct wsrep *get_wsrep()
+{ return 0; }
+
+my_bool get_wsrep_certify_nonPK()
+{ return 0; }
+
+my_bool get_wsrep_debug()
+{ return 0; }
+
+my_bool get_wsrep_drupal_282555_workaround()
+{ return 0; }
+
+my_bool get_wsrep_load_data_splitting()
+{ return 0; }
+
+my_bool get_wsrep_log_conflicts()
+{ return 0; }
+
+long get_wsrep_protocol_version()
+{ return 0; }
+
+my_bool wsrep_aborting_thd_contains(THD *)
+{ return 0; }
+
+void wsrep_aborting_thd_enqueue(THD *)
+{ }
+
+bool wsrep_consistency_check(THD *)
+{ return 0; }
+
+void wsrep_lock_rollback()
+{ }
+
+int wsrep_on(THD *thd)
+{ return 0; }
+
+void wsrep_post_commit(THD*, bool)
+{ }
+
+enum wsrep_trx_status wsrep_run_wsrep_commit(THD *, handlerton *, bool)
+{ return WSREP_TRX_ERROR; }
+
+void wsrep_thd_LOCK(THD *)
+{ }
+
+void wsrep_thd_UNLOCK(THD *)
+{ }
+
+void wsrep_thd_awake(THD *, my_bool)
+{ }
+
+const char *wsrep_thd_conflict_state_str(THD *)
+{ return 0; }
+
+enum wsrep_exec_mode wsrep_thd_exec_mode(THD *)
+{ return LOCAL_STATE; }
+
+const char *wsrep_thd_exec_mode_str(THD *)
+{ return NULL; }
+
+enum wsrep_conflict_state wsrep_thd_get_conflict_state(THD *)
+{ return NO_CONFLICT; }
+
+my_bool wsrep_thd_is_wsrep(THD *)
+{ return 0; }
+
+char *wsrep_thd_query(THD *)
+{ return 0; }
+
+enum wsrep_query_state wsrep_thd_query_state(THD *)
+{ return QUERY_IDLE; }
+
+const char *wsrep_thd_query_state_str(THD *)
+{ return 0; }
+
+int wsrep_thd_retry_counter(THD *)
+{ return 0; }
+
+void wsrep_thd_set_conflict_state(THD *, enum wsrep_conflict_state)
+{ }
+
+longlong wsrep_thd_trx_seqno(THD *)
+{ return -1; }
+
+struct wsrep_ws_handle* wsrep_thd_ws_handle(THD *)
+{ return 0; }
+
+int wsrep_trx_is_aborting(THD *)
+{ return 0; }
+
+void wsrep_unlock_rollback()
+{ }
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index f47310ba49f..0dd273a0df7 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -782,14 +782,15 @@ int wsrep_init()
return rcode;
}
-extern int wsrep_on(void *);
-
void wsrep_init_startup (bool first)
{
if (wsrep_init()) unireg_abort(1);
- wsrep_thr_lock_init(wsrep_thd_is_BF, wsrep_abort_thd,
- wsrep_debug, wsrep_convert_LOCK_to_trx, wsrep_on);
+ wsrep_thr_lock_init(
+ (wsrep_thd_is_brute_force_fun)wsrep_thd_is_BF,
+ (wsrep_abort_thd_fun)wsrep_abort_thd,
+ wsrep_debug, wsrep_convert_LOCK_to_trx,
+ (wsrep_on_fun)wsrep_on);
/* Skip replication start if no cluster address */
if (!wsrep_cluster_address || strlen(wsrep_cluster_address) == 0) return;
@@ -1187,12 +1188,9 @@ err:
}
-bool wsrep_prepare_key_for_innodb(const uchar* cache_key,
- size_t cache_key_len,
- const uchar* row_id,
- size_t row_id_len,
- wsrep_buf_t* key,
- size_t* key_len)
+bool wsrep_prepare_key(const uchar* cache_key, size_t cache_key_len,
+ const uchar* row_id, size_t row_id_len,
+ wsrep_buf_t* key, size_t* key_len)
{
if (*key_len < 3) return false;
@@ -2112,9 +2110,9 @@ int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len)
}
-extern int wsrep_on(void *thd)
+extern int wsrep_on(THD *thd)
{
- return (int)(WSREP(((THD*)thd)));
+ return (int)(WSREP(thd));
}
@@ -2124,9 +2122,9 @@ extern "C" bool wsrep_thd_is_wsrep_on(THD *thd)
}
-extern "C" bool wsrep_consistency_check(void *thd)
+bool wsrep_consistency_check(THD *thd)
{
- return ((THD*)thd)->wsrep_consistency_check == CONSISTENCY_CHECK_RUNNING;
+ return thd->wsrep_consistency_check == CONSISTENCY_CHECK_RUNNING;
}
@@ -2143,20 +2141,19 @@ extern "C" void wsrep_thd_set_query_state(
}
-extern "C" void wsrep_thd_set_conflict_state(
- THD *thd, enum wsrep_conflict_state state)
+void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state)
{
thd->wsrep_conflict_state= state;
}
-extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd)
+enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd)
{
return thd->wsrep_exec_mode;
}
-extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
+const char *wsrep_thd_exec_mode_str(THD *thd)
{
return
(!thd) ? "void" :
@@ -2167,13 +2164,13 @@ extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
}
-extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd)
+enum wsrep_query_state wsrep_thd_query_state(THD *thd)
{
return thd->wsrep_query_state;
}
-extern "C" const char *wsrep_thd_query_state_str(THD *thd)
+const char *wsrep_thd_query_state_str(THD *thd)
{
return
(!thd) ? "void" :
@@ -2185,13 +2182,13 @@ extern "C" const char *wsrep_thd_query_state_str(THD *thd)
}
-extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd)
+enum wsrep_conflict_state wsrep_thd_get_conflict_state(THD *thd)
{
return thd->wsrep_conflict_state;
}
-extern "C" const char *wsrep_thd_conflict_state_str(THD *thd)
+const char *wsrep_thd_conflict_state_str(THD *thd)
{
return
(!thd) ? "void" :
@@ -2205,19 +2202,19 @@ extern "C" const char *wsrep_thd_conflict_state_str(THD *thd)
}
-extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd)
+wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd)
{
return &thd->wsrep_ws_handle;
}
-extern "C" void wsrep_thd_LOCK(THD *thd)
+void wsrep_thd_LOCK(THD *thd)
{
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
}
-extern "C" void wsrep_thd_UNLOCK(THD *thd)
+void wsrep_thd_UNLOCK(THD *thd)
{
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
}
@@ -2234,14 +2231,7 @@ extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd)
return thd->wsrep_rand;
}
-
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd)
-{
- return thd->thread_id;
-}
-
-
-extern "C" wsrep_seqno_t wsrep_thd_trx_seqno(THD *thd)
+longlong wsrep_thd_trx_seqno(THD *thd)
{
return (thd) ? thd->wsrep_trx_meta.gtid.seqno : WSREP_SEQNO_UNDEFINED;
}
@@ -2253,7 +2243,7 @@ extern "C" query_id_t wsrep_thd_query_id(THD *thd)
}
-extern "C" char *wsrep_thd_query(THD *thd)
+char *wsrep_thd_query(THD *thd)
{
return (thd) ? thd->query() : NULL;
}
@@ -2288,30 +2278,29 @@ extern "C" void wsrep_thd_awake(THD *thd, my_bool signal)
}
-extern "C" int wsrep_thd_retry_counter(THD *thd)
+int wsrep_thd_retry_counter(THD *thd)
{
return(thd->wsrep_retry_counter);
}
extern int
-wsrep_trx_order_before(void *thd1, void *thd2)
+wsrep_trx_order_before(THD *thd1, THD *thd2)
{
- if (wsrep_thd_trx_seqno((THD*)thd1) < wsrep_thd_trx_seqno((THD*)thd2)) {
+ if (wsrep_thd_trx_seqno(thd1) < wsrep_thd_trx_seqno(thd2)) {
WSREP_DEBUG("BF conflict, order: %lld %lld\n",
- (long long)wsrep_thd_trx_seqno((THD*)thd1),
- (long long)wsrep_thd_trx_seqno((THD*)thd2));
+ (long long)wsrep_thd_trx_seqno(thd1),
+ (long long)wsrep_thd_trx_seqno(thd2));
return 1;
}
WSREP_DEBUG("waiting for BF, trx order: %lld %lld\n",
- (long long)wsrep_thd_trx_seqno((THD*)thd1),
- (long long)wsrep_thd_trx_seqno((THD*)thd2));
+ (long long)wsrep_thd_trx_seqno(thd1),
+ (long long)wsrep_thd_trx_seqno(thd2));
return 0;
}
-extern "C" int
-wsrep_trx_is_aborting(void *thd_ptr)
+int wsrep_trx_is_aborting(THD *thd_ptr)
{
if (thd_ptr) {
if ((((THD *)thd_ptr)->wsrep_conflict_state == MUST_ABORT) ||
@@ -2456,3 +2445,72 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
return wsrep_to_buf_helper(thd, stmt_query.c_ptr(), stmt_query.length(),
buf, buf_len);
}
+
+/***** callbacks for wsrep service ************/
+
+my_bool get_wsrep_debug()
+{
+ return wsrep_debug;
+}
+
+my_bool get_wsrep_load_data_splitting()
+{
+ return wsrep_load_data_splitting;
+}
+
+long get_wsrep_protocol_version()
+{
+ return wsrep_protocol_version;
+}
+
+my_bool get_wsrep_drupal_282555_workaround()
+{
+ return wsrep_drupal_282555_workaround;
+}
+
+my_bool get_wsrep_log_conflicts()
+{
+ return wsrep_log_conflicts;
+}
+
+wsrep_t *get_wsrep()
+{
+ return wsrep;
+}
+
+my_bool get_wsrep_certify_nonPK()
+{
+ return wsrep_certify_nonPK;
+}
+
+void wsrep_lock_rollback()
+{
+ mysql_mutex_lock(&LOCK_wsrep_rollback);
+}
+
+void wsrep_unlock_rollback()
+{
+ mysql_cond_signal(&COND_wsrep_rollback);
+ mysql_mutex_unlock(&LOCK_wsrep_rollback);
+}
+
+my_bool wsrep_aborting_thd_contains(THD *thd)
+{
+ wsrep_aborting_thd_t abortees = wsrep_aborting_thd;
+ while (abortees)
+ {
+ if (abortees->aborting_thd == thd)
+ return true;
+ abortees = abortees->next;
+ }
+ return false;
+}
+
+void wsrep_aborting_thd_enqueue(THD *thd)
+{
+ wsrep_aborting_thd_t aborting = (wsrep_aborting_thd_t)
+ my_malloc(sizeof(struct wsrep_aborting_thd), MYF(0));
+ aborting->aborting_thd = thd;
+ aborting->next = wsrep_aborting_thd;
+ wsrep_aborting_thd = aborting;
+}
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index c81ed794659..ce12c13b5a8 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -18,6 +18,9 @@
#ifndef WSREP_MYSQLD_H
#define WSREP_MYSQLD_H
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
+
#ifdef WITH_WSREP
typedef struct st_mysql_show_var SHOW_VAR;
@@ -33,32 +36,6 @@ typedef struct st_mysql_show_var SHOW_VAR;
class set_var;
class THD;
-enum wsrep_exec_mode {
- LOCAL_STATE,
- REPL_RECV,
- TOTAL_ORDER,
- LOCAL_COMMIT
-};
-
-enum wsrep_query_state {
- QUERY_IDLE,
- QUERY_EXEC,
- QUERY_COMMITTING,
- QUERY_EXITING,
- QUERY_ROLLINGBACK,
-};
-
-enum wsrep_conflict_state {
- NO_CONFLICT,
- MUST_ABORT,
- ABORTING,
- ABORTED,
- MUST_REPLAY,
- REPLAYING,
- RETRY_AUTOCOMMIT,
- CERT_FAILURE,
-};
-
enum wsrep_consistency_check_mode {
NO_CONSISTENCY_CHECK,
CONSISTENCY_CHECK_DECLARED,
@@ -90,27 +67,21 @@ extern const char* wsrep_data_home_dir;
extern const char* wsrep_dbug_option;
extern long wsrep_slave_threads;
extern int wsrep_slave_count_change;
-extern MYSQL_PLUGIN_IMPORT my_bool wsrep_debug;
extern my_bool wsrep_convert_LOCK_to_trx;
extern ulong wsrep_retry_autocommit;
extern my_bool wsrep_auto_increment_control;
-extern my_bool wsrep_drupal_282555_workaround;
extern my_bool wsrep_incremental_data_collection;
extern const char* wsrep_start_position;
extern ulong wsrep_max_ws_size;
extern ulong wsrep_max_ws_rows;
extern const char* wsrep_notify_cmd;
-extern my_bool wsrep_certify_nonPK;
extern long wsrep_max_protocol_version;
-extern long wsrep_protocol_version;
extern ulong wsrep_forced_binlog_format;
extern ulong wsrep_OSU_method_options;
extern my_bool wsrep_desync;
extern my_bool wsrep_recovery;
extern my_bool wsrep_replicate_myisam;
-extern my_bool wsrep_log_conflicts;
extern ulong wsrep_mysql_replication_bundle;
-extern my_bool wsrep_load_data_splitting;
extern my_bool wsrep_restart_slave;
extern my_bool wsrep_restart_slave_activated;
extern my_bool wsrep_slave_FK_checks;
@@ -157,34 +128,18 @@ void wsrep_init_startup(bool before);
// Other wsrep global variables
extern my_bool wsrep_inited; // whether wsrep is initialized ?
-extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
-extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd);
-extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd);
-extern "C" const char * wsrep_thd_exec_mode_str(THD *thd);
-extern "C" const char * wsrep_thd_conflict_state_str(THD *thd);
-extern "C" const char * wsrep_thd_query_state_str(THD *thd);
-extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd);
extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode);
extern "C" void wsrep_thd_set_query_state(
THD *thd, enum wsrep_query_state state);
-extern "C" void wsrep_thd_set_conflict_state(
- THD *thd, enum wsrep_conflict_state state);
extern "C" void wsrep_thd_set_trx_to_replay(THD *thd, uint64 trx_id);
-extern "C" void wsrep_thd_LOCK(THD *thd);
-extern "C" void wsrep_thd_UNLOCK(THD *thd);
extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd);
extern "C" time_t wsrep_thd_query_start(THD *thd);
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd);
-extern "C" int64_t wsrep_thd_trx_seqno(THD *thd);
extern "C" query_id_t wsrep_thd_query_id(THD *thd);
-extern "C" char * wsrep_thd_query(THD *thd);
extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd);
extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id);
-extern "C" void wsrep_thd_awake(THD *thd, my_bool signal);
-extern "C" int wsrep_thd_retry_counter(THD *thd);
extern void wsrep_close_client_connections(my_bool wait_to_end);
@@ -231,7 +186,7 @@ extern wsrep_seqno_t wsrep_locked_seqno;
"%s: \n " \
" THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %lld\n " \
" SQL: %s", \
- role, wsrep_thd_thread_id(thd), wsrep_thd_exec_mode_str(thd), \
+ role, thd_get_thread_id(thd), wsrep_thd_exec_mode_str(thd), \
wsrep_thd_query_state_str(thd), \
wsrep_thd_conflict_state_str(thd), (long long)wsrep_thd_trx_seqno(thd), \
wsrep_thd_query(thd) \
@@ -252,24 +207,12 @@ extern wsrep_seqno_t wsrep_locked_seqno;
extern void wsrep_ready_wait();
-enum wsrep_trx_status {
- WSREP_TRX_OK,
- WSREP_TRX_CERT_FAIL, /* certification failure, must abort */
- WSREP_TRX_SIZE_EXCEEDED, /* trx size exceeded */
- WSREP_TRX_ERROR, /* native mysql error */
-};
-
-extern enum wsrep_trx_status
-wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all);
class Ha_trx_info;
struct THD_TRANS;
void wsrep_register_hton(THD* thd, bool all);
-void wsrep_post_commit(THD* thd, bool all);
void wsrep_brute_force_killer(THD *thd);
int wsrep_hire_brute_force_killer(THD *thd, uint64_t trx_id);
-extern "C" bool wsrep_consistency_check(void *thd_ptr);
-
/* this is visible for client build so that innodb plugin gets this */
typedef struct wsrep_aborting_thd {
struct wsrep_aborting_thd *next;
@@ -335,10 +278,6 @@ void wsrep_init_sidno(const wsrep_uuid_t&);
void wsrep_xid_init(xid_t*, const wsrep_uuid_t*, wsrep_seqno_t);
const wsrep_uuid_t* wsrep_xid_uuid(const xid_t*);
wsrep_seqno_t wsrep_xid_seqno(const xid_t*);
-extern "C" int wsrep_is_wsrep_xid(const void* xid);
-
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd);
-extern "C" char *wsrep_thd_query(THD *thd);
extern bool
wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
@@ -375,7 +314,6 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
#define WSREP_CLIENT(thd) (0)
#define wsrep_emulate_bin_log (0)
#define wsrep_xid_seqno(X) (0)
-#define wsrep_is_wsrep_xid(X) (0)
#define wsrep_to_isolation (0)
#define wsrep_recovery (0)
#define wsrep_init() (1)
@@ -385,7 +323,6 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
#define wsrep_sync_wait(...) (0)
#define wsrep_to_isolation_begin(...) (0)
#define wsrep_register_hton(...) do { } while(0)
-#define wsrep_post_commit(...) do { } while(0)
#define wsrep_check_opts() (0)
#define wsrep_stop_replication(X) do { } while(0)
#define wsrep_inited (0)
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 0779535d7fb..b9ff0ecf8a8 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -491,12 +491,11 @@ void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe)
}
}
-int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync)
+enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd, my_bool sync)
{
- int state = -1;
- if (thd_ptr)
+ enum wsrep_conflict_state state = NO_CONFLICT;
+ if (thd)
{
- THD* thd = (THD*)thd_ptr;
if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd);
state = thd->wsrep_conflict_state;
@@ -505,26 +504,23 @@ int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync)
return state;
}
-my_bool wsrep_thd_is_wsrep(void *thd_ptr)
+my_bool wsrep_thd_is_wsrep(THD *thd)
{
my_bool status = FALSE;
- if (thd_ptr)
+ if (thd)
{
- THD* thd = (THD*)thd_ptr;
-
status = (WSREP(thd) && WSREP_PROVIDER_EXISTS);
}
return status;
}
-my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync)
+my_bool wsrep_thd_is_BF(THD *thd, my_bool sync)
{
my_bool status = FALSE;
- if (thd_ptr)
+ if (thd)
{
- THD* thd = (THD*)thd_ptr;
// THD can be BF only if provider exists
- if (wsrep_thd_is_wsrep(thd_ptr))
+ if (wsrep_thd_is_wsrep(thd))
{
if (sync)
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h
index cc3a7c7b9d1..9914e98dcdb 100644
--- a/sql/wsrep_thd.h
+++ b/sql/wsrep_thd.h
@@ -32,11 +32,10 @@ int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr,
my_bool signal);
extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
-extern my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
+extern my_bool wsrep_thd_is_BF(THD *thd, my_bool sync);
extern my_bool wsrep_thd_is_wsrep(void *thd_ptr);
-extern int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
-//extern "C" my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
+enum wsrep_conflict_state wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
extern "C" my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync);
extern "C" my_bool wsrep_thd_is_local(void *thd_ptr, my_bool sync);
extern "C" int wsrep_thd_in_locking_session(void *thd_ptr);
diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc
index cdee1c2cece..e7509d393d8 100644
--- a/sql/wsrep_utils.cc
+++ b/sql/wsrep_utils.cc
@@ -514,9 +514,8 @@ wsrep_seqno_t wsrep_xid_seqno(const XID* xid)
}
extern
-int wsrep_is_wsrep_xid(const void* xid_ptr)
+int wsrep_is_wsrep_xid(const XID* xid)
{
- const XID* xid= reinterpret_cast<const XID*>(xid_ptr);
return (xid->formatID == 1 &&
xid->gtrid_length == WSREP_XID_GTRID_LEN &&
xid->bqual_length == 0 &&
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index ef5387edca1..d866d6b7764 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -114,6 +114,9 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "ha_innodb.h"
#include "i_s.h"
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
+
# ifndef MYSQL_PLUGIN_IMPORT
# define MYSQL_PLUGIN_IMPORT /* nothing */
# endif /* MYSQL_PLUGIN_IMPORT */
@@ -121,17 +124,12 @@ this program; if not, write to the Free Software Foundation, Inc.,
#ifdef WITH_WSREP
#include "dict0priv.h"
#include "../storage/innobase/include/ut0byte.h"
-#include <wsrep_mysqld.h>
#include <mysql/service_md5.h>
-extern my_bool wsrep_certify_nonPK;
class binlog_trx_data;
extern handlerton *binlog_hton;
extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log;
-extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_wsrep_rollback;
-extern MYSQL_PLUGIN_IMPORT mysql_cond_t COND_wsrep_rollback;
-extern MYSQL_PLUGIN_IMPORT wsrep_aborting_thd_t wsrep_aborting_thd;
static inline wsrep_ws_handle_t*
wsrep_ws_handle(THD* thd, const trx_t* trx) {
@@ -139,14 +137,6 @@ wsrep_ws_handle(THD* thd, const trx_t* trx) {
(wsrep_trx_id_t)trx->id);
}
-extern bool wsrep_prepare_key_for_innodb(const uchar *cache_key,
- size_t cache_key_len,
- const uchar* row_id,
- size_t row_id_len,
- wsrep_buf_t* key,
- size_t* key_len);
-
-extern handlerton * wsrep_hton;
extern TC_LOG* tc_log;
extern void wsrep_cleanup_transaction(THD *thd);
static int
@@ -3702,7 +3692,7 @@ innobase_commit_low(
#ifdef WITH_WSREP
THD* thd = (THD*)trx->mysql_thd;
const char* tmp = 0;
- if (wsrep_on((void*)thd)) {
+ if (wsrep_on(thd)) {
#ifdef WSREP_PROC_INFO
char info[64];
info[sizeof(info) - 1] = '\0';
@@ -3721,7 +3711,7 @@ innobase_commit_low(
trx_commit_for_mysql(trx);
}
#ifdef WITH_WSREP
- if (wsrep_on((void*)thd)) { thd_proc_info(thd, tmp); }
+ if (wsrep_on(thd)) { thd_proc_info(thd, tmp); }
#endif /* WITH_WSREP */
}
@@ -4449,7 +4439,7 @@ innobase_kill_query(
#ifdef WITH_WSREP
wsrep_thd_LOCK(thd);
- if (wsrep_thd_conflict_state(thd) != NO_CONFLICT) {
+ if (wsrep_thd_get_conflict_state(thd) != NO_CONFLICT) {
/* if victim has been signaled by BF thread and/or aborting
is already progressing, following query aborting is not necessary
any more.
@@ -7584,7 +7574,7 @@ no_commit:
;
} else if (src_table == prebuilt->table) {
#ifdef WITH_WSREP
- switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
+ switch (wsrep_run_wsrep_commit(user_thd, 0, 1))
{
case WSREP_TRX_OK:
break;
@@ -7609,7 +7599,7 @@ no_commit:
prebuilt->sql_stat_start = TRUE;
} else {
#ifdef WITH_WSREP
- switch (wsrep_run_wsrep_commit(user_thd, wsrep_hton, 1))
+ switch (wsrep_run_wsrep_commit(user_thd, 0, 1))
{
case WSREP_TRX_OK:
break;
@@ -9735,7 +9725,7 @@ wsrep_append_foreign_key(
wsrep_buf_t wkey_part[3];
wsrep_key_t wkey = {wkey_part, 3};
- if (!wsrep_prepare_key_for_innodb(
+ if (!wsrep_prepare_key(
(const uchar*)cache_key,
cache_key_len + 1,
(const uchar*)key, len+1,
@@ -9746,6 +9736,7 @@ wsrep_append_foreign_key(
wsrep_thd_query(thd) : "void");
return DB_ERROR;
}
+ wsrep_t *wsrep= get_wsrep();
rcode = (int)wsrep->append_key(
wsrep,
wsrep_ws_handle(thd, trx),
@@ -9781,7 +9772,7 @@ wsrep_append_key(
#ifdef WSREP_DEBUG_PRINT
fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s ",
(shared) ? "Shared" : "Exclusive",
- wsrep_thd_thread_id(thd), (long long)trx->id, key_len,
+ thd_get_thread_id(thd), (long long)trx->id, key_len,
table_share->table_name.str);
for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]);
@@ -9790,7 +9781,7 @@ wsrep_append_key(
#endif
wsrep_buf_t wkey_part[3];
wsrep_key_t wkey = {wkey_part, 3};
- if (!wsrep_prepare_key_for_innodb(
+ if (!wsrep_prepare_key(
(const uchar*)table_share->table_cache_key.str,
table_share->table_cache_key.length,
(const uchar*)key, key_len,
@@ -9802,6 +9793,7 @@ wsrep_append_key(
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
+ wsrep_t *wsrep= get_wsrep();
int rcode = (int)wsrep->append_key(
wsrep,
wsrep_ws_handle(thd, trx),
@@ -9838,7 +9830,7 @@ ha_innobase::wsrep_append_keys(
if (table_share && table_share->tmp_table != NO_TMP_TABLE) {
WSREP_DEBUG("skipping tmp table DML: THD: %lu tmp: %d SQL: %s",
- wsrep_thd_thread_id(thd),
+ thd_get_thread_id(thd),
table_share->tmp_table,
(wsrep_thd_query(thd)) ?
wsrep_thd_query(thd) : "void");
@@ -17518,7 +17510,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: %lu",
signal, (long long)bf_seqno,
- wsrep_thd_thread_id(thd),
+ thd_get_thread_id(thd),
victim_trx->id);
WSREP_DEBUG("Aborting query: %s",
@@ -17534,10 +17526,10 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
WSREP_DEBUG("withdraw for BF trx: %lu, state: %d",
victim_trx->id,
- wsrep_thd_conflict_state(thd));
+ wsrep_thd_get_conflict_state(thd));
}
- switch (wsrep_thd_conflict_state(thd)) {
+ switch (wsrep_thd_get_conflict_state(thd)) {
case NO_CONFLICT:
wsrep_thd_set_conflict_state(thd, MUST_ABORT);
break;
@@ -17552,7 +17544,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
case ABORTING: // fall through
default:
WSREP_DEBUG("victim %lu in state %d",
- victim_trx->id, wsrep_thd_conflict_state(thd));
+ victim_trx->id, wsrep_thd_get_conflict_state(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
break;
@@ -17563,7 +17555,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
enum wsrep_status rcode;
WSREP_DEBUG("kill query for: %ld",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
WSREP_DEBUG("kill trx QUERY_COMMITTING for %lu",
victim_trx->id);
@@ -17571,6 +17563,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
wsrep_abort_slave_trx(bf_seqno,
wsrep_thd_trx_seqno(thd));
} else {
+ wsrep_t *wsrep= get_wsrep();
rcode = wsrep->abort_pre_commit(
wsrep, bf_seqno,
(wsrep_trx_id_t)victim_trx->id
@@ -17611,7 +17604,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
victim_trx->lock.was_chosen_as_deadlock_victim= TRUE;
if (victim_trx->lock.wait_lock) {
WSREP_DEBUG("victim has wait flag: %ld",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
lock_t* wait_lock = victim_trx->lock.wait_lock;
if (wait_lock) {
WSREP_DEBUG("canceling wait lock");
@@ -17624,9 +17617,9 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
} else {
/* abort currently executing query */
DBUG_PRINT("wsrep",("sending KILL_QUERY to: %ld",
- wsrep_thd_thread_id(thd)));
+ thd_get_thread_id(thd)));
WSREP_DEBUG("kill query for: %ld",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
/* Note that innobase_kill_connection will take lock_mutex
and trx_mutex */
wsrep_thd_UNLOCK(thd);
@@ -17641,9 +17634,6 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
break;
case QUERY_IDLE:
{
- bool skip_abort= false;
- wsrep_aborting_thd_t abortees;
-
WSREP_DEBUG("kill IDLE for %lu", victim_trx->id);
if (wsrep_thd_exec_mode(thd) == REPL_RECV) {
@@ -17657,35 +17647,22 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
/* This will lock thd from proceeding after net_read() */
wsrep_thd_set_conflict_state(thd, ABORTING);
- mysql_mutex_lock(&LOCK_wsrep_rollback);
+ wsrep_lock_rollback();
- abortees = wsrep_aborting_thd;
- while (abortees && !skip_abort) {
- /* check if we have a kill message for this already */
- if (abortees->aborting_thd == thd) {
- skip_abort = true;
- WSREP_WARN("duplicate thd aborter %lu",
- wsrep_thd_thread_id(thd));
- }
- abortees = abortees->next;
- }
- if (!skip_abort) {
- wsrep_aborting_thd_t aborting = (wsrep_aborting_thd_t)
- my_malloc(sizeof(struct wsrep_aborting_thd),
- MYF(0));
- aborting->aborting_thd = thd;
- aborting->next = wsrep_aborting_thd;
- wsrep_aborting_thd = aborting;
- DBUG_PRINT("wsrep",("enqueuing trx abort for %lu",
- wsrep_thd_thread_id(thd)));
- WSREP_DEBUG("enqueuing trx abort for (%lu)",
- wsrep_thd_thread_id(thd));
+ if (wsrep_aborting_thd_contains(thd)) {
+ WSREP_WARN("duplicate thd aborter %lu",
+ thd_get_thread_id(thd));
+ } else {
+ wsrep_aborting_thd_enqueue(thd);
+ DBUG_PRINT("wsrep",("enqueuing trx abort for %lu",
+ thd_get_thread_id(thd)));
+ WSREP_DEBUG("enqueuing trx abort for (%lu)",
+ thd_get_thread_id(thd));
}
DBUG_PRINT("wsrep",("signalling wsrep rollbacker"));
WSREP_DEBUG("signaling aborter");
- mysql_cond_signal(&COND_wsrep_rollback);
- mysql_mutex_unlock(&LOCK_wsrep_rollback);
+ wsrep_unlock_rollback();
wsrep_thd_UNLOCK(thd);
break;
diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h
index 9c190bb90cb..c1706a059e2 100644
--- a/storage/innobase/handler/ha_innodb.h
+++ b/storage/innobase/handler/ha_innodb.h
@@ -476,38 +476,7 @@ __attribute__((nonnull));
extern void mysql_bin_log_commit_pos(THD *thd, ulonglong *out_pos, const char **out_file);
#ifdef WITH_WSREP
-#include <wsrep_mysqld.h>
-//extern "C" int wsrep_trx_order_before(void *thd1, void *thd2);
-
-extern "C" bool wsrep_thd_is_wsrep_on(THD *thd);
-
-extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
-extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd);
-extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd);
-extern "C" const char * wsrep_thd_exec_mode_str(THD *thd);
-extern "C" const char * wsrep_thd_conflict_state_str(THD *thd);
-extern "C" const char * wsrep_thd_query_state_str(THD *thd);
-extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd);
-
-extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode);
-extern "C" void wsrep_thd_set_query_state(
- THD *thd, enum wsrep_query_state state);
-extern "C" void wsrep_thd_set_conflict_state(
- THD *thd, enum wsrep_conflict_state state);
-
-extern "C" void wsrep_thd_set_trx_to_replay(THD *thd, uint64 trx_id);
-
-extern "C"void wsrep_thd_LOCK(THD *thd);
-extern "C"void wsrep_thd_UNLOCK(THD *thd);
-extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd);
-extern "C" time_t wsrep_thd_query_start(THD *thd);
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd);
-extern "C" int64_t wsrep_thd_trx_seqno(THD *thd);
-extern "C" query_id_t wsrep_thd_query_id(THD *thd);
-extern "C" char * wsrep_thd_query(THD *thd);
-extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd);
-extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id);
-extern "C" void wsrep_thd_awake(THD* thd, my_bool signal);
+#include <mysql/service_wsrep.h>
#endif
extern const struct _ft_vft ft_vft_result;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 5ba6df883aa..123dbdf254d 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -49,10 +49,6 @@ Smart ALTER TABLE
#include "pars0pars.h"
#include "row0sel.h"
#include "ha_innodb.h"
-#ifdef WITH_WSREP
-//#include "wsrep_api.h"
-#include <sql_acl.h> // PROCESS_ACL
-#endif
/** Operations for creating secondary indexes (no rebuild needed) */
static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_ONLINE_CREATE
diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h
index 563a01f747d..212df1a1283 100644
--- a/storage/innobase/include/ha_prototypes.h
+++ b/storage/innobase/include/ha_prototypes.h
@@ -291,18 +291,11 @@ UNIV_INTERN
int
wsrep_innobase_kill_one_trx(void *thd_ptr,
const trx_t *bf_trx, trx_t *victim_trx, ibool signal);
-my_bool wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
-int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
-my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
-my_bool wsrep_thd_is_wsrep(void *thd_ptr);
-int wsrep_trx_order_before(void *thd1, void *thd2);
int wsrep_innobase_mysql_sort(int mysql_type, uint charset_number,
- unsigned char* str, unsigned int str_length,
- unsigned int buf_length);
-int
-wsrep_on(void *thd_ptr);
-extern "C" int wsrep_is_wsrep_xid(const void*);
+ unsigned char* str, unsigned int str_length,
+ unsigned int buf_length);
#endif /* WITH_WSREP */
+
/**********************************************************************//**
Determines the connection character set.
@return connection character set */
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index 5265d3c8cf5..bf665eb1955 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -50,11 +50,8 @@ Created 5/7/1996 Heikki Tuuri
#include "dict0boot.h"
#include <set>
-#ifdef WITH_WSREP
-extern my_bool wsrep_debug;
-extern my_bool wsrep_log_conflicts;
-#include "ha_prototypes.h"
-#endif
+#include <mysql/service_wsrep.h>
+
/* Restricts the length of search we will do in the waits-for
graph of transactions */
#define LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK 1000000
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index adced7059e4..b0581945835 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -51,10 +51,9 @@ Created 12/27/1996 Heikki Tuuri
#include "pars0sym.h"
#include "eval0eval.h"
#include "buf0lru.h"
-#ifdef WITH_WSREP
-extern my_bool wsrep_debug;
-#endif
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
/* What kind of latch and lock can we assume when the control comes to
-------------------------------------------------------------------
diff --git a/storage/innobase/srv/srv0conc.cc b/storage/innobase/srv/srv0conc.cc
index cbf81f8e8f7..8942eb20080 100644
--- a/storage/innobase/srv/srv0conc.cc
+++ b/storage/innobase/srv/srv0conc.cc
@@ -41,11 +41,8 @@ Created 2011/04/18 Sunny Bains
#include "sync0sync.h"
#include "trx0trx.h"
-#include "mysql/plugin.h"
-#ifdef WITH_WSREP
-extern "C" int wsrep_trx_is_aborting(void *thd_ptr);
-extern my_bool wsrep_debug;
-#endif
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
/** Number of times a thread is allowed to enter InnoDB within the same
SQL query after it has once got the ticket. */
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc
index 4af61d4869b..9dc0ef96460 100644
--- a/storage/innobase/trx/trx0sys.cc
+++ b/storage/innobase/trx/trx0sys.cc
@@ -44,9 +44,7 @@ Created 3/26/1996 Heikki Tuuri
#include "os0file.h"
#include "read0read.h"
-#ifdef WITH_WSREP
-#include "ha_prototypes.h" /* wsrep_is_wsrep_xid() */
-#endif /* */
+#include <mysql/service_wsrep.h>
/** The file format tag structure with id and name. */
struct file_format_t {
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 48073667b2f..96e843647ea 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -29,6 +29,8 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0trx.ic"
#endif
+#include <mysql/service_wsrep.h>
+
#include "trx0undo.h"
#include "trx0rseg.h"
#include "log0log.h"
@@ -1028,7 +1030,7 @@ trx_write_serialisation_history(
#ifdef WITH_WSREP
sys_header = trx_sysf_get(mtr);
/* Update latest MySQL wsrep XID in trx sys header. */
- if (wsrep_is_wsrep_xid((const void *)&trx->xid))
+ if (wsrep_is_wsrep_xid(&trx->xid))
{
trx_sys_update_wsrep_checkpoint(&trx->xid, sys_header, mtr);
}
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 76de9efe080..1355c8a22a1 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -117,6 +117,9 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include "i_s.h"
#include "xtradb_i_s.h"
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
+
# ifndef MYSQL_PLUGIN_IMPORT
# define MYSQL_PLUGIN_IMPORT /* nothing */
# endif /* MYSQL_PLUGIN_IMPORT */
@@ -141,13 +144,6 @@ wsrep_ws_handle(THD* thd, const trx_t* trx) {
(wsrep_trx_id_t)trx->id);
}
-extern bool wsrep_prepare_key_for_innodb(const uchar *cache_key,
- size_t cache_key_len,
- const uchar* row_id,
- size_t row_id_len,
- wsrep_buf_t* key,
- size_t* key_len);
-
extern handlerton * wsrep_hton;
extern TC_LOG* tc_log;
extern void wsrep_cleanup_transaction(THD *thd);
@@ -4136,7 +4132,7 @@ innobase_commit_low(
#ifdef WITH_WSREP
THD* thd = (THD*)trx->mysql_thd;
const char* tmp = 0;
- if (wsrep_on((void*)thd)) {
+ if (wsrep_on(thd)) {
#ifdef WSREP_PROC_INFO
char info[64];
info[sizeof(info) - 1] = '\0';
@@ -4155,7 +4151,7 @@ innobase_commit_low(
trx_commit_for_mysql(trx);
}
#ifdef WITH_WSREP
- if (wsrep_on((void*)thd)) { thd_proc_info(thd, tmp); }
+ if (wsrep_on(thd)) { thd_proc_info(thd, tmp); }
#endif /* WITH_WSREP */
}
@@ -4933,7 +4929,7 @@ innobase_kill_connection(
#ifdef WITH_WSREP
wsrep_thd_LOCK(thd);
- if (wsrep_thd_conflict_state(thd) != NO_CONFLICT) {
+ if (wsrep_thd_get_conflict_state(thd) != NO_CONFLICT) {
/* if victim has been signaled by BF thread and/or aborting
is already progressing, following query aborting is not necessary
any more.
@@ -10250,7 +10246,7 @@ wsrep_append_foreign_key(
wsrep_buf_t wkey_part[3];
wsrep_key_t wkey = {wkey_part, 3};
- if (!wsrep_prepare_key_for_innodb(
+ if (!wsrep_prepare_key(
(const uchar*)cache_key,
cache_key_len + 1,
(const uchar*)key, len+1,
@@ -10296,7 +10292,7 @@ wsrep_append_key(
#ifdef WSREP_DEBUG_PRINT
fprintf(stderr, "%s conn %ld, trx %lu, keylen %d, table %s ",
(shared) ? "Shared" : "Exclusive",
- wsrep_thd_thread_id(thd), (long long)trx->id, key_len,
+ thd_get_thread_id(thd), (long long)trx->id, key_len,
table_share->table_name.str);
for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]);
@@ -10305,7 +10301,7 @@ wsrep_append_key(
#endif
wsrep_buf_t wkey_part[3];
wsrep_key_t wkey = {wkey_part, 3};
- if (!wsrep_prepare_key_for_innodb(
+ if (!wsrep_prepare_key(
(const uchar*)table_share->table_cache_key.str,
table_share->table_cache_key.length,
(const uchar*)key, key_len,
@@ -10353,7 +10349,7 @@ ha_innobase::wsrep_append_keys(
if (table_share && table_share->tmp_table != NO_TMP_TABLE) {
WSREP_DEBUG("skipping tmp table DML: THD: %lu tmp: %d SQL: %s",
- wsrep_thd_thread_id(thd),
+ thd_get_thread_id(thd),
table_share->tmp_table,
(wsrep_thd_query(thd)) ?
wsrep_thd_query(thd) : "void");
@@ -18444,7 +18440,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: %lu",
signal, (long long)bf_seqno,
- wsrep_thd_thread_id(thd),
+ thd_get_thread_id(thd),
victim_trx->id);
WSREP_DEBUG("Aborting query: %s",
@@ -18460,10 +18456,10 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
WSREP_DEBUG("withdraw for BF trx: %lu, state: %d",
victim_trx->id,
- wsrep_thd_conflict_state(thd));
+ wsrep_thd_get_conflict_state(thd));
}
- switch (wsrep_thd_conflict_state(thd)) {
+ switch (wsrep_thd_get_conflict_state(thd)) {
case NO_CONFLICT:
wsrep_thd_set_conflict_state(thd, MUST_ABORT);
break;
@@ -18478,7 +18474,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
case ABORTING: // fall through
default:
WSREP_DEBUG("victim %lu in state %d",
- victim_trx->id, wsrep_thd_conflict_state(thd));
+ victim_trx->id, wsrep_thd_get_conflict_state(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
break;
@@ -18489,7 +18485,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
enum wsrep_status rcode;
WSREP_DEBUG("kill query for: %ld",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
WSREP_DEBUG("kill trx QUERY_COMMITTING for %lu",
victim_trx->id);
@@ -18537,7 +18533,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
victim_trx->lock.was_chosen_as_deadlock_victim= TRUE;
if (victim_trx->lock.wait_lock) {
WSREP_DEBUG("victim has wait flag: %ld",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
lock_t* wait_lock = victim_trx->lock.wait_lock;
if (wait_lock) {
WSREP_DEBUG("canceling wait lock");
@@ -18550,9 +18546,9 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
} else {
/* abort currently executing query */
DBUG_PRINT("wsrep",("sending KILL_QUERY to: %ld",
- wsrep_thd_thread_id(thd)));
+ thd_get_thread_id(thd)));
WSREP_DEBUG("kill query for: %ld",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
/* Note that innobase_kill_connection will take lock_mutex
and trx_mutex */
wsrep_thd_UNLOCK(thd);
@@ -18591,7 +18587,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
if (abortees->aborting_thd == thd) {
skip_abort = true;
WSREP_WARN("duplicate thd aborter %lu",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
}
abortees = abortees->next;
}
@@ -18602,10 +18598,10 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
aborting->aborting_thd = thd;
aborting->next = wsrep_aborting_thd;
wsrep_aborting_thd = aborting;
- DBUG_PRINT("wsrep",("enqueuing trx abort for %lu",
- wsrep_thd_thread_id(thd)));
+ DBUG_PRINT("wsrep",("enqueuing trx abort for %lu",
+ thd_get_thread_id(thd)));
WSREP_DEBUG("enqueuing trx abort for (%lu)",
- wsrep_thd_thread_id(thd));
+ thd_get_thread_id(thd));
}
DBUG_PRINT("wsrep",("signalling wsrep rollbacker"));
@@ -18660,7 +18656,7 @@ wsrep_abort_transaction(handlerton* hton, THD *bf_thd, THD *victim_thd,
static int innobase_wsrep_set_checkpoint(handlerton* hton, const XID* xid)
{
DBUG_ASSERT(hton == innodb_hton_ptr);
- if (wsrep_is_wsrep_xid((const void *)xid)) {
+ if (wsrep_is_wsrep_xid(xid)) {
mtr_t mtr;
mtr_start(&mtr);
trx_sysf_t* sys_header = trx_sysf_get(&mtr);
diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h
index d6a1b738fe7..0c76c286030 100644
--- a/storage/xtradb/handler/ha_innodb.h
+++ b/storage/xtradb/handler/ha_innodb.h
@@ -487,33 +487,18 @@ struct trx_t;
extern "C" bool wsrep_thd_is_wsrep_on(THD *thd);
-extern "C" enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
-extern "C" enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd);
-extern "C" enum wsrep_query_state wsrep_thd_query_state(THD *thd);
-extern "C" const char * wsrep_thd_exec_mode_str(THD *thd);
-extern "C" const char * wsrep_thd_conflict_state_str(THD *thd);
-extern "C" const char * wsrep_thd_query_state_str(THD *thd);
-extern "C" wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd);
extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode);
extern "C" void wsrep_thd_set_query_state(
THD *thd, enum wsrep_query_state state);
-extern "C" void wsrep_thd_set_conflict_state(
- THD *thd, enum wsrep_conflict_state state);
extern "C" void wsrep_thd_set_trx_to_replay(THD *thd, uint64 trx_id);
-extern "C"void wsrep_thd_LOCK(THD *thd);
-extern "C"void wsrep_thd_UNLOCK(THD *thd);
extern "C" uint32 wsrep_thd_wsrep_rand(THD *thd);
extern "C" time_t wsrep_thd_query_start(THD *thd);
-extern "C" my_thread_id wsrep_thd_thread_id(THD *thd);
-extern "C" int64_t wsrep_thd_trx_seqno(THD *thd);
extern "C" query_id_t wsrep_thd_query_id(THD *thd);
-extern "C" char * wsrep_thd_query(THD *thd);
extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd);
extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id);
-extern "C" void wsrep_thd_awake(THD* thd, my_bool signal);
#endif
extern const struct _ft_vft ft_vft_result;
diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h
index 4ebaee3c89e..f038b307a6e 100644
--- a/storage/xtradb/include/ha_prototypes.h
+++ b/storage/xtradb/include/ha_prototypes.h
@@ -290,17 +290,9 @@ UNIV_INTERN
int
wsrep_innobase_kill_one_trx(void *thd_ptr,
const trx_t *bf_trx, trx_t *victim_trx, ibool signal);
-my_bool wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
-int wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
-my_bool wsrep_thd_is_BF(void *thd_ptr, my_bool sync);
-my_bool wsrep_thd_is_wsrep(void *thd_ptr);
-int wsrep_trx_order_before(void *thd1, void *thd2);
int wsrep_innobase_mysql_sort(int mysql_type, uint charset_number,
unsigned char* str, unsigned int str_length,
unsigned int buf_length);
-int
-wsrep_on(void *thd_ptr);
-extern "C" int wsrep_is_wsrep_xid(const void*);
#endif /* WITH_WSREP */
/**********************************************************************//**
Determines the connection character set.
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index d308e04d07d..8cf77e1ec82 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -50,11 +50,8 @@ Created 5/7/1996 Heikki Tuuri
#include "dict0boot.h"
#include <set>
-#ifdef WITH_WSREP
-extern my_bool wsrep_debug;
-extern my_bool wsrep_log_conflicts;
-#include "ha_prototypes.h"
-#endif
+#include <mysql/service_wsrep.h>
+
/* Restricts the length of search we will do in the waits-for
graph of transactions */
#define LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK 1000000
diff --git a/storage/xtradb/lock/lock0wait.cc b/storage/xtradb/lock/lock0wait.cc
index 388c847f580..77aa0261a0f 100644
--- a/storage/xtradb/lock/lock0wait.cc
+++ b/storage/xtradb/lock/lock0wait.cc
@@ -33,6 +33,8 @@ Created 25/5/2010 Sunny Bains
#include "ha_prototypes.h"
#include "lock0priv.h"
+#include <mysql/service_wsrep.h>
+
/*********************************************************************//**
Print the contents of the lock_sys_t::waiting_threads array. */
static
diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc
index bdd2a691368..a642f7932b7 100644
--- a/storage/xtradb/row/row0upd.cc
+++ b/storage/xtradb/row/row0upd.cc
@@ -53,10 +53,9 @@ Created 12/27/1996 Heikki Tuuri
#include "pars0sym.h"
#include "eval0eval.h"
#include "buf0lru.h"
-#ifdef WITH_WSREP
-extern my_bool wsrep_debug;
-#endif
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
/* What kind of latch and lock can we assume when the control comes to
-------------------------------------------------------------------
diff --git a/storage/xtradb/srv/srv0conc.cc b/storage/xtradb/srv/srv0conc.cc
index 5868e4e012b..c4cf1b9ab7b 100644
--- a/storage/xtradb/srv/srv0conc.cc
+++ b/storage/xtradb/srv/srv0conc.cc
@@ -42,11 +42,8 @@ Created 2011/04/18 Sunny Bains
#include "btr0types.h"
#include "trx0trx.h"
-#include "mysql/plugin.h"
-#ifdef WITH_WSREP
-extern "C" int wsrep_trx_is_aborting(void *thd_ptr);
-extern my_bool wsrep_debug;
-#endif
+#include <mysql/plugin.h>
+#include <mysql/service_wsrep.h>
/** Number of times a thread is allowed to enter InnoDB within the same
SQL query after it has once got the ticket. */
diff --git a/storage/xtradb/trx/trx0roll.cc b/storage/xtradb/trx/trx0roll.cc
index eb2af877a6d..b349614badf 100644
--- a/storage/xtradb/trx/trx0roll.cc
+++ b/storage/xtradb/trx/trx0roll.cc
@@ -29,6 +29,8 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0roll.ic"
#endif
+#include <mysql/service_wsrep.h>
+
#include "fsp0fsp.h"
#include "mach0data.h"
#include "trx0rseg.h"
diff --git a/storage/xtradb/trx/trx0sys.cc b/storage/xtradb/trx/trx0sys.cc
index 19d14bf6f38..9b59ae14278 100644
--- a/storage/xtradb/trx/trx0sys.cc
+++ b/storage/xtradb/trx/trx0sys.cc
@@ -48,6 +48,8 @@ Created 3/26/1996 Heikki Tuuri
#include "ha_prototypes.h" /* wsrep_is_wsrep_xid() */
#endif /* */
+#include <mysql/service_wsrep.h>
+
/** The file format tag structure with id and name. */
struct file_format_t {
ulint id; /*!< id of the file format */
@@ -362,7 +364,7 @@ trx_sys_update_wsrep_checkpoint(
#endif /* UNIV_DEBUG */
ut_ad(xid && mtr);
- ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid((const void *)xid));
+ ut_a(xid->formatID == -1 || wsrep_is_wsrep_xid(xid));
if (mach_read_from_4(sys_header + TRX_SYS_WSREP_XID_INFO
+ TRX_SYS_WSREP_XID_MAGIC_N_FLD)
diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc
index d26517637cd..30d4b7f6546 100644
--- a/storage/xtradb/trx/trx0trx.cc
+++ b/storage/xtradb/trx/trx0trx.cc
@@ -30,6 +30,8 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0trx.ic"
#endif
+#include <mysql/service_wsrep.h>
+
#include "trx0undo.h"
#include "trx0rseg.h"
#include "log0log.h"
@@ -1226,7 +1228,7 @@ trx_write_serialisation_history(
#ifdef WITH_WSREP
sys_header = trx_sysf_get(mtr);
/* Update latest MySQL wsrep XID in trx sys header. */
- if (wsrep_is_wsrep_xid((const void *)&trx->xid))
+ if (wsrep_is_wsrep_xid(&trx->xid))
{
trx_sys_update_wsrep_checkpoint(&trx->xid, sys_header, mtr);
}