diff options
author | sjaakola <seppo.jaakola@iki.fi> | 2015-04-28 20:38:25 +0300 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-09-09 21:31:16 -0400 |
commit | 63c5bee535f0827721484c93a2ba8798437fadf5 (patch) | |
tree | 7a1ba13a833c784532372e2adcfc8c95530fe132 | |
parent | 417f778e53f6d3c111ef25976d7f1b2d532ca2a3 (diff) | |
download | mariadb-git-63c5bee535f0827721484c93a2ba8798437fadf5.tar.gz |
Refs codership/mysql-wsrep#113 - Extended the protection of local FLUSH
sessions to cover all exclusive MDL locks
-rw-r--r-- | sql/mdl.cc | 17 | ||||
-rw-r--r-- | sql/mdl.h | 3 | ||||
-rw-r--r-- | sql/sql_class.cc | 1 | ||||
-rw-r--r-- | sql/sql_parse.cc | 17 | ||||
-rw-r--r-- | sql/wsrep_hton.cc | 2 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 2 | ||||
-rw-r--r-- | sql/wsrep_mysqld.h | 2 | ||||
-rw-r--r-- | sql/wsrep_thd.cc | 5 |
8 files changed, 26 insertions, 23 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc index f6390983ad9..e18194e8663 100644 --- a/sql/mdl.cc +++ b/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 */ diff --git a/sql/mdl.h b/sql/mdl.h index 421258c2ab7..0898a0f75b7 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -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()); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index af03a3b10b3..4ce99da7c7d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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"; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 13646c3a0c6..42ad69d84ec 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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*/ /* diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 9809b5d9550..03bf072edcc 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -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; } diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 1e46d577875..20ba2d7a51a 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -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); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 55323d68a48..414284f45fd 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -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 */ diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 2b251ef5d58..d898c982b1d 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -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()); +} |