summaryrefslogtreecommitdiff
path: root/sql/wsrep_client_service.cc
diff options
context:
space:
mode:
authorTeemu Ollakka <teemu.ollakka@galeracluster.com>2019-02-19 22:56:39 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2019-02-25 08:31:52 +0200
commit24be84384cf6d138b13ae9c03ae2be7d8cd184af (patch)
tree119aecc3d85322908ba95c24b75ce71dcb1fa773 /sql/wsrep_client_service.cc
parent6edfeb82fdf95f753b1ee4a1858ddc7740eaaab1 (diff)
downloadmariadb-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.
Diffstat (limited to 'sql/wsrep_client_service.cc')
-rw-r--r--sql/wsrep_client_service.cc27
1 files changed, 14 insertions, 13 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;
}