diff options
author | Teemu Ollakka <teemu.ollakka@galeracluster.com> | 2019-02-19 22:56:39 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-02-25 08:31:52 +0200 |
commit | 24be84384cf6d138b13ae9c03ae2be7d8cd184af (patch) | |
tree | 119aecc3d85322908ba95c24b75ce71dcb1fa773 | |
parent | 6edfeb82fdf95f753b1ee4a1858ddc7740eaaab1 (diff) | |
download | mariadb-git-24be84384cf6d138b13ae9c03ae2be7d8cd184af.tar.gz |
Simplified Wsrep_client_service::interrupted()
Wsrep-lib is now guaranteed to hold the underlying mutex
which is wrapped in lock object passed to Wsrep_client_service
interrupted() call. The library part will now take care of
checking the wsrep::transaction specific state, so it is
enough to check the thd->killed state for the result.
-rw-r--r-- | sql/wsrep_client_service.cc | 27 | ||||
-rw-r--r-- | sql/wsrep_client_service.h | 2 | ||||
m--------- | wsrep-lib | 0 |
3 files changed, 15 insertions, 14 deletions
diff --git a/sql/wsrep_client_service.cc b/sql/wsrep_client_service.cc index dd6d7d0bcfb..c042a1ea051 100644 --- a/sql/wsrep_client_service.cc +++ b/sql/wsrep_client_service.cc @@ -32,6 +32,7 @@ #include "log.h" /* stmt_has_updated_trans_table() */ //#include "debug_sync.h" #include "mysql/service_debug_sync.h" +#include "mysql/psi/mysql_thread.h" /* mysql_mutex_assert_owner() */ namespace { @@ -68,24 +69,24 @@ void Wsrep_client_service::reset_globals() DBUG_VOID_RETURN; } -bool Wsrep_client_service::interrupted() const +bool Wsrep_client_service::interrupted( + wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED) const { DBUG_ASSERT(m_thd == current_thd); - mysql_mutex_lock(&m_thd->LOCK_thd_data); - - /* wsrep state can be interrupted only if THD was explicitly killed, - for wsrep conflicts, we use deadlock error only - */ - bool ret= (m_thd->killed != NOT_KILLED && - m_thd->wsrep_trx().state() != wsrep::transaction::s_must_abort && - m_thd->wsrep_trx().state() != wsrep::transaction::s_aborting && - m_thd->wsrep_trx().state() != wsrep::transaction::s_aborted); - mysql_mutex_unlock(&m_thd->LOCK_thd_data); + /* Underlying mutex in lock object points to LOCK_thd_data, which + protects m_thd->wsrep_trx(), LOCK_thd_kill protects m_thd->killed. + Locking order is: + 1) LOCK_thd_data + 2) LOCK_thd_kill */ + mysql_mutex_assert_owner(static_cast<mysql_mutex_t*>(lock.mutex().native())); + mysql_mutex_lock(&m_thd->LOCK_thd_kill); + bool ret= (m_thd->killed != NOT_KILLED); if (ret) { - WSREP_DEBUG("wsrep state is interrupted, THD::killed %d trx state %d", - m_thd->killed, m_thd->wsrep_trx().state()); + WSREP_DEBUG("wsrep state is interrupted, THD::killed %d trx state %d", + m_thd->killed, m_thd->wsrep_trx().state()); } + mysql_mutex_unlock(&m_thd->LOCK_thd_kill); return ret; } diff --git a/sql/wsrep_client_service.h b/sql/wsrep_client_service.h index 43edae3441d..b1695b7aedf 100644 --- a/sql/wsrep_client_service.h +++ b/sql/wsrep_client_service.h @@ -36,7 +36,7 @@ class Wsrep_client_service : public wsrep::client_service public: Wsrep_client_service(THD*, Wsrep_client_state&); - bool interrupted() const; + bool interrupted(wsrep::unique_lock<wsrep::mutex>&) const; void reset_globals(); void store_globals(); int prepare_data_for_replication(); diff --git a/wsrep-lib b/wsrep-lib -Subproject ab0e5f5d776f1bb7472a6c7e50c475312e562bf +Subproject 9bec7d940cd27c9ea14e1665c4a4fd0ee5890ea |