Skip to content
Permalink
Browse files
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.
  • Loading branch information
temeo authored and Jan Lindström committed Feb 25, 2019
1 parent 6edfeb8 commit 24be843
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
@@ -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;
}

@@ -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();

0 comments on commit 24be843

Please sign in to comment.