Commit 63c5bee5 authored by sjaakola's avatar sjaakola Committed by Nirbhay Choubey

Refs codership/mysql-wsrep#113 - Extended the protection of local FLUSH

sessions to cover all exclusive MDL locks
parent 417f778e
...@@ -3373,4 +3373,21 @@ void MDL_ticket::wsrep_report(bool debug) ...@@ -3373,4 +3373,21 @@ void MDL_ticket::wsrep_report(bool debug)
psi_stage->m_name); 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 */ #endif /* WITH_WSREP */
...@@ -934,7 +934,8 @@ class MDL_context ...@@ -934,7 +934,8 @@ class MDL_context
public: public:
#ifdef WITH_WSREP #ifdef WITH_WSREP
THD *wsrep_get_thd() const { return get_thd(); } THD *wsrep_get_thd() const { return get_thd(); }
#endif bool wsrep_has_explicit_locks();
#endif /* WITH_WSREP */
void find_deadlock(); void find_deadlock();
ulong get_thread_id() const { return thd_get_thread_id(get_thd()); } 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) ...@@ -861,7 +861,6 @@ extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
return return
(!thd) ? "void" : (!thd) ? "void" :
(thd->wsrep_exec_mode == LOCAL_STATE) ? "local" : (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 == REPL_RECV) ? "applier" :
(thd->wsrep_exec_mode == TOTAL_ORDER) ? "total order" : (thd->wsrep_exec_mode == TOTAL_ORDER) ? "total order" :
(thd->wsrep_exec_mode == LOCAL_COMMIT) ? "local commit" : "void"; (thd->wsrep_exec_mode == LOCAL_COMMIT) ? "local commit" : "void";
......
...@@ -4165,11 +4165,6 @@ case SQLCOM_PREPARE: ...@@ -4165,11 +4165,6 @@ case SQLCOM_PREPARE:
} }
case SQLCOM_UNLOCK_TABLES: 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 It is critical for mysqldump --single-transaction --master-data that
UNLOCK TABLES does not implicitely commit a connection which has only UNLOCK TABLES does not implicitely commit a connection which has only
...@@ -4672,12 +4667,6 @@ case SQLCOM_PREPARE: ...@@ -4672,12 +4667,6 @@ case SQLCOM_PREPARE:
FALSE, UINT_MAX, FALSE)) FALSE, UINT_MAX, FALSE))
goto error; 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)) if (flush_tables_with_read_lock(thd, all_tables))
goto error; goto error;
...@@ -4698,12 +4687,6 @@ case SQLCOM_PREPARE: ...@@ -4698,12 +4687,6 @@ case SQLCOM_PREPARE:
{ {
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL) 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*/ #endif /* WITH_WSREP*/
/* /*
......
...@@ -40,7 +40,7 @@ void wsrep_cleanup_transaction(THD *thd) ...@@ -40,7 +40,7 @@ void wsrep_cleanup_transaction(THD *thd)
thd->wsrep_ws_handle.trx_id= WSREP_UNDEFINED_TRX_ID; thd->wsrep_ws_handle.trx_id= WSREP_UNDEFINED_TRX_ID;
thd->wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED; thd->wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED;
thd->wsrep_trx_meta.depends_on= WSREP_SEQNO_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; return;
} }
......
...@@ -1500,7 +1500,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx, ...@@ -1500,7 +1500,7 @@ wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
ret = TRUE; ret = TRUE;
} }
else if (granted_thd->lex->sql_command == SQLCOM_FLUSH || 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"); WSREP_DEBUG("BF thread waiting for FLUSH");
ticket->wsrep_report(wsrep_debug); ticket->wsrep_report(wsrep_debug);
......
...@@ -30,8 +30,6 @@ class THD; ...@@ -30,8 +30,6 @@ class THD;
enum wsrep_exec_mode { enum wsrep_exec_mode {
/* Transaction processing before replication. */ /* Transaction processing before replication. */
LOCAL_STATE, LOCAL_STATE,
/* Local flush. */
LOCAL_FLUSH,
/* Slave thread applying write sets from other nodes or replaying thread. */ /* Slave thread applying write sets from other nodes or replaying thread. */
REPL_RECV, REPL_RECV,
/* Total-order-isolation mode */ /* Total-order-isolation mode */
......
...@@ -611,3 +611,8 @@ int wsrep_thd_in_locking_session(void *thd_ptr) ...@@ -611,3 +611,8 @@ int wsrep_thd_in_locking_session(void *thd_ptr)
return 0; return 0;
} }
bool wsrep_thd_has_explicit_locks(THD *thd)
{
assert(thd);
return (thd->mdl_context.wsrep_has_explicit_locks());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment