mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Refs codership/mysql-wsrep#113 - Extended the protection of local FLUSH
sessions to cover all exclusive MDL locks
This commit is contained in:
committed by
Nirbhay Choubey
parent
417f778e53
commit
63c5bee535
17
sql/mdl.cc
17
sql/mdl.cc
@@ -3373,4 +3373,21 @@ void MDL_ticket::wsrep_report(bool debug)
|
||||
psi_stage->m_name);
|
||||
}
|
||||
}
|
||||
bool MDL_context::wsrep_has_explicit_locks()
|
||||
{
|
||||
MDL_ticket *ticket = NULL;
|
||||
|
||||
Ticket_iterator it(m_tickets[MDL_EXPLICIT]);
|
||||
|
||||
while ((ticket = it++))
|
||||
{
|
||||
if (ticket->m_type == MDL_EXCLUSIVE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* WITH_WSREP */
|
||||
|
@@ -934,7 +934,8 @@ private:
|
||||
public:
|
||||
#ifdef WITH_WSREP
|
||||
THD *wsrep_get_thd() const { return get_thd(); }
|
||||
#endif
|
||||
bool wsrep_has_explicit_locks();
|
||||
#endif /* WITH_WSREP */
|
||||
void find_deadlock();
|
||||
|
||||
ulong get_thread_id() const { return thd_get_thread_id(get_thd()); }
|
||||
|
@@ -861,7 +861,6 @@ extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
|
||||
return
|
||||
(!thd) ? "void" :
|
||||
(thd->wsrep_exec_mode == LOCAL_STATE) ? "local" :
|
||||
(thd->wsrep_exec_mode == LOCAL_FLUSH) ? "flush" :
|
||||
(thd->wsrep_exec_mode == REPL_RECV) ? "applier" :
|
||||
(thd->wsrep_exec_mode == TOTAL_ORDER) ? "total order" :
|
||||
(thd->wsrep_exec_mode == LOCAL_COMMIT) ? "local commit" : "void";
|
||||
|
@@ -4165,11 +4165,6 @@ end_with_restore_list:
|
||||
}
|
||||
|
||||
case SQLCOM_UNLOCK_TABLES:
|
||||
#ifdef WITH_WSREP
|
||||
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
|
||||
if (thd->wsrep_exec_mode == LOCAL_FLUSH) thd->wsrep_exec_mode = LOCAL_STATE;
|
||||
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
|
||||
#endif /* WITH_WSREP */
|
||||
/*
|
||||
It is critical for mysqldump --single-transaction --master-data that
|
||||
UNLOCK TABLES does not implicitely commit a connection which has only
|
||||
@@ -4672,12 +4667,6 @@ end_with_restore_list:
|
||||
FALSE, UINT_MAX, FALSE))
|
||||
goto error;
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
|
||||
thd->wsrep_exec_mode = LOCAL_FLUSH;
|
||||
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
if (flush_tables_with_read_lock(thd, all_tables))
|
||||
goto error;
|
||||
|
||||
@@ -4698,12 +4687,6 @@ end_with_restore_list:
|
||||
{
|
||||
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
|
||||
thd->wsrep_exec_mode = LOCAL_FLUSH;
|
||||
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
|
||||
}
|
||||
#endif /* WITH_WSREP*/
|
||||
|
||||
/*
|
||||
|
@@ -40,7 +40,7 @@ void wsrep_cleanup_transaction(THD *thd)
|
||||
thd->wsrep_ws_handle.trx_id= WSREP_UNDEFINED_TRX_ID;
|
||||
thd->wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED;
|
||||
thd->wsrep_trx_meta.depends_on= WSREP_SEQNO_UNDEFINED;
|
||||
if (thd->wsrep_exec_mode != LOCAL_FLUSH) thd->wsrep_exec_mode= LOCAL_STATE;
|
||||
thd->wsrep_exec_mode= LOCAL_STATE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -1500,7 +1500,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
|
||||
ret = TRUE;
|
||||
}
|
||||
else if (granted_thd->lex->sql_command == SQLCOM_FLUSH ||
|
||||
granted_thd->wsrep_exec_mode == LOCAL_FLUSH)
|
||||
granted_thd->mdl_context.wsrep_has_explicit_locks())
|
||||
{
|
||||
WSREP_DEBUG("BF thread waiting for FLUSH");
|
||||
ticket->wsrep_report(wsrep_debug);
|
||||
|
@@ -30,8 +30,6 @@ class THD;
|
||||
enum wsrep_exec_mode {
|
||||
/* Transaction processing before replication. */
|
||||
LOCAL_STATE,
|
||||
/* Local flush. */
|
||||
LOCAL_FLUSH,
|
||||
/* Slave thread applying write sets from other nodes or replaying thread. */
|
||||
REPL_RECV,
|
||||
/* Total-order-isolation mode */
|
||||
|
@@ -611,3 +611,8 @@ int wsrep_thd_in_locking_session(void *thd_ptr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool wsrep_thd_has_explicit_locks(THD *thd)
|
||||
{
|
||||
assert(thd);
|
||||
return (thd->mdl_context.wsrep_has_explicit_locks());
|
||||
}
|
||||
|
Reference in New Issue
Block a user